1. Fill the missing pieces

Fill the ____ parts in the code below.

In [ ]:
words = ['PYTHON', 'JOHN', 'chEEse', 'hAm', 'DOE', '123']
upper_case_words = []

for ____ in words:
    if ____.isupper():
        ____.append(____)
In [ ]:
assert upper_case_words == ['PYTHON', 'JOHN', 'DOE']

2. Calculate the sum of dict values

Calculate the sum of the values in magic_dict by taking only into account numeric values (hint: see isinstance).

In [ ]:
magic_dict = dict(val1=44, val2='secret value', val3=55.0, val4=1)
In [ ]:
# Your implementation
sum_of_values =     
In [ ]:
assert sum_of_values == 100

3. Create a list of strings based on a list of numbers

The rules:

  • If the number is a multiple of five and odd, the string should be 'five odd'
  • If the number is a multiple of five and even, the string should be 'five even'
  • If the number is odd, the string is 'odd'
  • If the number is even, the string is 'even'
In [ ]:
numbers = [1, 3, 4, 6, 81, 80, 100, 95]
In [ ]:
# Your implementation
my_list = 
In [ ]:
assert my_list == ['odd', 'odd', 'even', 'even', 'odd', 'five even', 'five even', 'five odd']