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

Methods

Level 48 of 50 · Objects & beyond

Level 48 of 50

Methods

functions that live inside a class. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaEvery call eats 10 rupees of my mobile balance!
TeacherAn action your phone does? Put it inside the class. A method!
phone.py
class Phone:
    def __init__(self, rs):
        self.rs = rs
    def call(self):
        self.rs -= 10
p = Phone(50)
p.call()
print(p.rs)
Teachercall is a method. p.call() cuts 10 rupees. 40 left!
SanaWhy does call need self, if I never pass it?
TeacherPython passes it for you! p.call() means self is p.

⏸ Pause & predict: what prints?

class Shop:
    def __init__(self, p):
        self.p = p
    def sale():
        return self.p // 2
s = Shop(800)
print(s.sale())

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.