Find Greater, Smaller or Equal number in Python

Comparison Operators in Python 3

In this program, we will learn about comparison operators in Python 3. 

Before finding the Greater, Smaller or Equal Number. We have knowledge about Comparison Operators. There are different comparison operations in python like other programming languages like Java, C/C++, etc. Those Operators are given below:

  • Equal to Operator (==): If the values of two operands are equal, then the condition becomes true.
  • Not Equal to Operator (!=): If the values of two operands are not equal, then the condition becomes true.
  • Greater than Operator (>): If the value of the left operand is greater than the value of the right operand, then the condition becomes true.
  • Greater than equal to (>=): If the value of the left operand is greater than or equal to the value of the right operand, then the condition becomes true.
  • Smaller than Operator (<): If the value of the left operand is less than the value of the right operand, then the condition becomes true.
  • Smaller than equal to (<=): If the value of the left operand is less than or equal to the value of the right operand, then the condition becomes true.
https://youtube.com/watch?v=PV_OwGX8yh0

Find the Largest number smaller than or equal to number

def greater_smaller(num1,num2):

if num1>num2:

return "num_1 is greater"

elif num2>num1:

return "num_2 is greater"

return "both are equal"

#Here we take a input from user at a time.User have to enter number like 12,23 or 21,32. #Number will be seperated by comma. Or you can take input simple like num1=input() and #num2=input()
num1,num2=input("enter your num1&num2 values:").split(",")

print(greater_smaller(num1,num2))

Output:

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
enter your num1&num2 values:12,23
num_2 is greater

Process finished with exit code 0

Recommended Post:

Get Salesforce Answers

Pramod Kumar Yadav is from Janakpurdham, Nepal. He was born on December 23, 1996, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India.He is director of Appan Bazaar Pvt.Ltd., as teacher in Tridev Eng. School , and an Educational Consultant, and he is currently working as a developer and Digital Marketer.



Leave a Comment