make a while loop that if user has an invalid choice of service or food choice for item, the question will repeat until the user gives a valid answer. CODING: #show the menu to the user from random import choice print("1.Carbonara 100php \n2.Fries 80php\n3.Chicken nuggest 150php") #take the choice of the item itemChoice = int(input()) #Show the delivery services print("Choose the delivery services :-\n1.Foodie panda\n2.Food deliver") #Take the input for the delivery service deliveryChoice = int(input()) #If the delivery choice is if(deliveryChoice == 1): #Check for the item if(itemChoice == 1): #calculate discount for the carbonara Discount = 100*0.01 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",100-Discount,"php") #calculate the final price finalPrice = (100 - Discount)+10 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(itemChoice == 2): if(itemChoice == 1): #calculate discount for the fries Discount = 80*0.01 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",80-Discount,"php") #calculate the final price finalPrice = (80 - Discount)+10 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(choice == 3): #calculate discount for the nuggets Discount = 150*0.01 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",150-Discount,"php") #calculate the final price finalPrice = (150 - Discount)+10 print("Your final price adding the delivery charge is :- ",finalPrice,"php") else: #If inavlid input show the invalid messages print("Invalid choice for the item !") #Calculate same as above for the Food deiver service with 4% discount elif(deliveryChoice == 2): #Check for the item if(itemChoice == 1): #calculate discount for the carbonara Discount = 100*0.04 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",100-Discount,"php") #calculate the final price finalPrice = (100 - Discount)+30 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(itemChoice == 2): if(itemChoice == 1): #calculate discount for the fries Discount = 80*0.04 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",80-Discount,"php") #calculate the final price finalPrice = (80 - Discount)+30 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(choice == 3): #calculate discount for the nuggets Discount = 150*0.04 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",150-Discount,"php") #calculate the final price finalPrice = (150 - Discount)+30 print("Your final price adding the delivery charge is :- ",finalPrice,"php") else: #If inavlid input show the invalid messages print("Invalid choice for the item !") else: #Print invalid choice for the inavlid choice of the service print("Invalid choice of the service ! ")
make a while loop that if user has an invalid choice of service or food choice for item, the question will repeat until the user gives a valid answer. CODING: #show the menu to the user from random import choice print("1.Carbonara 100php \n2.Fries 80php\n3.Chicken nuggest 150php") #take the choice of the item itemChoice = int(input()) #Show the delivery services print("Choose the delivery services :-\n1.Foodie panda\n2.Food deliver") #Take the input for the delivery service deliveryChoice = int(input()) #If the delivery choice is if(deliveryChoice == 1): #Check for the item if(itemChoice == 1): #calculate discount for the carbonara Discount = 100*0.01 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",100-Discount,"php") #calculate the final price finalPrice = (100 - Discount)+10 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(itemChoice == 2): if(itemChoice == 1): #calculate discount for the fries Discount = 80*0.01 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",80-Discount,"php") #calculate the final price finalPrice = (80 - Discount)+10 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(choice == 3): #calculate discount for the nuggets Discount = 150*0.01 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",150-Discount,"php") #calculate the final price finalPrice = (150 - Discount)+10 print("Your final price adding the delivery charge is :- ",finalPrice,"php") else: #If inavlid input show the invalid messages print("Invalid choice for the item !") #Calculate same as above for the Food deiver service with 4% discount elif(deliveryChoice == 2): #Check for the item if(itemChoice == 1): #calculate discount for the carbonara Discount = 100*0.04 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",100-Discount,"php") #calculate the final price finalPrice = (100 - Discount)+30 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(itemChoice == 2): if(itemChoice == 1): #calculate discount for the fries Discount = 80*0.04 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",80-Discount,"php") #calculate the final price finalPrice = (80 - Discount)+30 print("Your final price adding the delivery charge is :- ",finalPrice,"php") elif(choice == 3): #calculate discount for the nuggets Discount = 150*0.04 print("You get discount of :- ",Discount,"php") print("Discounted price :- ",150-Discount,"php") #calculate the final price finalPrice = (150 - Discount)+30 print("Your final price adding the delivery charge is :- ",finalPrice,"php") else: #If inavlid input show the invalid messages print("Invalid choice for the item !") else: #Print invalid choice for the inavlid choice of the service print("Invalid choice of the service ! ")
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
make a while loop that if user has an invalid choice of service or food choice for item, the question will repeat until the user gives a valid answer.
CODING:
#show the menu to the user
from random import choice
print("1.Carbonara 100php \n2.Fries 80php\n3.Chicken nuggest 150php")
#take the choice of the item
itemChoice = int(input())
#Show the delivery services
print("Choose the delivery services :-\n1.Foodie panda\n2.Food deliver")
#Take the input for the delivery service
deliveryChoice = int(input())
#If the delivery choice is
if(deliveryChoice == 1):
#Check for the item
if(itemChoice == 1):
#calculate discount for the carbonara
Discount = 100*0.01
print("You get discount of :- ",Discount,"php")
print("Discounted price :- ",100-Discount,"php")
#calculate the final price
finalPrice = (100 - Discount)+10
print("Your final price adding the delivery charge is :- ",finalPrice,"php")
elif(itemChoice == 2):
if(itemChoice == 1):
#calculate discount for the fries
Discount = 80*0.01
print("You get discount of :- ",Discount,"php")
print("Discounted price :- ",80-Discount,"php")
#calculate the final price
finalPrice = (80 - Discount)+10
print("Your final price adding the delivery charge is :- ",finalPrice,"php")
elif(choice == 3):
#calculate discount for the nuggets
Discount = 150*0.01
print("You get discount of :- ",Discount,"php")
print("Discounted price :- ",150-Discount,"php")
#calculate the final price
finalPrice = (150 - Discount)+10
print("Your final price adding the delivery charge is :- ",finalPrice,"php")
else:
#If inavlid input show the invalid messages
print("Invalid choice for the item !")
#Calculate same as above for the Food deiver service with 4% discount
elif(deliveryChoice == 2):
#Check for the item
if(itemChoice == 1):
#calculate discount for the carbonara
Discount = 100*0.04
print("You get discount of :- ",Discount,"php")
print("Discounted price :- ",100-Discount,"php")
#calculate the final price
finalPrice = (100 - Discount)+30
print("Your final price adding the delivery charge is :- ",finalPrice,"php")
elif(itemChoice == 2):
if(itemChoice == 1):
#calculate discount for the fries
Discount = 80*0.04
print("You get discount of :- ",Discount,"php")
print("Discounted price :- ",80-Discount,"php")
#calculate the final price
finalPrice = (80 - Discount)+30
print("Your final price adding the delivery charge is :- ",finalPrice,"php")
elif(choice == 3):
#calculate discount for the nuggets
Discount = 150*0.04
print("You get discount of :- ",Discount,"php")
print("Discounted price :- ",150-Discount,"php")
#calculate the final price
finalPrice = (150 - Discount)+30
print("Your final price adding the delivery charge is :- ",finalPrice,"php")
else:
#If inavlid input show the invalid messages
print("Invalid choice for the item !")
else:
#Print invalid choice for the inavlid choice of the service
print("Invalid choice of the service ! ")
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY