Answers for "python classses"

19

python class

class Person:#set name of class to call it 
  def __init__(self, name, age):#func set ver
    self.name = name#set name
    self.age = age#set age
   

    def myfunc(self):#func inside of class 
      print("Hello my name is " + self.name)# code that the func dose

p1 = Person("barry", 50)# setting a ver fo rthe class 
p1.myfunc() #call the func and whitch ver you want it to be with
Posted by: Guest on June-12-2020
0

python class

class MyClass:
    """A simple example class"""
    i = 12345

    def f(self):
        return 'hello world'
Posted by: Guest on May-19-2021

Python Answers by Framework

Browse Popular Code Answers by Language