palindrome is a number or a text phrase that reads the same backwards or forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads in a five-digit integer and determines whether it is a palindrome. (Hint: Use the division and modulus operators to separate the number into its individual digits.)

What will be an ideal response?

```
# Determines if a five-digit integer is a palindrome.

number = raw_input( "Please enter a five-digit integer: " )
number = int( number )

# isolate last digit
lastDigit = number % 10

# isolate fourth digit
number = number / 10
fourthDigit = number % 10

# skip middle digit
number = number / 100

# isolate second digit
secondDigit = number % 10

# isolate first digit
firstDigit = number / 10

# number is palindrome if first and last digits match and
# if second and fourth digits match
if ( firstDigit == lastDigit ) and ( secondDigit == fourthDigit ):
print "The number is a palindrome."
else:
print "The number is not a palindrome."
```
Please enter a five-digit integer: 61216
The number is a palindrome.
Please enter a five-digit integer: 12345
The number is not a palindrome.

Computer Science & Information Technology

You might also like to view...

Typically, ______ are used by a compiler to implement recursive methods.

a) linked-lists b) arrays c) stacks d) queues

Computer Science & Information Technology

A __________ attack exploits the characteristics of the algorithm to attempt to deduce a specific plaintext or to deduce the key being used.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology