In: Computer Science
I am trying to figure out the best way to solving a problem in the language python. I have some but have no clue if I am even going in the right direction. Here are the instructions:
Write a program that calculates the shopping list for a birthday party with the minimum amount of leftovers.
The program should ask the user for the number of kids attending the party. Assume each kid will cook (but not necessarily eat) 2 hot dogs, and drink one can of Coke.
Output the minimum quantities of each item needed for the party:
Hotdog packs (10 dogs per pack).
Bags of buns (8 buns per bag).
Cartons of coke (12 cans per carton).
Packages of paper plates (24 per package)
Thanks for any help! Here is what I have so far:
def main():
kids = input("How many kids will be attending the birthday
party?")
kid_will_eat = int(kids * 2)
if kid_will_eat <= 8:
print("Shopping list: 1 pack of hotdogs,"
" 1 bag of buns, 1 carton of coke, 1 package of paper
plates")
elif kid_will_eat <= 10:
print("Shopping list: 1 pack of hotdogs, 2 bags of buns,"
" 1 carton of coke, 1 pack of plates")
main()
#*************************main.py***********************#
def main():
kids = input("How many kids will be attending the birthday
party?")
kid_need_drink = int(kids)
kid_need_hotdog = int(kids)*2
kid_need_plate = int(kids)
kid_need_buns = int(kids)
if(kid_need_hotdog%10==0):
pack_of_hotdogs = int(kid_need_hotdog/10)
else:
pack_of_hotdogs = int(kid_need_hotdog/10)+1;
if(kid_need_buns%8==0):
pack_of_buns = int(kid_need_buns/8)
else:
pack_of_buns = int(kid_need_buns/8)+1
if(kid_need_drink%12==0):
pack_of_drink = int(kid_need_drink/12)
else:
pack_of_drink = int(kid_need_drink/12)+1
if(kid_need_plate%24==0):
pack_of_plates = int(kid_need_plate/24)
else:
pack_of_plates = int(kid_need_plate/24)+1
print("Shopping list: %d pack of hotdogs, %d bag of buns, %d carton
of coke, %d package of paper plates"
%(pack_of_hotdogs,pack_of_buns,pack_of_drink,pack_of_plates))
main()
Please let me know if you have any doubt or modify the answer, Thanks :)