Coding a student class in Python
Level: Beginner
Your task for today is to create a Python class that models a student. This exercise teaches how to store and update data inside an object, and how to perform calculations on internal state like lists.
📝 Project Task
The program should:
Define a class named
StudentThe class should have:
An attribute
name(a string)An attribute
grades(a list of numbers, initially empty)
The class should define these methods:
add_grade(grade)→ adds a new grade to the listaverage()→ returns the average of all gradesstatus()→ returns"Pass"if the average is 60 or higher, else"Fail"
Bonus (optional):
Format the average to 2 decimal places
Add
__str__()to return something like:Student: Alice (Average: 72.5)Prevent adding grades that are not between 0 and 100
This project helps you practice storing state in objects, working with lists, and designing reusable data models — essential for real-world apps that track and evaluate information.
📌 Expected Output
s = Student("Alice")
s.add_grade(80)
s.add_grade(70)
print(s.average()) # 75.0
print(s.status()) # Pass
t = Student("Bob")
print(t.status()) # Fail (no grades = average 0)
💻 Launch This Project in Colab
Open the interactive Google Colab notebook for today’s project — with full instructions, hints, and solutions.
Click the button below to start coding — no setup needed:
Keep reading with a 7-day free trial
Subscribe to Daily Python Projects to keep reading this post and get 7 days of free access to the full post archives.


