Skip to the content.

3.2 Popcorn Hacks

My answers for the popcorn hacks

CSP Big Idea 3.2

Popcorn Hack #1

Create a list named movies containing your four favorite movies. Write Python code to replace the second movie with a new movie, add another movie to the list, and display the updated list.

movies = ["lion king", "finding nemo", "inside out", "minecraft movie"]
print(movies)

movies[2] = "inside out 2"   # Changing element

print(movies) 

['lion king', 'finding nemo', 'inside out', 'minecraft movie']
['lion king', 'finding nemo', 'inside out 2', 'minecraft movie']

Popcorn Hack #2

Given the list ages = [15, 20, 34, 16, 18, 21, 14, 19], write Python code to create a new list containing only ages that are eligible for voting (18 or older).

ages = [15, 20, 34, 16, 18, 21, 14, 19]
voting_ages= [num for num in ages if num >= 18]
print(voting_ages)


[20, 34, 18, 21, 19]