Q:

Python | Find largest of three number using nested if else

belongs to collection: Python basic programs

0

Input three integer numbers and find the largest of them using nested if else in python.

Example:

    Input:
    Enter first number: 10
    Enter second number: 20
    Enter third number: 5

    Output:
    Largest number: 20

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

# input three integer numbers 
a=int(input("Enter A: "))
b=int(input("Enter B: "))
c=int(input("Enter C: "))

# conditions to find largest 
if a>b:
    if a>c:
        g=a
    else:
        g=c
else:
    if b>c:
        g=b
    else:
        g=c

# print the largest number 
print("Greater  = ",g)

Output

Enter A: 10
Enter B: 20
Enter C: 5
Greater  =  20

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python | Calculate discount based on the sale amou... >>
<< Python | Input age and check eligibility for votin...