python coding exercise

Part 1:

(1) Write a Python program to remove duplicates from a dictionary.

(2) Suppose we have a dictionary called grades containing exam grades for a course. Keys are student names, and values are grades (integers). Write a Python function that produces a list of all students who received a grade above 90.

(3) Write a Python function to count the number of lines in a text file.

(4) Write a python function to find the longest words in a text file.

Note: for both (3) and (4), a filename needs to be passed to the corresponding function in order to get the output.

(5) Count how many of each vowel (a, e, i, o, u) there are in a text string, and print the count for each vowel with a single formatted string. Remember that vowels can be both lower and uppercase

Part 2:

NOTE: two files are attached to continue this part:


(1) Write a Python function that takes the name of a text file as input and prints the number of occurences of every word in the file. Your function should be case-insensitive, i.e., “Hello” and “hello” are treated as the same word. You should ignore words of length 2 or less. Test your function on the attached file “Frankenstein.txt”. (2 Points)

(2) The file “bloodtype. txt” (see the attachment) records blood-types of patients (A, B, AB, or O) at a clinic. Write a function bldcount() that reads the file and reports (i.e., prints) how many patients there are in each bloodtype. (1 Point)

Expected output:

>>> bldcount(‘bloodtype.txt’)

There are 15 patients of blood type A.

There is 1 patient of blood type B.

There are 13 patients of blood type AB.

There are 15 patients of blood type O.