Computer Science, asked by yasirsahibzada, 1 year ago

Write python program which reverse entered num or string?​

Answers

Answered by sachinjethani2003
1

Answer:

hello for reverse number i had a program which is this

x= int(input(" Enter  Num: "))    

Rev= 0    

while(x > 0):    

   Rem=x %10    

   Rev = (Rev *10) + Rem    

   x = x//10    

     

print(" Reverse of entered num is = %d" %Rev)    

Explanation:

Answered by AskewTronics
1

Program in python :

Explanation:

number=input("Enter the number or string: ")#take the input from the user.

reverse=''#take a variable which holds the reverse.

for x in number:#for loop which is used to reverse.

   reverse=x+reverse#reverse expression.

print(reverse)#print the reverse.

Output:

  • If the user input as "hellow", it will prints "wolleh".
  • If the user inputs as "12345", it will prints "54321".

Code Expalantion:

  • The above code is in python language, in which the first line is used to take the input from the user. The input can be in the form of string or number or float.
  • Then there will be a for loop which scans the element and add the last in a reverse variable.
  • And then the string is reversed.

Learn More :

  • Python : https://brainly.in/question/14689905
Similar questions