Question

# Write the functions with the following headers:# Return the reversal of an integer, e.g. reverse(456) returns # 654 def reverse(number): # Return true if number is a palindrome def isPalindrome(number): Use the reverse function to implement isPalindrome. A number is a palindrome if its reversal is the same as itself. Write a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.

Solution

Verified
def reverse(num):
'''Takes a positive int num, returns the int with reversed digits'''
stringified_num = str(num)
return int(stringified_num[::-1])

def isPalindrome(num):
'''Takes a positive int num, returns true if num is a palindrome'''
return reverse(num) == num

# Test
num = eval(input("Enter integer: "))
print(isPalindrome(num))


## Recommended textbook solutions

#### Computer Organization and Design MIPS Edition: The Hardware/Software Interface

5th EditionISBN: 9780124077263 (5 more)David A. Patterson, John L. Hennessy
220 solutions

#### Introduction to Programming Using Python

1st EditionISBN: 9780132747189Y. Daniel Liang
773 solutions

#### Fundamentals of Database Systems

7th EditionISBN: 9780133970777 (1 more)Ramez Elmasri, Shamkant B. Navathe
687 solutions

#### Introduction to Algorithms

3rd EditionISBN: 9780262033848 (2 more)Charles E. Leiserson, Clifford Stein, Ronald L. Rivest, Thomas H. Cormen
726 solutions