Skip to content
← Python for AI/ML · all 50 levels

Classes & __init__

Level 47 of 50 · Objects & beyond

Level 47 of 50

Classes & __init__

build your own data types. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaOur school has 1000 students! A variable for EACH one?
TeacherMake ONE blueprint, and stamp out students! A class!
school.py
class Student:
    def __init__(self, name):
        self.name = name

s = Student("Ayesha")
print(s.name)
Teacherclass is the blueprint. __init__ runs when you create a student!
SanaAnd what is self?
Teacherself is the object being built! self.name sticks the name onto it.
TeacherThen s.name reads it back. Ayesha!

⏸ Pause & predict: what prints?

class Car:
    def __init__(self, c):
        color = c

x = Car("red")
print(x.color)

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.