+ 2
help
2. Write a function that computes the sum of the digits in an integer. Use the following header: def sumDigits(number) (Hint: Use the % operator to extract digits, and the // operator to remove the extracted digit.) 3. Write the following function to display an integer in reverse order: def reverse(number) (For example, reverse(3456) displays 6543.) 4. Write the functions with the following headers: def reverse(number) # return the reversal of an integer def isPalindrome(number) # return true if number is palindrome (A number is palindrome if its reversal is the same as itself.)
1 Answer
0
integer=123321
def sumDigits(number):
sums=0
for i in str(number):
sums=sums+int(i)
return sums
def reverse(number):
num=str(number)[::-1]
return num
def isPalindrome(number):
num=str(number)[::-1]
if number==int(num):
return True
else:
return False
print(sumDigits(integer))
print(reverse(integer))
print(isPalindrome(integer))