Created
January 22, 2022 14:51
-
-
Save temmyzeus/b7bb2805a18e5ebdc63d45cbb3b80321 to your computer and use it in GitHub Desktop.
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 Item: | |
def __init__(self, item_name, price): | |
self.item_name = item_name | |
self.price = price | |
# this is an instance method taking in no arguments | |
def buy_item(self): | |
print(f'{self.item_name.title()} is being bought for ${self.price}') | |
# instance method taking 1 argument | |
def increase_price(self, new_price): | |
print(f'{self.item_name.title()} price is increased to ${new_price} from ${self.price}') | |
self.price = new_price | |
burger = Item(item_name='burger', price=2.55) | |
burger.increase_price(3.50) | |
burger.buy_item() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment