Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Under the hood, all Python data types need to be represented as binary integers to be understood by the computer's hardware. You will write a
Under the hood, all Python data types need to be represented as binary integers to be
understood by the computer's hardware. You will write a program to peek under the hood at
the decimal and binary representation of characters. You will need two new Python functions
to perform the conversion that work similar to the built in type conversion functions. The ord
function is used to convert a letter to an integer. The bin function converts an integer to a
string representation of a binary number. To see how these functions work you should play
with these functions in the shell, as we do in this example:
num ord
print num
binary bin
printbinary
Write a program that asks the user for a letter and prints out both the integer and binary
representations of the letter. It should ask the user for a character and then output the integer
and binary representations of the character. Here is an example of what the output should
look like if the user types the letter A at the prompt:
Enter a character:A
A corresponds to the integer which is b in binary.
Note in the output where we have inserted the character A and the decimal and binary
representations of that character. You will need to write a print statement that includes all
three as well as the intervening text.
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