Greatest of Three Numbers in Python using Nested if. It involves variable assignment and if – else Nested conditional operator. This is for Beginners, class 11,12 and Btech computer science students.
Write a program : WAP to input three numbers and print the greatest number in Python using nested if.
Nested if in Python : How it work !
Greatest of Three Numbers in Python using Nested if- Nested if means if condition under another if condition. So that first the if condition is checked, if it comes to be true then the next if condition is checked. There is 4 space indentation from first to another if and 4 space indentation of what to do if conditions comes true .
Write a program to find the greatest number from the given input
A basic python program source code to find the Greatest of Three Numbers using Nested if is written below:-
Program code explanation
a=float(input(“Enter the first number: “))#float is numbers like6.5 we can input integers and also decimal valued numbers
#Enter the first number will be printed then the input is to be given
b=float(input(“Enter the second number: “))#a,b,c are the 3 values taken as input to compare and output
c=float(input(“Enter the third number: “))#this three will be compared
if a>=b: # first the number is compared a,b if true it moves to the indented
if a>=c: #this indentation is under first condition first condition is true then only this line is read
print(“First number :”,a,”is greatest”) # Is printed on the output after above two conditions are fulfilled
if b>a:# first the number is compared a,b if true it moves to the indented
if b>c: #this indentation is under first condition first condition is true then only this line is read
print(“Second number :”,b,”is greatest”)# Is printed after above two conditions are fulfilled
if c>a: #first the number is compared a,b if true it moves to the indented
if c>b: #this indentation is under first condition first condition is true then only this line is read
print(“Third number :”,c,”is greatest”) # Is printed after above two conditions are fulfilled
Output of our program
Greatest of Three Numbers in Python using Nested if-
here various possible combination of input given and the following output .
This program Source code- click here
Input a welcome message and display it in Python
Display the larger / smaller number in Python.
Greatest of Three Numbers in Python using Nested if
Patterns using nested loop in Python
Program to Print Pattern in Python
Program to input the value of x and n and sum of series in Python
Python Program for Armstrong, Prefect Number, Palindrome
Program of Prime number by recursion in python
Prime Number Program in Python
Write a Program to Print Fibonacci Series in Python
Python program to count number of vowels in a string
Whether a String is Palindrome or not in Python
Linear search in python using list
Program to read a text file in python
Python program to read a file line by line
Program to Count Vowels and Consonants in Python
Python Leap Year Program for Beginners
Python Program to Print Series and Addition
Binary Search Program in Python
Program to find sum of digits in python
Sum of numbers divisible by 3 and 5 in python