Reference no: EM132360816
Programming Problems:
1. a) Write a function called has_duplicates that takes a list and returns True if there is any element that appears more than once. It should not modify the original list.
b) From part (a) you have a function named has_duplicates that takes
a list as a parameter and returns True if there is any object that appears more than once__ in the list. Use a dictionary to write a faster, simpler version of has_duplicates.
2. Download the file "GA.txt" and save it into your Python34 directory.
a) Write a program that will process the text file (open ('GA.txt')) to calculate the number of occurrences of each letter of the alphabet contained in the file. You should convert the file to all lower case letters. (I removed punctuation for you!) Your program should display the results.
b) After you have calculated the number of occurrences, you should calculate the relative frequency of each letter, and display the results.
Save a copy of this program for yourself, and for homework, get the display to be in alphabetical order! You may have time to do it now,but probably not (typing errors waste time).
Hints: you may use the string methods:
s.lower() to convert a string to lower case s.strip() to remove spaces
Note: I already removed the punctuation and new lines , but for your information, the string class can remove all of that for you:
import string
s.strip(string.punctuation) removes any punctuation marks
s.strip(string.whitespace) removes tabs, new lines, etc.