In this Python tutorial, you will learn how to write a python program to find the Largest Number Among Three numbers.
Prerequisite for Python Program to Find the Largest Among Three Numbers
- Python Input, Output
- Python nested if…else statement
- Python Data types
- Python Type Conversion
- Python Comparison Operators
- Python Logical Operator
Steps
- First, we ask the user to enter 3 numbers.
- Using the float() function we will convert the entered values into floating number values.
- Using the if….elif statement and comparison operators, we check for conditions.
Python Program to Find the Largest Among Three Numbers
Python Code
num_1 = float(input("Enter First Number: "))
num_2 = float(input("Enter Second Number: "))
num_3 = float(input("Enter the Third Number: "))
if num_1 > num_2 and num_1> num_3:
print("The largest number is:", num_1)
elif num_2 > num_1 and num_2>num_3:
print("The largest number is:", num_2)
else:
print("The largest number is:", num_3)
Output 1:
Enter First Number: 19
Enter Second Number: 19
Enter the Third Number: 20
The largest number is: 20.0
Output:2
Enter First Number: 1009
Enter Second Number: 123
Enter Third Number: 2652
The largest number is: 2652.0
People are also reading:
- WAP to print the ASCII value of a character
- Python Program to Print Hello world!
- WAP to display a message on screen
- Python Examples
- WAP to check whether the entered number is prime or not
- WAP to Calculate Simple Interest
- Python Program to Shuffle a Deck of Cards
- WAP in C++ & Python to Reverse a String
- Python Program to Convert Celsius To Fahrenheit
- WAP to print the 1 to 10 Multiples of a Number
Leave a Comment on this Post