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...

How are the Linux process scheduler’s run queues similar to multilevel feedback queues (see Section 8.7.6,Multilevel Feedback Queues)?

What will be an ideal response?

Computer Science & Information Technology

One of the most common methods for storing graphics data is in the form of a bitmap image-an image made up of a grid of small dots, called ____________________, that are colored appropriately to represent an image.

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

Computer Science & Information Technology

This is the first step in the systems design phase.

A. analyze the data B. examine hardware requirements C. design alternative systems D. select the best system

Computer Science & Information Technology

Which of the installation method requires an automation script?

a. Restore/Refresh b. Multiboot c. Parted Installation d. In-place Upgrade e. Unattended Installation

Computer Science & Information Technology