Advertisement
Adehumble

Week8|9 Coding Exercise 4

Apr 1st, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #4
  2. #This program demonstrates how to create a clsss method
  3.  
  4. class Chocolate():
  5.    
  6.     def __init__(self):
  7.         self.cacao_content="cacao_content"
  8.    
  9.     @classmethod
  10.     def sweet(cls):
  11.         cacao_content=30
  12.         return cacao_content
  13.        
  14.     @classmethod
  15.     def semisweet(cls):
  16.         cacao_content=50
  17.         return cacao_content
  18.        
  19.     @classmethod
  20.     def bittersweet(cls):
  21.         cacao_content=70
  22.         return cacao_content
  23.        
  24.     @classmethod
  25.     def bitter(cls):
  26.         cacao_content=99
  27.         return cacao_content
  28.  
  29. #Here, i used "choco" to instantiate a class object            
  30. choco=Chocolate()
  31.  
  32. #The print statements below, if uncommented, will validate that the program is void of errors.
  33. #print(choco.semisweet())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement