-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path24.py
More file actions
28 lines (22 loc) · 778 Bytes
/
24.py
File metadata and controls
28 lines (22 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Program No. : 24
Program : To find maximum of 3 numbers
def find_max_of_three():
print("--- Maximum of Three Numbers ---")
try:
# 1. Get three numbers as input
a = float(input("Enter first number (A): "))
b = float(input("Enter second number (B): "))
c = float(input("Enter third number (C): "))
# 2. Comparison Logic using logical 'and'
if (a >= b) and (a >= c):
largest = a
elif (b >= a) and (b >= c):
largest = b
else:
largest = c
# 3. Display Result
print(f"\nThe maximum of {a}, {b}, and {c} is: **{largest}**")
except ValueError:
print("Error: Please enter valid numeric values.")
# Run the program
find_max_of_three()