print( count_vowels("") ) # {"a": 0, "e": 0, "i": 0, "o": 0, "u": 0,
# "A": 0, "E": 0, "I": 0, "O": 0, "U": 0}
print( count_vowels("banana") ) # {"a": 3, "e": 0, "i": 0, "o": 0, "u": 0,
# "A": 0, "E": 0, "I": 0, "O": 0, "U": 0}
print( count_vowels("Adriana") ) # {"a": 2, "e": 0, "i": 1, "o": 0, "u": 0,
# "A": 1, "E": 0, "I": 0, "O": 0, "U": 0}
print( count_vowels("Hello World!") ) # {"a": 0, "e": 1, "i": 0, "o": 2, "u": 0,
# "A": 0, "E": 0, "I": 0, "O": 0, "U": 0}
Module 9 Assignments
Programming Problems
Due date: Wednesday, October 29, 2025 at 9pm
Programming Problem 17
Write a Python function that does the following:
- Its name is
count_vowels
- It takes as argument a
string
- It iterates over the
string
(either with awhile
orfor
loop) counting how many lowercase and uppercase vowels thestring
has - It returns a dictionary with vowels are the keys, and integer counts as the values
Test cases:
Name the program vowel_counting.py
. Make sure that gradescope gives you the points for passing the test case.
Programming Problem 18
Write a Python function that does the following:
- Its name is
invert_dictionary
- It takes a single
dictionary
as a parameter - It returns a new dictionary with the original
dictionary
values mapped as keys, and its original keys mapped as lists of values
Test cases:
print( invert_dictionary({"a": 7, "b": 8}) ) # { 7: ["a"], 8: ["b"] }
print( invert_dictionary({"a": 2, "b": 2}) ) # { 2: ["a", "b"] }
print( invert_dictionary({}) ) # {}
Name the program inversion.py
. Make sure that gradescope gives you the points for passing the test case.