Respuesta :

Answer:

  1. num = int(input("Enter an integer between 20-98: "))
  2. if(num>=20 and num <= 98):
  3.    firstDigit = num // 10
  4.    secondDigit = num % 10
  5.    while(firstDigit != secondDigit):
  6.        print(num)
  7.        num = num - 1
  8.        firstDigit = num // 10
  9.        secondDigit = num % 10

Explanation:

Firstly, we prompt user to input a number ranged between 20-98 and validate it using an if condition statement (Line 1 -3).

Next, we extract the first digit of the num by using // operator. This is to the the division result which exclude the demical points. Then we use % operator to the second digit (Line 4 - 5). The % operator will get the remainder of the division. So, any num value divided by 10 will always result in the remainder that match the first digit of num.

Once we get the first and second digit, we can proceed to display the num (Line 7) and decrement it by one (Line 8). We use the // and % operators again to get the first and second digit or the new num ( (Line 9 -10)) and repeat the same process in next iteration until firstDigit is equal to secondDigit.

Answer:

x = int(input())

if(x>=20 and x<=98):

   print(x)

   while(not(x%10==x//10)):

       x-=1

       print(x)

elif x<20 or x>98:

   print("Input must be 20-98")

 

Explanation: