Python bootcamp · Lab 02

Sum two numbers

easyInput8 minLesson: User Input

Read the question, write Python on the right, then Run or Check.

QuestionHint and solution stay closed until you open them

Read two integers, each on its own line, and print their sum.

input() always hands you a string, so you must convert it with int() before adding — otherwise "3" + "5" becomes "35".

Input. Two lines, each one integer.

Output. One integer: a + b

Constraints

  • -1,000,000 ≤ a, b ≤ 1,000,000

Examples

Example 1
Input
3
5
Output
8
Example 2 — Negatives are fair game.
Input
10
-4
Output
6
Hint
  1. a = int(input()) reads and converts the first line.
  2. Do the same for b, then print(a + b).
Show correct code

Peek only after you have tried. You can still Check your own version.

a = int(input())
b = int(input())
print(a + b)
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.