Conditional Statements · Python example
Combine conditions with and to find the maximum of three values.
This example compares three values and selects the largest using if, elif, and else. It also works when values are equal.
a = 14
b = 27
c = 9
if a >= b and a >= c:
largest = a
elif b >= a and b >= c:
largest = b
else:
largest = c
print(f"The largest number is {largest}")