Python Data Project
Step-by-Step Beginner Guide
Student Performance Analysis & Score Prediction
6 Steps VS Code 3 Charts ML Model
Follow one by one Run on your computer Visualize your data Predict exam scores
What You Will Learn
✓ Create a CSV dataset and load it with pandas
✓ Check and fix missing values and duplicate rows
✓ Build 3 charts: scatter plot, bar chart, and heatmap
✓ Train a Linear Regression model to predict scores
✓ Upload your finished project to GitHub
Tools You Need
Tool Purpose How to Get
Python 3.x Programming language [Link]/downloads
VS Code Code editor [Link]
Python Extension Run Python in VS Code VS Code Extensions tab
pip packages pandas, matplotlib, etc. Run: pip install ... (Step 1)
GitHub account Upload & share your project [Link] (free)
Tip: Open VS Code, press Ctrl+` to open the Terminal. All commands run there.
1 Setup — Create Project Folder & Install Libraries
Step 1a — Create your project folder
Open your Terminal in VS Code (Ctrl + `) and run these commands:
mkdir student-project
cd student-project
code .
Note: The last command code . opens VS Code inside your new folder.
Step 1b — Install required libraries
In the VS Code Terminal, run this one command:
pip install pandas matplotlib seaborn scikit-learn
Step 1c — Create the dataset file
In VS Code, create a new file called [Link] and paste this inside:
student_id,gender,study_hours,attendance,previous_score,final_score
1,Male,2,65,55,60
2,Female,4,80,70,78
3,Male,1,50,40,45
4,Female,5,90,85,88
5,Male,3,75,65,70
6,Female,6,95,90,92
7,Male,2,60,50,58
8,Female,4,85,72,80
9,Male,3,70,60,68
10,Female,5,88,82,86
11,Male,1,45,38,42
12,Female,6,96,91,94
13,Male,2,67,57,62
14,Female,4,82,74,79
15,Male,3,73,63,69
What each column means:
Column Meaning
student_id Unique ID number for each student
gender Male or Female
study_hours Hours studied per day
attendance Attendance percentage (0-100)
previous_score Score in the last exam
final_score Final exam score (we will predict this!)
Tip: Save every file with Ctrl+S before running it.
2 Load & Inspect Your Data
Create a new file called [Link] in your project folder. Add the code below and run it with the green
Play button or press F5.
import pandas as pd
# Load the dataset
df = pd.read_csv('[Link]')
# Show first 5 rows
print('=== First 5 Rows ===')
print([Link]())
# Show column info
print('\n=== Dataset Info ===')
print([Link]())
# Show basic statistics
print('\n=== Summary Statistics ===')
print([Link]())
What the output means:
Function What It Shows
[Link]() First 5 rows of your data
[Link]() Column names, data types, and if any values are missing
[Link]() Average, min, max, and standard deviation for each number column
Tip: df is short for DataFrame. Think of it as a spreadsheet table inside Python.
Note: Expected output: You should see a table with 15 rows and 6 columns. No errors means your
file path is correct!
3 Clean Your Data
Real-world data is messy. We need to handle missing values and remove duplicates before we can
analyse anything. Add this to your [Link] file:
# Check for missing values
print('Missing values in each column:')
print([Link]().sum())
# Fill missing numbers with the average of that column
num_cols = ['study_hours', 'attendance', 'previous_score', 'final_score']
for col in num_cols:
df[col] = df[col].fillna(df[col].mean())
# Remove any duplicate rows
df = df.drop_duplicates()
print('\nCleaning done!')
print('Total rows after cleaning:', len(df))
print('Missing values after cleaning:')
print([Link]().sum())
Why do we do this?
Problem Solution Why It Matters
Missing value (empty cell) Fill with column average Keeps all rows, no data lost
Duplicate rows drop_duplicates() Prevents wrong calculations
Wrong data type Use astype() to convert Math only works on numbers
Tip: isnull().sum() counts empty cells per column. If you see all zeros after cleaning, you are done!
4 Explore Data with 3 Charts (EDA)
EDA means Exploratory Data Analysis — looking at the data visually to find patterns. Add each chart
to your [Link] file and run.
Chart 1 — Study Hours vs Final Score (Scatter Plot)
import [Link] as plt
[Link](figsize=(8, 5))
[Link](df['study_hours'], df['final_score'],
color='purple', s=80, alpha=0.7)
[Link]('Study Hours Per Day')
[Link]('Final Score')
[Link]('Study Hours vs Final Score')
[Link](True, alpha=0.3)
plt.tight_layout()
[Link]('chart1_study_hours.png') # saves image to your folder
[Link]()
Chart 2 — Average Score by Gender (Bar Chart)
gender_avg = [Link]('gender')['final_score'].mean()
[Link](figsize=(6, 4))
gender_avg.plot(kind='bar', color=['#1E88E5', '#F4511E'], edgecolor='white')
[Link]('Gender')
[Link]('Average Final Score')
[Link]('Average Score by Gender')
[Link](rotation=0)
plt.tight_layout()
[Link]('chart2_gender.png')
[Link]()
Chart 3 — Correlation Heatmap
import seaborn as sns
[Link](figsize=(8, 5))
[Link](df[num_cols].corr(), annot=True, cmap='Blues', fmt='.2f')
[Link]('Correlation Heatmap')
plt.tight_layout()
[Link]('chart3_heatmap.png')
[Link]()
Tip: In the heatmap, a value close to 1.0 means two columns increase together. Look for the strong
link between previous_score and final_score!
5 Build a Machine Learning Model
We will train a Linear Regression model. Give it study hours, attendance, and previous score — it will
predict the final score.
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from [Link] import mean_squared_error, r2_score
# X = input features, y = what we want to predict
X = df[['study_hours', 'attendance', 'previous_score']]
y = df['final_score']
# Split into 80% training data and 20% testing data
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42)
# Create and train the model
model = LinearRegression()
[Link](X_train, y_train)
# Test the model
y_pred = [Link](X_test)
print('R2 Score :', round(r2_score(y_test, y_pred), 3))
print('MSE :', round(mean_squared_error(y_test, y_pred), 3))
# Predict score for a brand new student
import pandas as pd
new_student = [Link]({
'study_hours' : [4],
'attendance' : [85],
'previous_score' : [75]
})
predicted = [Link](new_student)
print('\nPredicted final score:', round(predicted[0], 2))
Key terms explained:
Term Simple Meaning
Features (X) The input data we use to make a prediction
Target (y) The value we want to predict (final_score)
Train split 80% Data the model learns from
Test split 20% Data used to check if the model is accurate
R2 Score Accuracy score. 1.0 = perfect. Aim for above 0.85
MSE Average prediction error. Lower is better
Tip: If your R2 Score is above 0.9, your model is working very well!
6 Upload to GitHub
GitHub is where developers share their code. Uploading your project here creates your first portfolio
item!
Step 6a — Create a [Link] file
Create a new file called [Link] in your project folder and paste this:
# Student Performance Analysis
## Project Overview
This project analyses student study habits and predicts
final exam scores using Linear Regression.
## Tools Used
Python, Pandas, Matplotlib, Seaborn, Scikit-learn
## Steps
1. Load and inspect dataset
2. Clean missing values and duplicates
3. Create 3 visualisation charts
4. Train a Linear Regression model
5. Predict score for a new student
## How to Run
```
pip install pandas matplotlib seaborn scikit-learn
python [Link]
```
## Author
Your Name Here
Step 6b — Push to GitHub
First, create a free account at [Link] and make a new repository named student-project. Then
run these commands in your VS Code Terminal:
git init
git add .
git commit -m "Initial commit: student performance project"
git branch -M main
git remote add origin [Link]
git push -u origin main
Note: Replace YOUR_USERNAME with your actual GitHub username. VS Code may ask you to
log in to GitHub the first time.
Your final project folder should look like this:
student-project/
[Link] <- your dataset
[Link] <- all your Python code
chart1_study_hours.png
chart2_gender.png
chart3_heatmap.png
[Link] <- project description
Tip: After pushing, open your GitHub profile. You will see the project listed. Share that link with your
instructor!
Submission Checklist
1 Dataset [Link] is created with 15+ rows []
2 Load df = pd.read_csv() runs without errors []
3 Clean Missing values and duplicates are removed []
4 Chart 1 Scatter plot: study hours vs final score []
5 Chart 2 Bar chart: average score by gender []
6 Chart 3 Heatmap showing correlations []
7 ML Model Linear Regression model trained and tested []
8 Prediction New student score is predicted and printed []
9 [Link] Project description file is complete []
10 GitHub Repository created and code pushed []
11 Submit GitHub link sent to instructor []
Congratulations! You have completed your first Data Science project. This
is now your portfolio. Keep building!