Skip to content
UPEEC

Input and Output

Read text with input() and write with print() — plus formatting options.

Beginner
Comments 0
name = input("Name: ")              # always returns a str
age = int(input("Age: "))           # convert explicitly
print("Hello", name, sep=", ", end="!\n")
print(f"{3.14159:.2f}")             # 3.14

For fast reading of large inputs (competitive programming) use sys.stdin.readline or sys.stdin.read().split().

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.