Home
Aptitude
Categories


Home » Python programs

Python | Find largest of three number using nested if else



Python | Nested if else example: Here, we are implement a program, it will input three numbers and find the largest of three numbers.
Submitted by Pankaj Singh, on October 04, 2018

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

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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.