Skip to main content

Simple Input & Output

Output



Usually, programs take input and process it to produce output.
In Python, you can use the print function to produce output. This displays a textual representation of something to the screen.
>>> print(1 + 1)
2
>>> print("Hello\nWorld!")
Hello
World!

When a string is printed, the quotes around it are not displayed.

Input



To get input from the user in Python, you can use the intuitively named input function.
The function prompts the user for input, and returns what they enter as a string (with the contents automatically escaped).
>>> input("Enter something please: ")
Enter something please: This is what\nthe user enters!

'This is what

the user enters!

The print and input functions aren't very useful at the Python console, which automatically does input and output. However, they are very useful in actual programs.