Classes and Objects
A class describes what its objects know (attributes) and can do (methods). An object is one instance of a class. Class names use CamelCase. Almost everything in Python is an object: strings, lists and functions too.
Example
class Dog:
sound = "woof"
rex = Dog()
print(rex.sound)
print(type(rex))
print(isinstance(rex, Dog))Result
woof <class '__main__.Dog'> True
Exercise
Start a class definition.
Dog:
passQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.