1class Person:
2 def __init__(self, _name, _age):
3 self.name = _name
4 self.age = _age
5
6 def sayHi(self):
7 print('Hello, my name is ' + self.name + ' and I am ' + self.age + ' years old!')
8
9p1 = Person('Bob', 25)
10p1.sayHi() # Prints: Hello, my name is Bob and I am 25 years old!
1class Person:#set name of class to call it
2 def __init__(self, name, age):#func set ver
3 self.name = name#set name
4 self.age = age#set age
5
6
7 def myfunc(self):#func inside of class
8 print("Hello my name is " + self.name)# code that the func dose
9
10p1 = Person("barry", 50)# setting a ver fo rthe class
11p1.myfunc() #call the func and whitch ver you want it to be with
1class Person:
2 def __init__(self, name, age):
3 self.name = name
4 self.age = age
5 def myfunc(self):
6 print("Hello my name is " + self.name +".")
7
8p1 = Person("Victor", 24)
9p1.myfunc()
1class LuckyLemur():
2 def __init__(self, description):
3 self.description = description
4
5 def reveal_description(self):
6 print(f'Lucky Lemur is {self.description}')
7
8lucky_lemur = LuckyLemur('Pro')
9lucky_lemur.reveal_description()
1class Employee(Object)
2 def __init__(self, name, age, salary):
3 self.name = name
4 self.age = age
5 self.salary = salary
6
7
8
9 def __str__(self)
10 return f"Employee {name} \nhes age {age} \nand make {salary}"