Variables, Input & Output
Python · Beginner
Definition
Variables name values; input() reads text from the user and print() writes output.
The very first step in every Python program.
Diagram
Flowchart
Example: Fast input for contests
import io, sys
sys.stdin = io.StringIO('3 4\n')
a, b = map(int, input().split())
print(a + b)Output: 7
Key points
- input() always returns str
- sys.stdin.readline is faster for big inputs
Interview questions
How to print without newline?
print(x, end='').