The guide for 7.2.9 Top Movies explains how to use Python to store, access, and modify data. This specific exercise is part of the CodeHS AP Computer Science Principles
curriculum and focuses on the fundamental programming concept of mutability (changing items within a list). 🎬 Exercise Objective
The goal is to create a list of four favorite movies, print the first one, and then replace that first movie with a new title to see how the list updates in memory. 🛠️ Step-by-Step Implementation 1. Initialize the List Create a variable named and assign it a list containing four strings. # Create a list of 4 favorite movies The Matrix Interstellar Use code with caution. Copied to clipboard 2. Access the First Element In Python, lists use zero-based indexing . This means the first item is at position # Print the first movie in the list print(movies[ Use code with caution. Copied to clipboard 3. Modify the List
To replace an item, assign a new value to the specific index. # Change the first movie to "Star Wars" Use code with caution. Copied to clipboard 4. Verify the Change
Print the first element again to confirm the update was successful. # Print the new first movie print(movies[ Use code with caution. Copied to clipboard 💡 Key Concepts to Remember Zero-Indexing : Always start counting from 0. is the 1st item, is the 2nd. Square Brackets to define the list and to access specific indices. Mutability 7.2.9 Top Movies
: Lists in Python are "mutable," meaning you can change their contents after they are created without making a whole new list. : Ensure movie titles are wrapped in quotes (e.g., "Star Wars" ) so Python recognizes them as text. ✅ Completed Code Solution # 1. Create the list The Matrix Interstellar # 2. Print the initial first element print(movies[ # 3. Modify the first element # 4. Print the updated first element print(movies[ Use code with caution. Copied to clipboard If you are working on a different exercise in the curriculum or need help with list methods
, let me know! Would you like to see how to add more movies to this list automatically?
. In this exercise, students practice creating and modifying lists by managing a collection of their favorite films. Feature Breakdown: CodeHS 7.2.9 Top Movies This exercise is designed to teach the fundamentals of list indexing mutability —the ability to change data after it has been created. 1. Define the List
The first step is to create a variable containing a list of exactly four movie titles. # Create a list of 4 favorite movies The Matrix Interstellar Back to the Future Use code with caution. Copied to clipboard 2. Access the First Element In Python, lists use zero-based indexing , meaning the very first item is at position # Print the 0th element (the first movie) print(movies[ Use code with caution. Copied to clipboard 3. Update the Data The guide for 7
A key objective of the 7.2.9 exercise is to change the first movie to "Star Wars" and verify the update by printing it again. # Set the 0th element to "Star Wars" # Print the 0th element again to show the change print(movies[ Use code with caution. Copied to clipboard Why It Matters
While the task is simple, it builds the foundation for more complex data management in computer science. Developers use these same principles to manage everything from user profiles to real-world movie databases like those found on more advanced
Python list exercise, such as sorting or filtering movies by their IMDb rating
The action genre is crowded with CGI spectacles, but the 7.2.9 picks prioritize smart choreography and tension over exploding planets. Action & Thriller: The Adrenaline Keepers The action
Why it rates 7.2.9: The archetypal 7.2.9 movie. It’s too violent for the mainstream crowd but too stylish for pure exploitation fans. With a 93% on Rotten Tomatoes but polarizing audience scores, Drive sits perfectly in the 7.2 range due to its minimalist dialogue and maximalist neon violence.
SELECT m.title, g.genre, m.rating
FROM movies m
JOIN movie_genres mg ON m.id = mg.movie_id
JOIN genres g ON mg.genre_id = g.id
WHERE g.genre = 'Action'
ORDER BY m.rating DESC
LIMIT 5;
Why it rates 7.2.9: Despite a confusing marketing campaign ("Live. Die. Repeat."), Tom Cruise and Emily Blunt’s time-loop masterpiece has aged like fine wine. The 7.2.9 score acknowledges its clever narrative structure and brutal action. It’s not a philosophical mind-bender like Inception, but as a high-concept action-sci-fi, it scores a perfect 9.
SELECT title, rating, year
FROM movies
WHERE year >= 2010
ORDER BY rating DESC
LIMIT 5;
| title | release_year | rating | votes | |---------------------------|--------------|--------|---------| | The Shawshank Redemption | 1994 | 9.3 | 2,800,000 | | The Godfather | 1972 | 9.2 | 1,900,000 | | The Dark Knight | 2008 | 9.0 | 2,700,000 | | ... | ... | ... | ... |