Skip to the content.

3.2 Hacks!

3.2 Popcorn and Homework Hacks

Popcorn Hack 1

# Define a dictionary with movies  categorized by genre
movies = {
    "Romance": ["The Notebook", "10 Things I Hate About You", "To All The Boys I've Loved Before"],
    "Comedy": ["Superbad", "Grown Ups", "White Chicks"],
    "Action": ["The Avengers", "Deadpool", "John Wick"],
    "Horror": ["Annabelle", "Scream", "IT"]
}

# Function to print the list of movies by genre
def print_movies(movies):
    for category, items in movies.items():
        print(f"\n{category}:")
        for item in items:
            print(f" - {item}")

# Call the function to display movies
print_movies(movies)

Popcorn Hack 2

sprints = {
    'Sprint1': ['Snake Game', 'Cookie Clicker', 'Mario'],
    'Sprint2': ['Big Ideas 3.10']
}

print(sprints['Sprint1'])
if "Snake Game" in sprints['Sprint1']:
    print(True) 
else:
    print(False)

# Output:
# ['Snake Game', 'Cookie Clicker', 'Mario']
# True

Popcorn Hack 3

# List of songs in an album
album = [
    {
        "title": "Young Girls",
        "artist": "Bruno Mars",
        "duration": "3:48",
    },
    {
        "title": "Locked out of Heaven",
        "artist": "Bruno Mars",
        "duration": "3:53",
    },
    {
        "title": "Gorilla",
        "artist": "Bruno Mars",
        "duration": "4:04",
    }
    {
        "title": "Treasure",
        "artist": "Bruno Mars",
        "duration": "2:58",
    },
    {
        "title": "Moonshine",
        "artist": "Bruno Mars",
        "duration": "3:48",
    },
    {
        "title": "When I Was Your Man",
        "artist": "Bruno Mars",
        "duration": "3:33",
    },
    {
        "title": "Natalie",
        "artist": "Bruno Mars",
        "duration": "3:45",
    },
    {
        "title": "Show Me",
        "artist": "Bruno Mars",
        "duration": "3:27",
    },
    {
        "title": "Money Make Her Smile",
        "artist": "Bruno Mars",
        "duration": "3:23",
    },
    {
        "title": "If I Knew",
        "artist": "Bruno Mars",
        "duration": "2:12",
    },
]

# Display information about each song in the album
for song in album:
    print(f"Title: {song['title']}")
    print(f"Artist: {song['artist']}")
    print(f"Duration: {song['duration']}")
    print("\n")

Homework Hack

%%python
romance = ["The Notebook", "10 Things I Hate About You", "To All The Boys I've Loved Before"]
print(romance)

comedy = ["Superbad", "Grown Ups", "White Chicks"]
print(comedy)

action = ["The Avengers", "Deadpool", "John Wick"]
print(action)

horror = ["Annabelle", "Scream", "IT"]
print(horror)