Basics of Data Analytics
Made for 13-year-olds โ teach a computer to be your data helper!
By the end of this module, you will be able to:
Python is a programming language โ a way of giving instructions to a computer. It's one of the most popular languages in the world, and it's especially popular for data analytics.
| Task | Spreadsheet | Python |
|---|---|---|
| Small dataset (50 rows) | โ Easy | โ Easy |
| Huge dataset (1 million rows) | โ Slow, may crash | โ Fast |
| Repeating the same analysis | ๐ Click everything again | โ Run the same code |
| Making a chart | โ Quick | โ Also quick (with code) |
You don't need to install anything! We'll use a free online tool. Ask a parent or teacher to help you open Google Colab (colab.research.google.com) or Replit (replit.com) โ both are free and run Python in your browser.
The first thing every programmer learns is how to make the computer say hello:
print("Hello, World!")
print() tells the computer to show something on the screen. Whatever is inside the quotes gets printed.
A variable is like a labeled box where you store a value.
name = "Alex"
age = 13
favorite_sport = "soccer"
print(name)
print(age)
print(favorite_sport)
The = sign means "store this value in this box." It's not like math class โ it's an instruction!
a = 10
b = 3
print(a + b) # Addition
print(a - b) # Subtraction
print(a * b) # Multiplication
print(a / b) # Division
Anything after a # is a comment โ the computer ignores it. Comments are notes for humans!
age = 13, you're putting "13" into a bowl labeled "age."
Later, you can use that bowl in your recipe!
A list is a way to store many values in one variable. It's like a row in a spreadsheet!
ages = [12, 13, 13, 14, 13, 15, 12]
print(ages)
print(ages[0]) # First item (counting starts at 0!)
print(ages[2]) # Third item
print(len(ages)) # How many items
ages[0] is the first item, and ages[2] is the
third. This trips up almost every beginner โ you're not alone!
scores = [85, 92, 78, 95, 88]
print(sum(scores)) # Add them all up
print(len(scores)) # How many scores
print(sum(scores) / len(scores)) # Average!
You just calculated the average with one line of code โ the same thing you did by hand in Module 4!
pandas is a free Python library that makes working with data much easier. It's like a super-powered spreadsheet inside Python.
import pandas as pd
import means "bring in this tool." as pd gives it a short nickname so you don't have to type "pandas" every time.
pandas can read data from a CSV file (a common file type for data).
data = pd.read_csv("scores.csv")
print(data)
This loads the file into a DataFrame โ pandas' version of a spreadsheet table. It has rows and columns, just like Excel.
pandas has built-in commands to explore data quickly:
data.head() # Show first 5 rows
data.shape # How many rows and columns
data.describe() # Quick statistics (average, min, max, etc.)
data.mean() # Average of each column
data.max() # Biggest value in each column
data.min() # Smallest value in each column
data.describe() is like pressing a
"give me a summary" button. Instead of doing all the math by hand, pandas does it for you in
one line!
Imagine you have a file called class_scores.csv with these columns: Name, Math, Science, English.
import pandas as pd
data = pd.read_csv("class_scores.csv")
print(data.head())
print(data.mean())
With just a few lines, you loaded a file, looked at the first rows, and found the average of every subject!
Your Mission: Use Python to explore a small dataset!
Ask a parent or teacher to help you open Google Colab or Replit. Create a new notebook.
Copy and run each of these in a new cell. Write down what happens!
# 1. Your first list
scores = [85, 92, 78, 95, 88, 70, 91]
print(scores)
# 2. Math with Python
print("The average is:", sum(scores) / len(scores))
print("The highest score is:", max(scores))
print("The lowest score is:", min(scores))
print("The total is:", sum(scores))
# 3. Your own list
# Make a list of your last 5 test scores (or use made-up ones)
my_scores = [___, ___, ___, ___, ___]
print("My average:", sum(my_scores) / len(my_scores))
Try changing the numbers. What happens if you add more scores? What if you set one score to 100? What if you put a really low score like 0?
In your notebook or on paper, write:
Submit: A screenshot or copy of your Python code + your write-up.
print("Hello") do?ages = [12, 13, 14], what is ages[0]?import pandas as pd do?data.mean() calculate?#) that the computer ignores.