Easy as Pie? - Teaching Code Literacy. Learn Python The Hard Way, 2nd Edition — Learn Python The Hard Way, 2nd Edition. PyLadies - Home. Code for America & City Governments. W3Schools Online Web Tutorials. Don’t Fear the Internet. Code Academy - Learn Ruby on Rails. Python Programming/Input and output. Input[edit] Note on Python version: The following uses the syntax of Python 2.x. Some of the following is not going to work with Python 3.x. Python has two functions designed for accepting data directly from the user: input()raw_input() There are also very simple ways of reading a file and, for stricter control over input, reading from stdin if necessary. raw_input()[edit] raw_input() asks the user for a string of data (ended with a newline), and simply returns the string.
Print raw_input('What is your name? Prints out What is your name? Example: in order to assign the user's name, i.e. string data, to a variable "x" you would type x = raw_input('What is your name? ') Once the user inputs his name, e.g. Print 'Your name is ' + x Your name is Simon input()[edit] input() uses raw_input to read a string of data, and then attempts to evaluate it as if it were a Python program, and then returns the value that results. More complicated expressions are possible. It is possible for a user to input: 7.