Overview

In this week, you will break down a season of games to uncover patterns like analysts do.

New Skills

  • Use conditionals to label wins and losses
  • Filter data with multiple conditions
  • Search and group results
  • Sort games to find biggest wins and losses
  • Load and analyze season-style CSV data

Review

Here's a quick refresher on the skills you learned last week. You'll use all of these again this week!

Lists — A list stores multiple items in one variable. You can access each item by its position (index).

scores = [105, 98, 112, 88]
print(scores[0])  # prints 105

Loops — A for loop repeats code for every item in a list, so you don't have to write the same thing over and over.

for score in scores:
    print(score)

Conditions (if/else) — An if statement checks whether something is true or false and decides what to do next.

if score > 100:
    print("Great game!")
else:
    print("Room to improve.")

Loading a CSV file — A CSV file is a simple text file where data is separated by commas. You can load it into Python so your program can work with real data instead of typing everything by hand.

import csv

with open("games.csv", "r") as file:
    reader = csv.DictReader(file)
    for row in reader:
        print(row)

Discord

Make sure you have joined the course Discord so we can send you update and links.

>button: 💬 Join the Course Discord