Python Find the Largest Among 3 Numbers

In this snippet, we'll learn to find the largest among 3 numbers using if else.

Solution

Have a look at the solution:

num1 = 5
num2 = 7
num3 = 2

# input from user
# num1 = float(input("Enter 1st number: "))

if (num1 >= num2) and (num1 >= num3):
   largest = num1
elif (num2 >= num1) and (num2 >= num3):
   largest = num2
else:
   largest = num3

print("The largest number: ", largest)

Output:

The largest number:  7

Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.