Find the greater number using python| Taking input from user find that which number is greater or equal | python for beginner
Hello Reader's
In this post you are going to see that how you can find that which number is greater or equal while taking input from the user .
In this activity you are going to perform three operations the first one is to find the Greater number, and print the result that given number is greater and another operation is based on equals , What is the given numbers are equal?, how you can find them and print them, and the last operation is to compare the given numbers and print that A or B is greater.
To perform this activity there is need to install any module. now without wasting our time let's jump on the coding part.
We have to take two input from user so that we can compare that which number is greater. To do this simply type
a= int(input("Enter a number: "))
b= int(input("Enter another number: "))
This is going to take two input from user input A and input B.
if a>b: This line of code is going to initialize if loop and compare A and B and if A is greater the it will be going to execute the next line of code that is :-
print("A is greater") If A is greater then this line of code will be executed and print that "A is greater" .
elif a==b: This line of code is going to compare A and B to check that given numbers are equal to each other or not, if they are equal then only next line of code will be executed that is :-
print("Both numbers are equal") This line of code is going print only if the given numbers are equal.
else : This line of code if going to executed if and only if the given number A is not greater and A and B are not equal .
print("B is greater") This line id going to print that is B is grater than A.
Code :-
a= int(input("Enter a number: "))
b= int(input("Enter another number: "))
if a>b:
print("A is greater")
elif a==b:
print("Both numbers are equal")
else :
print("B is greater")
Comments
Post a Comment
Thank you for sharing this.
You’re helping us become better. Want to stay in the loop? Subscribe to our YouTube channel.