(1) Prompt the user to input an integer between 0 and 155, a float, a character,
ID: 2246995 • Letter: #
Question
(1) Prompt the user to input an integer between 0 and 155, a float, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. (Submit for 2 points).
(2) Extend to also output in reverse. (Submit for 1 point, so 3 points total).
(3) Extend to convert the integer to a character by using the 'chr()' function, and output that character. (Submit for 2 points, so 5 points total).
____________________________________________________
The pre-written code is as follows:
userInt = int(input('Enter integer (0 - 155): '))
# FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space
# FIXME (2): Output the four values in reverse
# FIXME (3): Convert the integer to a characer, and output that character
Have been struggling with this one, help would be appreciated
Explanation / Answer
userInt = int(input('Enter Integer (0 - 155): '))
userFloat = float(input('Enter Float: '))
userCharacter = input('Enter Character: ')
userString = str(input('Enter Integer (0 - 155): '))
print(userInt,userFloat,userCharacter,userString)
print(userString,userCharacter,userFloat,userInt)
userConvert = (chr(userInt))
print(userInt,'converted to a character is',userConvert)
OUTPUT
Enter Integer (0 - 155): 99
Enter Float: 3.77
Enter Character:z
Enter Integer (0 - 155):Howdy
99 3.77 z Howdy
Howdy z 3.77 99
99 converted to a character is c
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.