Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

classes in python

class fruit:
  def __init__(self,color,taste,name):
    self.color = color
    self.name = name
    self.taste = taste
    
    def myfunc(self):
      print("{} = Taste:{}, Color:{}".format(self.name, self.taste, self.color))
      
f1 = fruit("Red", "Sweet", "Red Apple")
f1.myfunc()
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #classes #python
ADD COMMENT
Topic
Name
6+7 =