Input two numbers and display the larger / smaller number in Python. Today we are showing the code in python. This python project is useful for beginners, CBSE School Class 11 students Computer Science practical file and NIELIT O Level Programming and Problem Solving through Python (Module M3-R5). In
if case first the condition in the same line of if is evaluated if it is true then it is executed and else the commands after else is executed. So, This is evaluation method , plus executing method. Screenshot of the source code written it is very important to read every step Program code Input two numbers and display the larger / smaller number in Python. a = int(input(“Enter the first number: “)) #input first number Output of the program We enter the first number : 56 and the second number :28 an then comparing it tells 56 is greater. Testing is done . Run the python program and enter the required data. Source code of Program ->click here Thanks for reading and learning about this program.If/else case in Python
Objective : Input two numbers and display the larger / smaller number in Python.
Python Program to find Largest of two Numbers using if-else statements
b = int(input(“Enter the second number: “)) #input second number
if(a >= b): #comparing
print(a, “is greater”)
else:
print(b, “is greater”)
for more python programs -> click here
Hello World Program in Python
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
LCM and GCD program in Python
Python program to count number of vowels in a string
Whether a String is Palindrome or not in Python
Bubble Sort Program 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
Stack Program in Python
Queue Program 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
In this python program, we will take two numbers from user and display larger and smaller number in python, which can compare these two numbers and print larger and smaller number depending upon the user-entered input. Also, we will discuss how to check equality of both number in python Let us see how we can compare and display larger and
smaller number in python # python program to find smaller and larger number
#take two number from user
num1 = int(input("Enter first number :"))
num2 = int(input("Enter second number :"))
if (num1 > num2):
print(num1,"is larger than",num2)
elif (num1 == num2):
print(num1,"is equal to",num2)
else :
print(num1,"is smaller than",num2)
Here, we ask the user to enter first and second number of their choice. If the first number is greater than second
number then it will display ” first number is larger than second number” else it will display “first number is smaller than second number”. If both numbers are equal then we it will display “first number is equal to second number” Identify larger and smaller number in python
Program Logic:
Below is implementation code / Source code
Explanation:
Below is output of above code
>>> %Run 'smaller and larger number.py'
Enter first number :23
Enter second number :34
23 is smaller than 34
>>> %Run 'smaller and larger number.py'
Enter first number :34
Enter second number :33
34 is larger than 33
>>> %Run 'smaller and larger number.py'
Enter first number :23
Enter second number :23
23 is equal to 23
>>>
Snapshot of executable code
Post navigation