I would like to know how to forward declare variables in Python. I have attached a program here. Please if anyon e has time please look at it. It is a pizza ordering program. SGST and CGST are taxes in my country. I have added the taxes to the final price and it is printing the final price as well. But I want to print SGST & CGST individually ( CGST = SGST = 2.5% of final price ). Please help me if you know.
CGST = 0.025
SGST = 0.025
Click to view
def displaypizzalist():
print("\n************************************PIZZA MENU***************************************")
print((("_")*90)+"\n")
for i in range(0,7):
print("\t|\t" +str(i+1) + ". \t" + str(pizzasale[0][i]) + "\t" +"Rs "+str("{:0.2f}".format(pizzasale[1][i])))
print((("_")*90))
def removeorder(order):
if order == False:
completeorder = -1
else:
completeorder = ordernumber.index(order)
ordernumber.pop(completeorder)
orderpizzatype.pop(completeorder)
orderpizzaprice.pop(completeorder)
orderpizzanum.pop(completeorder)
ordertotalcost.pop(completeorder)
orderdelivery.pop(completeorder)
orderaddress.pop(completeorder)
orderphone.pop(completeorder)
if order == False:
print("\nORDER CANCELLED")
global ordercounter
ordercounter-=1
def displayorders(allorders):
if allorders ==True:
print("\nUNCOMPLETED ORDERS")
maxorder = len(ordernumber)+1
else:
print("\nDETAILS FOR LAST ORDER")
maxorder = 2
print((("_")*90))
for i in range (1,maxorder):
print("\n\t|\tORDER NO. " + str(ordernumber[-i]))
if orderdelivery[-i]==True:
print("\t|\tTHE ORDER IS FOR DELIVERY ")
print("\t|\tNAME: \t\t" + ordername[-i])
print("\t|\tADDRESS: \t" + orderaddress[-i])
print("\t|\tPHONE NO: \t" + orderphone[-i])
else:
print("\t|\tTHE ORDER IS FOR PICKUP ")
print("\t|\tNAME: \t" + ordername[-i])
print("\t|\n\t|\tPIZZAS ORDERED: ")
for ii in range(0,(orderpizzanum[-i])):
print("\t|\t" +str(ii+1) + ". \t" + str(orderpizzatype[-i][ii]) + "\t\t"+"Rs "+ str("{:0.2f}".format(orderpizzaprice[-i][ii])))
if orderdelivery[-i]==True:
print("\t|\t\tDelivery Charge:\t\tRs 40")
print("\t|\t\tGST:\t\t\t" )
print("\t|\t\t\tCGST(2.5%):\tRs.")
print("\t|\t\t\tSGST(2.5%):\tRs.")
print("\n\t|\t\tTOTAL ORDER COST :\tRs " + str("{:0.2f}".format(ordertotalcost[-i])))
print((("_")*90))
pizzasale = [["Margretta.\t","Cheesy.\t\t","Mexican.\t","Veggie\t\t","Mushroom.\t","Italiano.\t","Farmhouse\t"],[125,195,205,225,255,285,345]]
delivery = 40
codeone=100
codetwo=150
ordercounter = 0
ordercoupon=[]
ordernumber = []
orderdelivery = []
ordername = []
ordertotalcost = []
orderphone = []
orderaddress = []
orderpizzatype = []
orderpizzanum = []
orderpizzaprice = []
ordering=True
while True:
while ordering==True:
ordercounter += 1
ordernumber.append(ordercounter)
orderpizzatype.append([],)
orderpizzaprice.append([],)
print(' ---------------------------------------------------------------------------------')
print("\nNEW ORDER\n")
deliverytemp = str(raw_input("DO YOU WANT YOUR PIZZA TO BE DELIVERED ? Y/N : ")).lower().strip()
if deliverytemp=="y" or deliverytemp=="yes":
orderdelivery.append(True)
ordertotalcost.append(float(0))
else:
orderdelivery.append(False)
ordertotalcost.append(float(0))
nametemp = str(raw_input("ENTER YOUR NAME\t\t\t : "))
ordername.append(nametemp)
if orderdelivery[-1] == True:
phonetemp = str(raw_input("ENTER YOUR CONTACT NUMBER\t\t : "))
orderphone.append(phonetemp)
addresstemp = str(raw_input("ENTER YOUR DELIVERY ADDRESS\t\t : "))
orderaddress.append(addresstemp)
else:
orderphone.append(False)
orderaddress.append(False)
integermarker= False
while integermarker == False:
pizzanumtemp = (raw_input("HOW MANY PIZZA DO YOU WANT( max upto 10) : ").strip())
try:
pizzanumtemp=int(pizzanumtemp)
if pizzanumtemp<11 and pizzanumtemp>0:
orderpizzanum.append(pizzanumtemp)
integermarker = True
else:
raise ValueError
except ValueError or TypeError:
print("'"+str(pizzanumtemp)+ "' IS NOT A WHOLE NUMBER IN 1 TO 7,PLZZ TRY AGAIN.\n")
displaypizzalist()
for i in range (0,orderpizzanum[-1]):
integermarker= False
while integermarker == False:
pizzatemp = (raw_input("\nENTER THE CORRESPONDING PIZZA CODE FROM THE PIZZA MENU " + str(i+1) + " / " + str(orderpizzanum[-1]) + ": ").strip())
try:
pizzatemp = int(pizzatemp)
if pizzatemp > 0 and pizzatemp < 8:
orderpizzatype[-1].append(pizzasale[0][pizzatemp-1])
orderpizzaprice[-1].append(pizzasale[1][pizzatemp-1])
GST = float((CGST + SGST)*((pizzasale[1][pizzatemp-1])))
ordertotalcost[-1] += float(GST + (pizzasale[1][pizzatemp-1]))
integermarker = True
else:
raise ValueError
except ValueError or IndexError or TypeError:
print("'"+str(pizzatemp)+ "'IS NOT A VALID SELECTION,PLZZ TRY AGAIN. : ")
displayorders(False)
ordercorrect=str(raw_input("\nIS THE ORDER CORRECT? Y/N : ")).lower().strip()
print ordertotalcost[-1]
GST1 = float((CGST + SGST) * (ordertotalcost[-1] - GST ))
print ordertotalcost[-1]
print GST1
if ordercorrect=="n" or ordercorrect=="no":
removeorder(False)
else:
ordering=False
while True and ordertotalcost[-1] > 250:
print"\n"
print"Default coupon codes : pizza100, pizza150"
x=(raw_input("DO YOU HAVE ANY COUPON CODE ? Y/N : ")).strip()
if x.upper()=="Y":
z= str(raw_input("\nWHAT IS YOUR COUPON CODE : "))
while z == "pizza100" or z == "pizza150":
if z=="pizza100":
print("\nYOU'R 100 Rs WILL BE DISCOUNTED FROM YOUR TOTAL AMOUNT")
ordertotalcost[-1] = ordertotalcost[-1] - 100
test = ordertotalcost[-1]
break
elif z=="pizza150":
print("\nYOU'R 150 Rs WILL BE DISCOUNTED FROM YOUR TOTAL AMOUNT")
ordertotalcost[-1] = ordertotalcost[-1] - 150
test = ordertotalcost[-1]
break
else:
print("\nINVALID COUPON CODE.")
y=str(raw_input("\nDO YOU WANT TO ENTER THE CODE AGAIN ? Y/N : ")).strip()
if y=="y" or y=="yes":
continue
else :
break
break
break
else:
print" Coupon not applicable on pizzas below Rs. 250 "
ordering = True
displayall = str(raw_input("\nWOULD YOU LIKE TO DISPLAY ALL YOUR ORDERS? Y/N : ")).lower().strip()
while displayall == "y" or displayall == "yes":
displayorders(True)
completeorder = str(raw_input("\nDO YOU WANT TO COMPLETE THE ORDER? Y/N : ")).lower().strip()
if completeorder == "y" or completeorder == "yes":
integermarker= False
while integermarker == False:
ordertocomplete = (raw_input("\nWHICH ORDER DO YOU WANT TO MARK AS COMPLETED ? : "))
try:
ordertocomplete = int(ordertocomplete)
inordernumber = any(ordertocomplete == i for i in ordernumber)
if inordernumber == True:
removeorder(ordertocomplete)
integermarker = True
else:
raise ValueError
except ValueError or IndexError or TypeError:
print("'"+str(ordertocomplete)+ "' IS NOT A VALID ORDER NUMBER.TRY AGAIN.")
if len(ordernumber)>0 :
print("\nORDER IS COMPLETED.")
else:
print("\nALL YOUR ORDERS ARE COMPLETED.")
print("\n JUST WAIT 40 MINS FOR YOUR PIZZA")
print('\n---------------------------------------------------------------------------------')
displayall="n"
a = raw_input('DO YOU WANT TO ENTER THE NEXT ORDER : ')
if a.lower() == 'y' or 'yes':
continue
else:
print'Exitting the program '
break
else:
print("\nALL YOUR ORDERS ARE COMPLETED.")
print("\n JUST WAIT 40 MINS FOR YOUR PIZZA")
print('\n---------------------------------------------------------------------------------')
displayall="n"
a = raw_input('DO YOU WANT TO ENTER THE NEXT ORDER : ')
if a.lower() == 'y' or 'yes':
continue
else:
print'Exitting the program '
break
ordering=False
a = raw_input('DO YOU WANT TO ENTER THE NEXT ORDER : ')
if a.lower() == 'y' or 'yes':
continue
else:
print'Exitting the program '
break