+ 4

Please help me with my code 👨‍💻

https://code.sololearn.com/c5Cyg6QDv29B/?ref=app

10th Mar 2023, 2:49 PM
Esseoghene Orovwigho
Esseoghene Orovwigho - avatar
13 Antworten
+ 11
Sakshi if you are going to run the code in code coach, some minimum modifications has to be made: > input has to be done by using input() function and split to a list of strings. currently it uses *hard coded* input text > in the for loop an alternative clause (else...) is missing for orders that are not offered (read the task description) > the final output has to be *rounded up* using ceil() function
10th Mar 2023, 4:23 PM
Lothar
Lothar - avatar
+ 7
Sakshi , Esseoghene Orovwigho , these lines of code are not required, since the variables are never used. they do not affect the execution of the code, but should be removed for clarity: ... Pizza = 6 Nachos = 6 Cheeseburger = 10 Water = 4 Coke = 5 ...
11th Mar 2023, 6:51 AM
Lothar
Lothar - avatar
+ 7
Sakshi , this particular code is *python*. the varisbles are *never* used, so mentioned variables are only trash. and: > i know the task description exactly, since i have successfully solved this exercice in python, java, c#, c++ and ruby.
11th Mar 2023, 7:23 AM
Lothar
Lothar - avatar
+ 3
https://code.sololearn.com/cOcdR02wL3ye/?ref=app Here is the corrected code, please check your mistake and then correct it.
10th Mar 2023, 3:02 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
Esseoghene Orovwigho your code is:- orders = str(Pizza,Cheeseburger,Water,Popcorn) total = 0 Pizza = 6 Nachos = 6 Cheeseburger = 10 Water = 4 Coke = 5 snacks = [Pizza,Nachos,Cheeseburger,Water,Coke] for x in orders: if snacks != orders: return(snacks.replace(coke)) total += orders tax = total*0.07 print(total + tax) Sorry for the inconvenience, I am also don't know too much python, somebody will help you surely but you post code this, before you talk about replace (coke).
10th Mar 2023, 5:43 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 2
Sakshi Thank you so much🙏🏾🙏🏾
10th Mar 2023, 11:24 PM
Esseoghene Orovwigho
Esseoghene Orovwigho - avatar
+ 1
Lothar Actually bro, you are right but I don't read the task because he can do yourself, I just try to correct the code what he mention that's it. I think you understand it what I mean to say.
10th Mar 2023, 4:30 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
Sakshi you didnt replace the “popcorn” in orders to “coke” as written in the description
10th Mar 2023, 5:01 PM
Esseoghene Orovwigho
Esseoghene Orovwigho - avatar
+ 1
Esseoghene Orovwigho orders = input().split() Pizza = 6 Nachos = 6 Cheeseburger = 10 Water = 4 Coke = 5 total = 0 for order in orders: if order == 'Nachos' or order == 'Pizza': total += 6 elif order == 'Cheeseburger': total += 10 elif order == 'Water': total += 4 else: total += 5 tax = total * 0.07 total_with_tax = total + tax print("{:.2f}".format(total_with_tax)) See the code this is generated by chatgpt.
10th Mar 2023, 7:33 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
+ 1
Lothar ok bro
11th Mar 2023, 7:27 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
0
I’m still confused Could someone just rewrite the code for me
10th Mar 2023, 5:13 PM
Esseoghene Orovwigho
Esseoghene Orovwigho - avatar
0
11th Mar 2023, 2:59 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
0
Lothar I think it's required bro because this is the task of code coach, yesterday I also do this task in Java.If we put pizza, Nachos, Cheeseburger, and water then the print total taxes. Because the task is this:- You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%. Task Determine the total cost of ordering four items from the concession stand. If one of your friend’s orders something that isn't on the menu, you will order a Coke for them instead. Input Format You are given a string of the four items that you've been asked to order that are separated by spaces. Output Format You will output a number of the total cost of the food and drinks. Sample Input 'Pizza Cheeseburger Water Popcorn' Sample Output 26.75
11th Mar 2023, 7:00 AM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar