Answer to Question #97766 in Python for yousif

Question #97766
Write a program that asks the user for a number. If it is between 1 and 255, output the corresponding ASCII character. If it is outside of that range, output "Out of range"

Sample Run

Enter a number between 1 and 255: 97
a
Enter a number between 1 and 255: 256
Out of range
1
Expert's answer
2019-11-05T07:41:56-0500
while True:
    char = int(input("Enter a number between 1 and 255: "))
    if 1 <= char <= 255:
        x = chr(char)
        print(x)
        break
    else:
        print("Out of range")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS