Python Practice › If-Else Programs › Program 22
Larger of two numbers
Write a Python program to print the larger of two numbers.
Input
25, 63
Output
63
Approach
- Compare them with
>; handle equal numbers too.
Solution
a, b = 25, 63if a > b: print(a)elif b > a: print(b)else: print("Both are equal:", a)Output
63
Line by line
Lines 6-7
Equal numbers get their own message.
Learn the concept
New to this topic? Read the lesson, then come back.