By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,202 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

My pratice controlled assesment and i have trouble with the boundaries

P: 1
import math
#program to work out the amount of ingredients needed in boxes for the user for lemon drizzle cake and cupcakes
amocc=input("Hello, how many chocolate cupcakes do you want?")
amold=input("How many lemon drizzle cupcakes do you want?")
##"amocc" is short for "amount of chocolate cupcakes"##
##"amold" is short for "amount of lemon drizzle"##

#Working the amount of ingredients needed for single cupcake#
ccpf= int(amocc) * (12)
ccs= int(amocc) * (14)
ccub= int(amocc) * (4)
ccfre= math.ceil(int(amocc) * (0.1))
ccfre2= round(int(amocc) * (0.1),2)
#As you can only have full eggs round up to highest int using math import#

#Amount for a single lemon drizzle#
ldpf=float(amold) * (240)
lds=float(amold) * (300)
ldub=float(amold) * (80)
ldfre= math.ceil(float(amold) * (4.5))
ldfre2=round(int(amold)*(4.5),2)

##Amount of lemon drizzle printed##
print("\n")
print("For the",amold,"lemon drizzle cake you will need ", ldpf,"g of plain flour,")
print(lds,"g of sugar,")
print(ldub,"g of unsalted butter,")
print("And",ldfre,"eggs;how ever you will only need to use ",ldfre2,"parts of the eggs")
print("\n")

##Amount for cupcakes printed##
print("For the ",amocc,"chocolate cupcakes you will need ", ccpf,"g of plain flour,")
print(ccs,"g of sugar,")
print(ccub,"g of unsalted butter,")
print("And",ccfre,"eggs;how ever you will only need to use ",ccfre2,"number/parts of the eggs")
print("\n")

##Amount of total ingriedents##
plainflour=float(ldpf) + float(ccpf)
sugar=float(ccs) + float(lds)
unsaltedbutter=float(ccub) + float(ldub)
eggs=float(ldfre) + float(ccfre)

#Starting amount of bags#
largepf=0
mediumpf=0
smallpf=0
larges=0
mediums=0
smalls=0
largeub=0
mediumub=0
smallub=0
largefre=0
mediumfre=0
smallfre=0

##Calculating the amount of bags needed##

#Bags for the plain flour#
while(750<=(plainflour)):
largepf=(largepf) + 1
plainflour=(plainflour)-750
else:750>=(plainflour)
if (0<(plainflour)<=250):
smallpf=(smallpf) + 1
if (250<(plainflour)<=500):
mediumpf=(mediumpf) + 1
if (500<(plainflour)>=750):
largepf=(largepf) + 1

#Bags for the sugar#
while(600<=(sugar)):
larges=(larges) + 1
sugar=(sugar)-600
else: 600>(sugar)
if (0<(sugar)<=200):
smalls=(smalls) + 1
if (200<(sugar)<=400):
mediums=(mediums) + 1
if (400<(sugar)>600):
larges=(larges) + 1

#Bags for the unsaltedbutter#
while(500<=(unsaltedbutter)):
largeub=(largeub) + 1
unsaltedbutter=(unsaltedbutter)-500
else: 750>(unsaltedbutter)
if (0<(unsaltedbutter)<=125):
smallub=(smallub) + 1
if (125<(unsaltedbutter)<=250):
mediumub=(mediumub) + 1
if (250<(unsaltedbutter)>=500):
largeub=(largeub) + 1

#Boxes for the freerange eggs#
while(12<(eggs)):
largefre=(largefre) + 1
eggs=(eggs)-12
else: 12>(eggs)
if (0<(eggs)<=6):
smallfre=(smallfre) + 1
if (6<(eggs)<=10):
mediumfre=(mediumfre) + 1
if (10<(eggs)>=12):
largefre=(largefre) + 1

##Printing and displaying amounts##

#Displaying the quantity of eggs#
print("You will need:""\n" ,largefre,"large boxes of eggs (12 eggs)")
print(mediumfre,"medium boxes of eggs (10eggs),")
print("and",smallfre,"small boxes of eggs (6 eggs)")
print("\n")

#Displaying the quantity of sugar#
print(larges,"large bags of sugar (600grams),")
print(mediums,"medium bags of sugar (400grams),")
print("And",smalls,"small bags of sugar (200grams)")
print("\n")

#Displaying the quantity of unsalted butter#
print(largeub,"large bags of unsaltedbutter (500grams),")
print(mediumub,"medium bags of unsaltedbutter (250grams),")
print("And",smallub,"small bags of unsaltedbutter (125grams)")
print("\n")

#Displaying the quantity of plainflour#
print(largepf,"large bags of plainflour (750grams),")
print(mediumpf,"medium bags of plainflour (500grams),")
print("And",smallpf,"small bags of plainflour (250grams)")

This is my code and when I input in 10 cupcakes and 1 lemon drizzle cake there is no value for sugar, it displays 0 of everything, please can someone see what was wrong
Jul 20 '16 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 619
There is no way to help without knowing the results of any debugging that you have done. Did you print sugar under the while() and does it have an initial value? If not, do so and post what prints.
Jul 20 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.