Nearly every useful program needs to take information in and show results back out. In Python, that means two functions you'll use constantly: input() to read from the keyboard, and print() to display text to the screen.

Getting Output with print()

The print() function writes text to the console. You can pass it one value or several, separated by commas:

print("Hello, World!")
print("The answer is", 42)

Output:

Hello, World!
The answer is 42

When you pass multiple values, print() automatically puts a space between them and a newline at the end — both of these defaults can be customized with the sep and end parameters:

print("a", "b", "c", sep="-")       # custom separator
print("Loading", end="...")        # custom ending (no newline)
print("Done!")

Output:

a-b-c
Loading...Done!

Getting Input with input()

The input() function pauses the program, waits for the user to type something and press Enter, and returns whatever they typed. You can pass it an optional message to display as a prompt:

name = input("What is your name? ")
print("Hello, " + name + "!")

Output:

What is your name? Alice
Hello, Alice!

The input() Gotcha: It's Always a String

This is one of the most common beginner mistakes: input() always returns a str, even if the user types a number. If you try to do math with it directly, Python will raise an error or produce the wrong result:

age = input("Enter your age: ")
print(type(age))

next_year = age + 1   # this line raises an error

Output:

<class 'str'>
TypeError: can only concatenate str (not "int") to str

The fix is to explicitly convert the input to the type you actually need, as covered in Python type conversion:

age = int(input("Enter your age: "))
next_year = age + 1
print("Next year you'll be", next_year)

Output:

Enter your age: 25
Next year you'll be 26

Wrapping input() directly in int() or float(), as shown above, is an extremely common pattern in Python code whenever you need numeric input — you can see it in action across many of the worked examples in our Python Programs collection.

With input and output covered, you've finished the absolute basics. The next section of this tutorial moves into controlling the flow of your program with conditions and loops.