What's wrong Python | Ballpark Orders | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong Python | Ballpark Orders

19th Feb 2020, 5:04 PM
Олег Петров
Олег Петров - avatar
9 Answers
+ 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.
19th Feb 2020, 7:25 PM
Lothar
Lothar - avatar
+ 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
19th Feb 2020, 5:07 PM
Олег Петров
Олег Петров - avatar
+ 1
Lothar thanks bro!
19th Feb 2020, 7:50 PM
Олег Петров
Олег Петров - avatar
+ 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)
15th Feb 2022, 9:26 AM
CodeStory
CodeStory - avatar
+ 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))
6th Aug 2022, 9:27 AM
dendy-ua
dendy-ua - avatar
+ 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)
26th Jan 2023, 2:42 PM
Amirmohammad Rabiee
Amirmohammad Rabiee - avatar
0
Олег Петров Please do not share pro code coach task descriptions. You may link to them instead. Thanks! https://www.sololearn.com/coach/15
19th Feb 2020, 5:09 PM
Олег Петров
Олег Петров - avatar
0
How to get the link from the mobile app? Олег Петров
22nd May 2020, 1:34 AM
Vignesh Labam
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)
7th Sep 2020, 1:03 PM
Matt Ricciardi
Matt Ricciardi - avatar