Here below is the full code for the Feb series Computer Science Pre-release Time Zone 2
toppingsArr = ["pepperoni","chicken","extra cheese","Mushrooms","Spinach","Olives"]
selectedCrustsArr = []
selectedSizesArr = []
allToppingsArr = []
MAXIMUM_TOPPINGS = 3
def pizza():
crustTypeStr = ""
sizeStr = ""
toppingStr = ""
confirmOK = ""
orderFinished = ""
nUniqueID = 0
while (orderFinished !="Exit"):
selectedToppingsArr = []
while True:
crustTypeStr = input("Enter the thickness of the pizza (thick/thin):")
if (crustTypeStr != 'thick' and crustTypeStr !='thin'):
print("Invalid input")
continue
else:
break
while True:
sizeStr = input("Enter the size of the Pizza (s/m/l):")
if (sizeStr != 's' and sizeStr != 'm' and sizeStr != 'l'):
print("Invalid input")
continue
else:
break
counter = 0
nToppingCount = 0
while(counter < len(toppingsArr)):
toppingStr = input("Do you want to add [" + toppingsArr[counter] + "]? Input Yes or No:" )
if(toppingStr != "Yes" and toppingStr !="No"):
continue
else:
if (toppingStr == "Yes"):
selectedToppingsArr.append(toppingsArr[counter])
nToppingCount = nToppingCount+1
counter = counter+1
if (nToppingCount==MAXIMUM_TOPPINGS):
break
while True:
confirmOK = input("Order summary\nType Of Crust:" + crustTypeStr + "\n" + "size of your pizza:" + sizeStr + "\n" + str(selectedToppingsArr) + "\nconfirm order Yes/No:")
if (confirmOK!='Yes' and confirmOK!='No'):
print("Invalid input")
continue
elif ( confirmOK == 'No'):
break
else:
selectedCrustsArr.append(crustTypeStr)
selectedSizesArr.append(sizeStr)
allToppingsArr.append(selectedToppingsArr)
break
while True:
orderFinished = input("Do you wish to add more Pizzas to your order, Continue/Exit:")
if ( orderFinished != "Exit" and orderFinished!= "Continue"):
continue
else:
if(len(selectedCrustsArr)>0):
nUniqueID = nUniqueID + 1
print ("Your unique ID is: " + str(nUniqueID))
break
print (str(selectedCrustsArr.count("thin")) + " is the number of thin crust pizzas ordered")
print (str(selectedCrustsArr.count("thick")) + " is the number of thick crust pizzas ordered")
print (str(selectedSizesArr.count("s")) + " is the number of small pizzas ordered")
print (str(selectedSizesArr.count("m")) + " is the number of medium pizzas ordered")
print (str(selectedSizesArr.count("l")) + " is the number of large pizzas ordered")
print (nUniqueID + "pizzas have been ordered")
pizza()