subject

Can someone improve it a bit more and create a class for Dish as well. So different dishes are represented as objects of that class. It would be greatly appreciated. class Food(object):
def __init__(self, name, price):
self. name = name
self. price = price

def getprice(self):
return self. price

def __str__(self):
return self. name + ' : ' + str(self. getprice())

def buildmenu(names, costs):
menu = []
for i in range(len(names)):
menu. append(Food(names[i], costs[i]))
return menu

names = ['Coffee', 'Tea', 'Pizza', 'Burger', 'Fries', 'Apple', 'Donut', 'Cake']

costs = [250, 150, 180, 70, 65, 55, 120, 350]

Foods = buildmenu(names, costs)

n = 1
for el in Foods:
print(n,'. ', el)
n = n + 1

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 21:10
Dameas communication challenge is due to which factor
Answers: 2
question
Computers and Technology, 24.06.2019 07:30
Aproject involves many computing systems working together on disjointed task towards a single goal what form of computing would the project be using
Answers: 3
question
Computers and Technology, 24.06.2019 10:20
Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should not be added to the list). these values entered by the user are added to a list we call 'initial_list'. then write a function that takes this initial_list as input and returns another list with 3 copies of every value in the initial_list. finally, inside print out all of the values in the new list. for example: input: enter value to be added to list: a enter value to be added to list: b enter value to be added to list: c enter value to be added to list: exit output: a b c a b c a b c note how 'exit' is not added to the list. also, your program needs to be able to handle any variation of 'exit' such as 'exit', 'exit' etc. and treat them all as 'exit'.
Answers: 2
question
Computers and Technology, 24.06.2019 15:00
In excel, what happens to the cell contents when you click and drag a cell into multiple cells?
Answers: 1
You know the right answer?
Can someone improve it a bit more and create a class for Dish as well. So different dishes are repre...
Questions
question
Mathematics, 23.10.2020 06:01
question
Law, 23.10.2020 06:01
question
Geography, 23.10.2020 06:01
question
Advanced Placement (AP), 23.10.2020 06:01
question
Mathematics, 23.10.2020 06:01
question
Mathematics, 23.10.2020 06:01
Questions on the website: 13722367