Friday, March 2, 2012

Python Program To Read Value String From Keyboard And Save To A Variable

Python Program To Read Value String From Keyboard And Save To A Variable

see also -
python compiler download
how to compile a python code
Here i am going to explain how you can read strings and data like integer float long double long and other data types from keyboard and save it to a variable in python.The python code is simpler than java.Java program need more steps to read a value or string from keyboard.
You can run this code by saving the program to c:\python27\program.py and open the command prompt and type the above code ( in screen shot ).
Code to read a string from keyboard in python :


name = raw_input("Enter your name:") 
print "Hello", name 
raw_input("Press a to exit.") 

Here name is the variable and Enter your name: is the message will be printed


Tags : how to read data from keyboard in python.how to input data from keyboard to a python program,how to read a string from keyboard ,input a line from keyboard to python program,keyboard input handling in python,source code to read input from keyboard 

No comments:

Post a Comment