Python bootcamp · Lab 06

Largest of three

easyIf Else10 minLesson: If Else

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

QuestionHint and solution stay closed until you open them

Read three integers (one per line) and print the largest.

Python has max() built in — but try it once with plain if statements too, so you understand what max() does under the hood.

Input. Three lines, each one integer.

Output. One integer: the largest of the three.

Examples

Example 1
Input
3
9
4
Output
9
Example 2 — Ties are fine — 5 is still the largest.
Input
5
5
2
Output
5
Hint
  1. max(a, b, c) returns the biggest of the three.
  2. By hand: start by assuming a is biggest, then compare against b and c.
Show correct code

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

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