Introduction
What's the most unbelievable thing a soccer player has ever done?
- Lionel Messi scoring 5 goals in a single Champions League match
- Cristiano Ronaldo scoring 17 goals in one Champions League season
- Abby Wambach becoming the all-time international goals leader with 184 goals
- Marta scoring 17 World Cup goals, the most in history
What we're building
By the end of this project, you will:
- Run your first real Python program and see output on screen
- Learn how to store data in variables to organize information
- Display formatted statistics using print statements
- Create a "stat card" showcasing a legendary sports achievement
Why this matters
Every sports broadcast, website, and app displays statistics. The graphics you see on ESPN, the stat overlays during games, the player cards in video games — they're all created by code. Today, you'll write the same kind of code that powers those displays.
Part 1: Quick Start
>button: Download the Starter PackOpen the starter pack in Cursor by going to File > Open Folder and selecting the folder you downloaded from your computer.
You should see a file called amazing_achievement.py. Open it, this is where we will be writing our code.
Writing the code
It's important to type in code manually at first, instead of copying and pasting. This will help your brain learn the code and remember it later. It's similar to playing scales on an instrument. You don't learn to play an instrument by copying someone else's notes, you learn by playing the notes yourself.
print("The most amazing statistical achievement in soccer history:")
print("Lionel Messi scored 5 goals in a single Champions League match.")
print("Date: March 7, 2012")
Running the code
Save the file (Cmd + S or Ctrl + S)
You can run the code by hitting the "play" icon in the top right of the screen. Or, you can open the terminal (Cmd + ~ or Ctrl + ~) and type python amazing_achievement.py and press enter.
If everything is working correctly, you should see the output in the terminal:
The most amazing statistical achievement in soccer history:
Lionel Messi scored 5 goals in a single Champions League match.
Date: March 7, 2012
If you got an error message, that's OK! You have a helpful AI assistant to help you fix it. Open your AI agent in Cursor (Cmd + L or Ctrl + L) and ask it to help you fix the error.
Congratulations! You just ran (and maybe debugged) your first Python program. The text you see in the terminal is the output of your code.
Part 2: Milestones
We're going to build on the code we wrote in the quick start to make it more impressive.
Milestone 1: Print a Single Stat
For this milestone, we're going to print a single stat about the achievement.
print("Lionel Messi scored 5 goals in a single match!")
Now, run your code the same way you did in the quick start.
If everything is working correctly, you should see the output in the terminal:
Lionel Messi scored 5 goals in a single match!
Now, let's make it more impressive.
Milestone 2: Store stats in variables
In most real-world programs, you'll want to store data in variables so you can reuse it later.
Python lets us store a variety of different types of data in variables. We're going to focus on numbers and text for now.
Check out the code below:
player = "Lionel Messi"
goals = 5
date = "March 7, 2012"
print(player)
print(goals)
print(date)
Do you see the name = value syntax? This is how we store data in variables. Notice that some of the values are surrounded by quotes. That means they are text (strings), not numbers. Numbers don't need quotes.
We can print the variables by just putting the variable name in the print() function.
Now, run your code the same way you did in the quick start.
Lionel Messi
5
March 7, 2012
Strings are pieces of text. You can combine strings with + to build a longer sentence:
first = "Lionel"
last = "Messi"
print(first + " " + last)
That works, but there is a cleaner way to mix text and variables using f-strings.
Now we're ready to move on to the next milestone.
Milestone 3: Combine text and variables
Now, let's combine text and variables to create a more impressive output.
Check out the code below. An f-string is a string that starts with f and uses {} to insert variable values.
player = "Lionel Messi"
goals = 5
date = "March 7, 2012"
team = "FC Barcelona"
print(f"{player} scored {goals} goals in a single match!")
print(f"He played for {team}.")
print(f"This happened on {date}.")
Now, run your code the same way you did in the quick start.
If everything is working correctly, you should see the output in the terminal:
Lionel Messi scored 5 goals in a single match!
He played for FC Barcelona.
This happened on March 7, 2012.
Move on to the next milestone.
Milestone 4: Create a Stat Card Display
Now we're going to get really fancy and create a stat card like you'd see in a sports broadcast (well at least one you might see in the 1980s...).
Check out the code below. It's a bit more complex, but don't worry, we'll break it down step by step.
player = "Lionel Messi"
team = "FC Barcelona"
opponent = "Bayer Leverkusen"
# The Achievement
goals = 5
shots = 10
shots_on_target = 7
date = "March 7, 2012"
# Create the stat card
print("╔════════════════════════════════════════╗")
print(" THE GREATEST SCORING MATCH")
print("╚════════════════════════════════════════╝")
print()
print(f" Player: {player}")
print(f" Team: {team}")
print(f" vs: {opponent}")
print()
print(" ─────────────────────────────────────")
print(f" GOALS: {goals}")
print(f" Shots: {shots}")
print(f" Shots on Target: {shots_on_target}")
print(" ─────────────────────────────────────")
print()
print(f" Date: {date}")
print()
print(" \"They say records are made to be broken.")
print(" This one never will be.\"")
Expected Output:
╔════════════════════════════════════════╗
THE GREATEST SCORING GAME EVER
╚════════════════════════════════════════╝
Player: Lionel Messi
Team: FC Barcelona
vs: Bayer Leverkusen
─────────────────────────────────────
GOALS: 5
Shots: 10
Shots on Target: 7
─────────────────────────────────────
Date: March 7, 2012
"They say records are made to be broken.
This one never will be."
Build the card in small steps:
- Start with the player, team, opponent, and achievement variables.
- Add the top border and title lines, then a blank line with
print()to create spacing. - Print the player, team, and opponent lines using f-strings.
- Add the stat section with a divider line, then print goals, shots, and shots on target.
- Finish with the date and the quote.
Wow, congratulations! You just built your first real Python program. You should be proud of yourself.
If you finished early or would like additional challenges, there are a few bonus exercises below.
Bonus Exercises: Push It Further with Your Agent
Use your AI assistant to explore what's possible with the same building blocks you just learned (variables, print statements, and f-strings). Open the AI agent in Cursor with Cmd + L (or Ctrl + L), then type your prompts in the chat panel on the right. Each idea below is meant to be done by prompting your agent and experimenting.
Bonus 1: Make an HTML Stat Page
Goal: Create a new file called amazing_achievement_html.py that writes an HTML page with your stats and some simple styles.
Try prompts like:
- "Write Python code that creates a string of HTML for my stat card, then saves it to a file called
amazing_achievement.html." - "Add basic CSS styles to the HTML so it looks like a simple sports card."
- "Update my Python file to open the HTML file in my browser after saving."
Bonus 2: Build a Multi-Stat Card
Goal: Print two or three achievements in a row, each with its own variables and output.
Try prompts like:
- "Help me duplicate my stat card for another athlete with new variables."
- "Make a function called
print_stat_card(...)so I can reuse it."
Bonus 3: Make It Interactive
Goal: Let the user type in the athlete and stats, then generate the output.
Try prompts like:
- "Show me how to use
input()to ask for the player's name, goals, and date." - "Use the inputs to build the same stat card output."
Bonus 4: Add More Formatting
Goal: Experiment with output style and layout.
Try prompts like:
- "Make the stat card wider and center the title."
- "Add a second divider line and align all the numbers."
- "Change the quote at the bottom and add a source line."
Bonus 5: Create a New Format
Goal: Print the same information in a totally different layout.
Try prompts like:
- "Turn the stat card into a scoreboard-style output."
- "Print the stats as a table with columns."
- "Make a 'trading card' layout with a short bio section."