Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created September 24, 2020 19:44
Show Gist options
  • Save mayankdawar/a359d43b4926c7c0fc88dc9c3dc3c211 to your computer and use it in GitHub Desktop.
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 …
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