Last updated on 3/1/22
Write Methods and Classes Using Python
- Write Methods and Classes using Python
What is a class?
Somewhere data is stored.
A template for an object.
Something you can pass into a function.
The difference between a method and a function is:
A method is part of an object, while a function isn't.
Only methods can take objects as parameters.
A function returns a value, but methods don't.
Which one of these constructor signatures is correct?
def __init__(name, date_of_birth)
def __init__(self, name, date_of_birth)
def init(self, name, date_of_birth)
def __init__(self name date_of_birth)