Read two whole numbers a and b and print their sum.
What to build
A program that reads two values and adds them as numbers.
Requirements
- Read each line with
input(). - Convert each one to a whole number before adding.
Input
Two lines. Each line has one whole number between -1000000000 and 1000000000.
Output
One line: the value of a + b.
Constraints
Each number is between -1000000000 and 1000000000.
Example
Input:
3
4
Output:
7
Why it works
input() gives text, so without int the + would join the two pieces of text rather than add them.
Examples
Example 1 · Input
3 4
Expected output
7
Example 2 · Input
10 -25
Expected output
-15
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
input() always gives text. int(...) turns it into a number.
Solution
Show one correct solution (try it yourself first)
a = int(input()) b = int(input()) print(a + b)