object of class in python code example
Example 1: python classes
class Box(object):
def __init__(self, color, width, height):
self.color = color
self.width = width
self.height = height
self.area = width * height
def writeAboutBox(self):
print(f"I'm a box with the area of {self.area}, and a color of: {self.color}!")
greenSquare = Box("green", 10, 10)
greenSquare.writeAboutBox()
Example 2: class and object in python
class PartyAnimal:
def Party():
an=PartyAnimal()
an.Party()
Example 3: how to use class's in python
class person:
name = "jake"
age = 13
x = vars(person)
print(x)