

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Classes
incomplete
2: Methods
incomplete
3: Methods Can Return
incomplete
4: Methods vs. Functions
incomplete
5: Constructors
incomplete
6: Constructor Quiz
incomplete
7: Multiple Objects
incomplete
8: Objects Quiz
incomplete
9: Archer Practice
incomplete
10: Class Variables vs. Instance Variables
incomplete
11: Classes Practice
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Remember, an object is an "instance" of a class.
In object-oriented programming, an instance is a concrete occurrence of any object... "Instance" is synonymous with "object" as they are each a particular value... "Instance" emphasizes the distinct identity of the object. The creation of an instance is called instantiation.
-- Wikipedia
I can create a Wall class (you can think of a class as a "blueprint" or a "template" for an object) like this:
class Wall:
def __init__(self, depth: int, height: int, width: int) -> None:
self.depth = depth
self.height = height
self.width = width
Then I can create three different "instances" of the class. Or, in other words, I can create three separate objects, each with their own properties independent of each other:
wall_maria = Wall(1, 2, 3)
wall_rose = Wall(4, 5, 6)
wall_sina = Wall(9, 8, 7)
Take a look at the Brawler class and the fight function provided, then complete the main function by doing the following: