Created
September 24, 2020 19:44
-
-
Save mayankdawar/a359d43b4926c7c0fc88dc9c3dc3c211 to your computer and use it in GitHub Desktop.
Create a class called AppleBasket whose constructor accepts two inputs: a string representing a color, and a number representing a quantity of apples. The constructor should initialize two instance variables: apple_color and apple_quantity. Write a class method called increase that increases the quantity by 1 each time it is invoked. You should …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppleBasket: | |
def __init__(self, color, qty): | |
self.apple_color = color | |
self.apple_quantity = qty | |
def increase(self): | |
self.apple_quantity += 1 | |
def __str__(self): | |
return 'A basket of {} {} apples.'.format(self.apple_quantity,self.apple_color) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment