Exercises 1, 2, and 3 are embedded in the Lists page so you must go there and find them if you did not do them while reading it.
Write a program to open the file romeo.txt found in your Ex08 folder that reads it line by line. For each line, split the line into a list of words using the split function.
For each word, check to see if the word is already in a list. If the word is not in the list, add it to the list.
When the program completes, sort and print the resulting words in alphabetical order.
Enter file: romeo.txt['Arise', 'But', 'It', 'Juliet', 'Who', 'already','and', 'breaks', 'east', 'envious', 'fair', 'grief','is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft','sun', 'the', 'through', 'what', 'window','with', 'yonder']Submit the program file with the name '8-4.py' once the program is thoroughly tested.
Write a program to read through the mail box data and when you find line that starts with "From", you will split the line into words using the split function. We are interested in who sent the message, which is the second word on the From line.
From [email protected] Sat Jan 5 09:14:16 2008You will parse the From line and print out the second word for each From line, then you will also count the number of From (not From:) lines and print out a count at the end.
This is a good sample output with a few lines removed:
python fromcount.pyEnter a file name: mbox-short.txt[email protected][email protected][email protected][...some output removed...][email protected][email protected][email protected][email protected]There were 27 lines in the file with From as the first wordSubmit the program file with the name '8-5.py' once the program is thoroughly tested.
Rewrite the program that prompts the user for a list of numbers and prints out the maximum and minimum of the numbers at the end when the user enters "done". Write the program to store the numbers the user enters in a list and use the max() and min() functions to compute the maximum and minimum numbers after the loop completes.
Enter a number: 6Enter a number: 2Enter a number: 9Enter a number: 3Enter a number: 5Enter a number: doneMaximum: 9.0Minimum: 2.0Submit the program file with the name '8-6.py' once the program is thoroughly tested.
Email addresses above are visible in the downloaded version of the book. They are hidden here to protect the addresses from discovery by spam bots.