Introduction to Computer Science/5.7 Formative Activity - "Top 5 List".

5.7 Formative Activity - "Top 5 List".

🎯 Activity Goals
  • Apply your knowledge of list creation, indexing, and methods.
  • Use a for loop to display the items in a list.
  • Write a complete, multi-step program that manipulates a list.

Practice Task: The "Top 5 List" Program

It's time to combine all the list manipulation skills we've learned this week. For this activity, you will create and modify a list of your "Top 5" of something (e.g., movies, video games, songs, foods) and then display the final, sorted list.

Your Task

Write a Python script that performs the following actions in order:

  1. Create a List: Create a list containing your personal "Top 5" of any category you like.
  2. Print the Original: Print the original list.
  3. Make a Change: Replace the item at index 2 with a new item.
  4. Add an Item: Use .append() to add one more item to the end of the list.
  5. Remove an Item: Use del to remove the very first item (at index 0).
  6. Sort the List: Use .sort() to sort the final list alphabetically.
  7. Display the Final List: Use a for loop to print each of the final items on its own line, preceded by a rank number.

Example Output:

Original Top 5 Video Games: ['Elden Ring', 'Zelda', 'StarCraft', 'Hades', 'Factorio']

Final Ranking:
1. Elden Ring
2. Factorio
3. Hades
4. Stardew Valley


Knowledge Check: Order of Operations

The order in which you call these methods matters! Try this quick interactive exercise to see if you can place the commands in the correct sequence.

Note

** **

How to Submit (Code Showcase)

This is a formative activity to share with your peers.

  1. Step 1: Post Your Code. Navigate to the "Unit 5 Code Showcase" Discussion Forum. Create a new thread and paste your complete, working Python code into the body of the post.
  2. Step 2: Review and Comment. Read through the solutions from at least two of your classmates and leave a positive, constructive reply on their threads.

Interactive Sandbox

Use this space to practice writing code and complete the "Your Turn" activities above.

Python 3Initializing...
Loading code editor...
Program output will appear here...