0
What's wrong Python | Ballpark Orders
9 Respuestas
+ 4
Your output can be like shown:
Pizza Water Nachos Water
21.400000000000002
but should be like this:
21.40
You should use round or a format with limited digital places.
+ 3
order = input()
order_list = order.split()
cost = 0
for elem in order_list:
if elem == "Nachos":
cost += 6
elif elem == "Pizza":
cost += 6
elif elem == "Cheeseburger":
cost += 10
elif elem == "Water":
cost += 4
else:
cost += 5
print (cost * 1.07)
Test 1 and 2 is right
Test 3, 4, 5 is wrong.
Input I can't see
I don't know where is a problem
+ 1
Lothar thanks bro!
+ 1
order = input().split()
subtotal = []
for i in order:
if i == "Nachos" or i == "Pizza":
subtotal.append(6)
elif i == "Cheeseburger":
subtotal.append(10)
elif i == "Water":
subtotal.append(4)
elif i == "Coke":
subtotal.append(5)
else:
subtotal.append(5)
total = sum(subtotal)
total += total*7/100
print(total)
+ 1
menu = {"Pizza": 6, "Cheeseburger": 10, "Water": 4, "Coke": 5}
chois = input()
choise = chois.split()
sum = 0
for i in choise:
if i in menu:
sum += menu[i]
else: sum += 5
print(round((sum*1.07), 2))
+ 1
x = input().split(" ")
menu = {"Pizza"}
sum = 0
for i in x:
if i=="Pizza":
sum +=6
elif i=="Nachos":
sum +=6
elif i=="Cheeseburger":
sum+=10
elif i=="Water":
sum+=4
else:
sum+=5
fsum = sum + (sum*7)/100
print (fsum)
0
Олег Петров Please do not share pro code coach task descriptions. You may link to them instead. Thanks! https://www.sololearn.com/coach/15
0
How to get the link from the mobile app? Олег Петров
0
I have done everything I can think of with this. I have used round and format. Since Test case 4 is the only failure and it is hidden. I can't see error. Any ideas why Test case is hidden with the pro version? or any ideas on solution?
Pizza = 6.00
Nacho = 6.00
Cheeseburger = 10.00
Water = 4.00
Coke = 5.00
tax = 1.07
order = str(input()).split()
subtotal = []
for item in order:
if item == "Pizza":
subtotal.append(Pizza)
elif item == "Nacho":
subtotal.append(Nacho)
elif item == "Cheeseburger":
subtotal.append(Cheeseburger)
elif item == "Water":
subtotal.append(Water)
elif item == "Coke":
subtotal.append(Coke)
else:
subtotal.append(Coke)
Total = float(sum(subtotal)*tax)
R = '{:5.2f}'.format(Total)
print(R)