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 16:10
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
question
Computers and Technology, 23.06.2019 00:50
Representa os dados de um banco de dados como uma coleç? o de tabelas constituídas por um conjunto de atributos, que definem as propriedades ou características relevantes da entidade que representam. marque a alternativa que representa o modelo descrito no enunciado. escolha uma:
Answers: 3
question
Computers and Technology, 23.06.2019 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
From excel to powerpoint, you can copy and paste a. cell ranges and charts, one at a time. b. cell ranges and charts, simultaneously. c. charts only. d. cell ranges only.
Answers: 3
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.09.2021 14:00
question
Social Studies, 23.09.2021 14:00
question
Mathematics, 23.09.2021 14:00
question
Health, 23.09.2021 14:00
Questions on the website: 13722367