Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in Python that defines a function called decToHex(). This function should take a single argument: a positive integer [1 mark]. If the

Write a program in Python that defines a function called decToHex(). This function should take a single argument: a positive integer [1 mark]. If the argument is within the range 0 though 15 (inclusive) your function should return a string of its value in the hexadecimal number system (you can use an If-Elif-Else statement to accomplish this) [2 marks]. If it is outside of this range, return an error message [1 mark]. E.g.,

>>> decToHex(5) "5" >>> decToHex(11) "B" >>> decToHex(17) "Error, value out of range" 

Note: Do not use the built in hex() function in your code or you will get zero for this question. Please include a number of function calls in your code to test your function beneath its definition.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

More Books