enter two number and display the greater one in python?
Answers
Answered by
6
The given problem is solved using language - Python.
a=int(input('Enter a number: '))
b=int(input('Enter another number: '))
if a>b:
print('First number is greater than the second number.')
elif a<b:
print('Second number is greater than the first number.')
else:
print('Both the numbers you entered are equal.')
- Line 1 and 2: Accepts two numbers as input.
- Line 3: Check if the first number is greater than the second.
- Line 4: If true, display the first number entered.
- Line 5: Check if second number is greater than the first number.
- Line 6: If true, display the second number entered.
- Line 7-8: If all the conditions are false, the numbers are equal.
#1
Enter a number: 20
Enter another number: 10
First number is greater than the second number.
————————————————————————————
#2
Enter a number: 10
Enter another number: 20
Second number is greater than the first number.
————————————————————————————
#3
Enter a number: 15
Enter another number: 15
Both the numbers you entered are equal.
Attachments:
Similar questions