Computer Science, asked by salonishukla165, 1 month ago

enter two number and display the greater one in python?​

Answers

Answered by anindyaadhikari13
6

\textsf{\large{\underline{Solution}:}}

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.')

\textsf{\large{\underline{Explanation}:}}

  1. Line 1 and 2: Accepts two numbers as input.
  2. Line 3: Check if the first number is greater than the second.
  3. Line 4: If true, display the first number entered.
  4. Line 5: Check if second number is greater than the first number.
  5. Line 6: If true, display the second number entered.
  6. Line 7-8: If all the conditions are false, the numbers are equal.

\textsf{\large{\underline{Sample I/O}:}}

#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