Assigned: Wednesday, October 2
Due: Wednesday, October 9, 2013 by 11:55pm
You will write a program that allows the user to input a positive integer and your program will output if that integer is a palindrome. This will be done using a loop and 3 functions to test your understanding of functions that return values as well as your understanding of loops. You should not use lists or string manipulation in this program as we have not covered those topics yet.
Program Specifications
This program requires you to use:
Description
A number is a palidrome if its reversal is the same as itself. For example, 121 is a palidrome.
Your code needs to include 3 functions:
HINTS:
main() needs to call isPalindrome and isPalidrome needs to call reverse
Recall the in-class practice from 10/2 where we used % and // operators to extract individual digits from an integer - this will help you write the reverse function.
Comments in your code
Because I'm requiring you to write functions in this assignment, I'm adding additional mandatory comments. It is good practice to always describe your functions in terms of what they do, the input they take in and the output they produce.
Here's an example you'd use for a function that computes the circumference of a circle:
# This function computes the circumference of a circle. # Parameters: r, the radius of the circle. # Returns: the circumference of the circle. def area_of_circle(r): return 2 * math.pi * r
An example of possible dialog with the user might be (user input is in italics):
Example 1
Enter a positive integer: 12345 12345 is not palindrome.
Example 2
Enter a positive integer: 2345432 2345432 is a palindrome.Your code does not need to follow this exact script, but all the mentioned functionality should work as shown.
What to Do
Requirements
When I examine your program, it must satisfy the following requirements. The maximum point value for each requirement is shown in brackets.