Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started