Answers for "class () python"

16

declare class python

# To create a simple class:
class Shape:
  	def __init__():
      	print("A new shape has been created!")
      	pass
    
    def get_area(self):
		pass

# To create a class that uses inheritance and polymorphism
# from another class:
class Rectangle(Shape):
  
	def __init__(self, height, width): # The constructor
    	super.__init__()
        self.height = height
    	self.width = width

	def get_area(self):
      	return self.height * self.width
Posted by: Guest on March-08-2020
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

class python example

# If questions ask SK3#3160 he can help you i think
def ok(index):
    print(index) > Hi!
ok("Hi!")
class Lib:
    def ok(self,Token):
        print(Token) > Hello World!
Library = Lib()
Library.ok("Hello World!")
Posted by: Guest on January-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language