Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 4 - Selections - Programming Exercises - Page 130: 4.34

Answer

code

Work Step by Step

# 4.34 (Hex to heximal) Write a program that prompts the user to enter a hex character # and displays its corresponding heximal integer. hex = input("Enter a hex character: ") if '0' <= hex <= '9': print("The decimal value is", hex) elif hex.upper() == 'A': print("The decimal value is 10") elif hex.upper() == 'B': print("The decimal value is 11") elif hex.upper() == 'C': print("The decimal value is 12") elif hex.upper() == 'D': print("The decimal value is 13") elif hex.upper() == 'E': print("The decimal value is 14") elif hex.upper() == 'D': print("The decimal value is 15") else: print("Invalid input")
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.