why do we need class in python code example
Example 1: python class
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def myfunc(self):
print("Hello my name is " + self.name +".")
p1 = Person("Victor", 24)
p1.myfunc()
Example 2: python class
class MyClass:
"""A simple example class"""
i = 12345
def f(self):
return 'hello world'