int + intPractice
Add two numbers with variables
At checkout, the app reads two prices and adds them. You read two integers with input(), store in a and b, then print(a + b).
Picture this: two boxes, then add
Read a and b, put the sum in a new box.
afirst number
+
bsecond number
→
totala + b
Diagram — read → add → print
In easy words: What is this task?
You read two numbers, store them in variables, and add them. It is the basic input-process-output pattern.
Where this is used
Used in billing totals, score sums, quantity calculations, and any workflow where two numeric inputs are combined.
Real world: split bill
Friend A paid ₹120, Friend B paid ₹80. Total spent = 120 + 80 = 200. Your program does the same with any two numbers typed in.
1a = int(input())
2b = int(input())
3print(a + b)
Output: 10
Remember
input() gives text — use int() to turn "7" into the number 7.
- First line of input becomes
a, second line becomes b.
1a = int(input())
2b = int(input())
3print(a + b)