1. Scrabbletm – File, Loop and Dictionary Practice
Write a program that reads a list of words and calculates the Scrabbletm point value of each word. If the word has 0 characters or 10 characters or more, assign a point value of 0. The words are read one per line from file
1030 Project 04 01 Words.txt
which is included with this specification. Convert lower case letters to upper case with a statement like
letter = character.upper()
and ignore all characters that aren’t letters. You can test if a character is a letter with
if letter.isalpha()
Point values are based on this table which can be conveniently implemented with a dictionary:
# points Letters 1 A, E, I, L, N, O, R, S, T, U 2 D, G 3 B, C, M, P 4 F, H, V, W, Y 5 K 8 J, X 10 Q, Z
An actual Scrabbletm board includes some squares that multiply the value of a letter or the value of an entire word. For this problem, ignore these squares. The output should be in a list with the word and its points, with the point total displayed at the end of the program. For example:
Word Points
CAT 3
DOG 5
FOX 13
HIPPO 12
PLATYPUS 15
Total 48
This problem is derived from The Python Workbook, by Ben Stephenson, page 66, exercise 137.
2. Letter Frequencies – File, Loop and Dictionary Practice
Write a program that reads sentences from file
1030 Project 04 02 Sentences.txt
(included with this specification) and calculates letter frequencies (total counts of how often each letter appears) for all sentences in the file. Print the original lines as you read them. Then, convert lower case letters to upper case and ignore all characters that aren’t letters. Frequency analysis is one approach to decrypting messages. The letters E and T are the most common letters in the English language, so a frequency analysis of a long message would likely show high counts for letters E and T.
After processing all lines in the input file, display on the screen and write to output file