Example
Input
enter first number 5
enter second number 6
Output
Greater is 6
Required to Know
Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), Use of If-else, and Use of Data types.
Steps
Take two numbers as input from the user.
If the first_number is greater than the second_number, print first_number. Otherwise, print second_number.
Condition
if(first_number>second_number):
print(first_number)
else:
print(second_number)
Program
# This code compares two numbers and prints the larger number.
first_number = int(input("Enter the first number: "))
second_number = int(input("Enter the second number: "))
# Check if the first number is greater than the second number.
if first_number > second_number:
# Print the first number.
print("Greater is", first_number)
# Otherwise, print the second number.
else:
print("Greater is", second_number)