or HW 3, you should use a main() function to control the program you write. You should also use other functions as appropriate (or as specified).
- String Manipulation – Write a program that asks the user to enter a word or phrase and then displays the word or phrase with all occurrences of the letter “r” removed. Example: “Park the car in Harvard Yard” becomes “Pak the ca in Havad Yad.”
- Special Number – Write a program that can find a four-digit number that has the four digits reversed when multiplied by four. For example, rstu * 4 = utsr. The program should report the number to the user.
- Check for Palindromes – Write a program that prompts the user to enter a word or phrase. Then check to see if the word is a palindrome. A palindrome reads the same forward and backward ignoring punctuation and spaces. For example, “racecar,” “Madam, I’m Adam,” and “Anna.” You can use these palindrome sentences (Links to an external site.) as a source for checking if your program works.
- Calculate the Factorial – The factorial of a positive integer is the product 1 * 2 * 3 * 4 … * n where n represents the positive integer. Write a program that asks the user to enter a positive integer and calculates the factorial. Use a main() function to control the program flow. Write a function to get an integer from the user and verify the user entered a positive integer value. Write a different function to calculate the factorial for a number.
- [REMOVED FROM PY HW 3 BECAUSE WE DID NOT COVER FILE I/O IN CLASS YET] Crayon Colors – The file “Colors.txt Download Colors.txt” contains the names of 123 crayon colors with one color per line. Write a program that asks the user to enter a letter of the alphabet and then displays all the colors that start with that letter. Write three separate functions: one to get the user input, one to read the colors.txt file into a list, one to build a list with the colors that start with the letter, and one to display the output.
- Anagram Checker – Write a program that asks the user to enter two words or phrases. Then check to see if the words or phrases are anagrams of each other. Two words or phrases are anagrams of each other if they use the same letter with the same frequency in both phrases. Examples include night & thing, inch & chin, elbow & below, little big man & labeling mitt, another day & a hearty nod.
- [REMOVED FROM PY HW 3 BECAUSE WE DID NOT COVER FILE I/O IN CLASS YET]Sorting States List – The data file “States.txt Download States.txt” contains the 50 US states in order they joined the union with one state per line. Write a program to read the file contents into a list. Then sort the list based on the number of consonants contained in the state name in ascending order. HINT: You will need to write a function to count the number of consonants in a word.
- Reading Numbers – Write a program that asks the user to enter a number with 27 digits or less. The convert that number into a set of three-digit numbers and associated place values. Display the results to the user. The following table shows the output if the user entered 293452000450041006950254586.