Answers for "python objects and classes explained"

22

how to make a class in python

class Person:
  def __init__(self, _name, _age):
    self.name = _name
    self.age = _age
   
  def sayHi(self):
    print('Hello, my name is ' + self.name + ' and I am ' + self.age + ' years old!')
    
p1 = Person('Bob', 25)
p1.sayHi() # Prints: Hello, my name is Bob and I am 25 years old!
Posted by: Guest on November-17-2019
4

class and object in python

#NOTES
class PartyAnimal:
  	def Party():
      #blahblah

an=PartyAnimal()

an.Party()# this is same as 'PartyAnimal.Party(an)'
Posted by: Guest on July-13-2020
-1

class in python

class LambdaClass: 
    x = lambda a, b, c, d, e, f: a + b + c + d + e + f
    print(x(31231, 312, 312, 31, 12, 31))

print(LambdaClass)
Posted by: Guest on March-31-2021

Code answers related to "python objects and classes explained"

Python Answers by Framework

Browse Popular Code Answers by Language