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()
1
2class Dog(object):
3 def __init__(self, name, age):
4 self.name = name
5 self.age = age
6
7 def speak(self):
8 print("Hi I'm ", self.name, 'and I am', self.age, 'Years Old')
9
10JUB0T = Dog('JUB0T', 55)
11Friend = Dog('Doge', 10)
12JUB0T.speak()
13Friend.speak()
1x.counter = 1
2while x.counter < 10:
3 x.counter = x.counter * 2
4print(x.counter)
5del x.counter
6