5.4.3. Practice: Looping through lists and dictionaries#

Try out these coding problems to practice looping, lists, and dictionaries

Make a loop that displays “Are you awake yet?” 5 times

# TODO: enter your code here

Make a list of names (at least three), and save it in a variable called names

# TODO: enter your code here

Now loop over each of those names, and for each name display “[name] is awesome!”

# TODO: enter your code here

Now, do the same thing as before, but for each name, first make a string that has “[name] is awesome!” and save it in a variable, then use the .upper() function on the string to make it all uppercase and save it into a variable, then display the final string.

# TODO: enter your code here

Now, we are going to make a dictionary with information on a photo

photo_1_info = {
    "width": 800,
    "height": 600,
    "location": "that one mountain",
    "device": "iPhone 6"
}

Select and display the width of the photo

# TODO: enter your code here

Select and display the location of the photo

# TODO: enter your code here

Now we are going to make a list of photo info for you to go through

photo_info_list = [
    {
        "width": 800,
        "height": 600,
        "location": "that one mountain",
        "device": "iPhone 6"
    },
    {
        "width": 800,
        "height": 600,
        "location": "on the lake",
        "device": "iPhone 5"
    },
    {
        "width": 1600,
        "height": 800,
        "location": "The underground mines",
        "device": "Nokia 3310"
    }
]

Now, make a for loop to go through each set of phone info in photo_info_list, and for each one, use print commands to display the width, height, location, and device

# TODO: enter your code here