Question

In: Computer Science

I am trying to figure out the best way to solving a problem in the language...

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()

Solutions

Expert Solution

#*************************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 :)


Related Solutions

I am trying to figure out the social security tax for the employees in this problem,...
I am trying to figure out the social security tax for the employees in this problem, becuase I have to post it all in a chart. I have tried multiplying by the 6.2 tax rate but my program says my answer is wrong. So, is there a different way to calculate social security tax or is there something that I am missing that the problem is asking me to do? I am not looking for answers, but just a clear...
I cannot figure out this problem, I've made a few attempts at solving it. I could...
I cannot figure out this problem, I've made a few attempts at solving it. I could really use some help. The question is : 75.00 mL of 0.225 M HNO2 is titrated to its equivalence point with 0.100 M NaOH. What is the pH at its' equivalence point? Please help!
I am trying to figure out the probability, expected value, variance, and standard deviation for a...
I am trying to figure out the probability, expected value, variance, and standard deviation for a series of dice rolls. For example, if I roll a six-sided die in an attempt to roll a 1, and it takes me 7 rolls before a 1 appears, what are those answers? I have figured out the probability equation: P(P-1)^x where x is the number of rolls - 1 so for 7 rolls the probability would be: 1/6(1-1/6)^6 = 0.05581632... Further where I...
I am trying to figure out which test analysis to use for my research questions. I...
I am trying to figure out which test analysis to use for my research questions. I was thinking about think about multivariate because of the number of variable being addressed in the study but there is also the possibility to use univariate to address each question. What are the current levels of police satisfaction in CMPD jurisdictions? What is the public’s perception of crime in CMPD jurisdictions? Does “hot spot” policing reduce crime in CMPD jurisdictions? How does broken windows...
I am having problems trying to figure out what information to pull to prepare budgets
I am having problems trying to figure out what information to pull to prepare budgets
I am trying to figure out how to calculate the sustainable earnings: Permanent Versus Transitory Earnings...
I am trying to figure out how to calculate the sustainable earnings: Permanent Versus Transitory Earnings Entrust, Inc., is a global provider of security software; it operates in one business segment involving the design, production, and sale of software products for securing digital identities and information. The consolidated statements of operations for a three-year period (all values in thousands) follows. On January 1, Year 1, the Entrust common shares traded at $10.40 per share; by year end Year 3, the...
Hi! I am trying to compare 2 files, and figure out which lines from infile2 are...
Hi! I am trying to compare 2 files, and figure out which lines from infile2 are also in infile1, and output the line index, from infile2, of common lines. I would also want to see which lines (actual string line) are common. Below is my c++ program, and I am not sure what I am doing wrong. Can someone tell me what I am doing wrong and how it can be fixed? _________________________________________________________main.cpp #include<iostream> #include<fstream> #include<vector> #include<string> using namespace std;...
Every airline in the world is trying to figure out how best to respond to an...
Every airline in the world is trying to figure out how best to respond to an unrest in the world amid ever-evolving security threats. No airline is immune to this threat. Compare and contrast security strategies used in other countries to the procedures used here in the USA. Cite specific examples.
Hi I am having the following problem. At the moment I am trying to create a...
Hi I am having the following problem. At the moment I am trying to create a bode plot for the following function. G(s)=(Ks+3)/((s+2)(s+3)) Note: Not K(s+2)! I then want to plot multiple bode plots for various values of K. Eg. 1,2,3, etc. I am having two separate issues. 1. How do I define the TF with a constant K in the location required (a multiple of s in the numerator) 2. How do I create multiple bode plots for values...
I was trying to figure out the flow of electrons in a battery connected to a...
I was trying to figure out the flow of electrons in a battery connected to a circuit. Conventionally, current is from the (+) terminal to the (-) terminal of the battery. Realistically it flows the other way round; from the (-) terminal to the (+) terminal. My question is, assuming electron flow is from the (-) terminal, would the battery's cathode be located at the (+) terminal and it's anode at the (-) terminal or would it be vice versa?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT