Python Program to Add Two Numbers
easyInput and operatorsPython
The first program every Python course teaches after Hello World. It shows the three things almost every program does: read input, work on it, and print a result.
The question
Write a program that reads two integers (one per line) and prints their sum.
The code
Input
73 8
Output
Sum = 81
How it works
- 1input() always returns text, so int(input()) converts what the user types into a whole number.
- 2The two numbers are stored in a and b.
- 3a + b adds them. print() with a comma puts a space between "Sum =" and the answer.
Common mistakes
- Forgetting int(): "12" + "30" joins the text and prints 1230 instead of 42.
- Using float() when the question asks for integers — the answer then prints as 42.0.
Now solve a similar question yourself
A new Python question every time, checked instantly.
