How do I write a Python Program that will take a numeric input from the user (only values between0-255)?
October 15, 2011 – 4:00 pmAnd make it print out the input in decimal, hex, and binary?
Thanks
Related posts:
- Python Help. 1.Write python code that prompts the user to enter his or her height and assigns the user's input?
- How does one write a Java program to convert deimal number to binary using dialog boxes for input?
- In python, how to accept input and print the input AND raw_input?
- Python 3.1.3 How to tell the user to input an integer number?
- Can someone write me a program for python that deals the user 1 card from a deck?
- Write a Java application that lets the user input a sequence of integers terminated?
- I need help writing a python program that converts decimal to binary notation?
- Python : How do I detect, if user didnt type anything for user input?
- Write python code that will write 100 randomly-generated values between 1 and 19, inclusive, to a file called?
- How do you measure the number of times a user enters input in python?
One Response to “How do I write a Python Program that will take a numeric input from the user (only values between0-255)?”
i would use an in range comparison, then print using dec, hex, and, bin functions:
—
x = input("please input a number (0-255)")
if x in range(0,256):
—-print hex(x)
—
etc.
the rest is up to you. i assume for dec you want dec(str(x)) but it is unclear if you want the hex/bin of the dec value, the hex/bin of the ascii value, or just want to stay in dec
By ChaosGrimm on Oct 15, 2011