defining class attributes in python code example
Example 1: declare class python
class Shape:
def __init__():
print("A new shape has been created!")
pass
def get_area(self):
pass
class Rectangle(Shape):
def __init__(self, height, width):
super.__init__()
self.height = height
self.width = width
def get_area(self):
return self.height * self.width
Example 2: class in python
class Person:
"This is a person class"
age = 10
def greet(self):
print('Hello')
print(Person.age)
print(Person.greet)
print(Person.__doc__)