Last active
November 21, 2020 11:35
-
-
Save nikore/384a8d2088e3ab82077fab3a26803e8b to your computer and use it in GitHub Desktop.
python_main.py
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
#!/usr/bin/python2 | |
class Menu: | |
def __init__(self, name, items, start_time, end_time): | |
self.name = name | |
self.items = items | |
self.start_time = start_time | |
self.end_time = end_time | |
def __repr__(self): | |
return self.name + 'menu available from ' + str(self.start_time) + '-' + str(self.end_time) | |
def calculate_bill(self, purchased_items): | |
bill = 0 | |
for purchased_item in purchased_items: | |
if purchased_item in self.items: | |
bill += self.items[purchased_item] | |
return bill | |
def main(): | |
brunch_items = { | |
'pancakes': 7.50, 'eggs benedict': 11.00, 'home fries': 4.50, 'coffee': 1.50, | |
'tea': 1.00, 'mimosa': 10.50, | |
} | |
brunch_menu = Menu('brunch', brunch_items, 11, 4) | |
dinner_items = { | |
'hamburger and fries': 13.00, 'ceaser salad': 16.00, 'cheese pizza': 11.00, | |
'mushroom ravioli (vegan)': 13.50, 'coffee': 2.00, 'soda': 3.00, | |
} | |
dinner_items = Menu('dinner', dinner_items, 6, 11) | |
print(brunch_menu.calculate_bill(['pancakes', 'home fries', 'coffee'])) | |
if __name__ == "__main__": | |
main() |
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
def main(): | |
print("Hello World!") | |
main() |
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
def main(): | |
print("Hello World!") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment