$29
Learning objectives:
Use Python strings and lists.
Use Python indexing and slicing facilities.
Show each function to an instructor as you complete it. Switch driver and navigator after each function.
1. Name switching.
Ask the user to enter a person's name in first-last order, and display the name in last-comma-first order. For example, if the user enters the string Thomas Jefferson, the output should be Jefferson, Thomas. Call the function nameReverse().
2. Splitting a domain name.
Ask the user to enter a three-part internet domain name and print the company name only. For example, if the user enters the string www.Amazon.com, the output should be Amazon. Call the function companyName().
3. Slice and dice.
Write a function, initials(), to ask the user to enter the names of the students in a class. The function should first ask how many names will be input. Then it should ask for the first name and last name of student 1, the name of student 2, the name of student 3, etc. For each student, it should determine the student’s initials and output these initials. Sample input messages and output follows. User input is italicized.
Enter the first name of student 1: Tradd
Enter Tradd’s last name: Stalvey
Tradd’s initials are TS.
4. Slice and dice 2.
Write a function, names(), to ask the user to enter a list of names, first and last only, separated by commas. (NOTE: that's a list in the normal sense, not in the Python sense.) For each name, the function should output the initials. Sample input and output follows. User input is italicized.
Enter people's names, separated by commas: Randall Alexander, Tony Leclerc, RoxAnn Stalvey, Walter Pharr
The initials are RA TL RS WP
5. Every third.
Write a function, thirds(), that first asks how many sentences will be input. The function should output every third character of each sentence, beginning with the third character. For example, if the user enters The quick brown fox jumps over the lazy dog, the output should be eukrnojporhlyo. Blanks and punctuation count as characters. For the string First one!!! the output should be r e! Do not allow extra blanks within your output.
6. Word count.
Do Exercise 9, p. 163, that counts the words in a sentence. Call the function wordCount(). For example, if the user enters the sentence The quick brown fox jumps over the lazy dog, the output should be 9. Use a loop to allow more than one sentence to be processed.
7. Word average.
Do Exercise 10, p. 163, that averages length of the words in a sentence. Call the function wordAverage(). For example, if the user enters the sentence The quick brown fox jumps over the lazy dog, the output should be 3.88888888889. Use a loop to allow more than one sentence to be processed.
8. Pig Latin.
Write a function, pigLatin(), that reads in a sentence and converts (and stores) it to a simplified form of pig Latin in which the first letter of each word is moved to the end of the word and is then followed by the letters “ay.” You may assume that all words in the input sentence are separated by spaces and there is no punctuation, numerals, etc. appearing in the sentence. The output should be the new sentence in all lower case regardless of the original typed string.
Give peace a CHANCE -- ivegay eacepay aay hancecay
Upload the files to both student accounts (don't forget to submit).
Delete any files that you have put on the desktop. Empty the trash. Log off the computer.