Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

Problem: There are ten hot dogs in a package of hot dogs and eight buns in a package of buns. Return the number of packages of hot dog buns needed for the given number of packages of hot dogs (assuming one hot dog per bun). Note: you should import math in order to use a function from that module.

OpenStudy (anonymous):

My code: def bun_packages_required(hotdog_packages_given): """(int) -> int Return the number of bun packages required based off the number of hotdog packages given. (Assuming there is one hot dog per bun) bun_packages_required(4) 5.0 bun_packages_required(8) 10.0 bun_packages_required(12) 15.0 """ hotdogs_in_package = 10 *hotdog_packages_given buns_in_package = 8 return (hotdogs_in_package/buns_in_package)

OpenStudy (anonymous):

Teachers Comments: The following test cases failed: | | test_bun_packages_required_leftover_few - IncorrectReturnValue | | If x is a just over a multiple of 8, what do you expecte the value of | | >>> bun_packages_required_no_buns(x) | | to be? | | test_bun_packages_required_leftover_many - IncorrectReturnValue | | If x is a not quite a multiple of 8, what do you expect the value of | | >>> bun_packages_required_no_buns(x) | | to be?

OpenStudy (anonymous):

this is my last problem if anybody could help me figure out what needs to be changed in my code in order to work

OpenStudy (anonymous):

So let me get this straight... if you have 2 packs of hot dogs = 20 hot dogs, you will need 20 buns which you can get from 3 packs of buns... which contains 24 buns.... should the answer then be 3 (packs of buns)?

OpenStudy (anonymous):

i guess and thered be a left over amount of buns that go unused too right? which is what i assume hes referring to. in my equation when i plug in 2 for the pack of hotdogs, ill recieve 2.50 i think

OpenStudy (anonymous):

which is technically right but its impossible to buy 2.5 packages im assuming

OpenStudy (anonymous):

should i then put something in the code to round my answer?

OpenStudy (anonymous):

then what you can do is get the number of bun packs --> number of hot dog packs * number of hot dogs per pack / number of buns per pack. then use math.ceil to get the number rounded up to the nearest integer!

OpenStudy (anonymous):

alright! that sounds good cause that way i can import math as well okay and what about the whole concept of no buns i dont get why he asking waht i think that will be, should i just write a comment in the string i have at teh beginning of the code?

OpenStudy (anonymous):

no idea about the teachers comments. is that all the info?

OpenStudy (anonymous):

ye thats everything

OpenStudy (anonymous):

so what are these test cases? bun_packages_required_no_buns and test_bun_packages_required_leftover_many ?

OpenStudy (anonymous):

and test_bun_packages_required_leftover_few

OpenStudy (anonymous):

those werent alll the test cases, just the ones that my code failed, he didnt tell me the other tests

OpenStudy (anonymous):

you don't have access to these test cases? you don't know what values the teacher is using?

OpenStudy (anonymous):

no, not at all, all i know is what he sends me

OpenStudy (anonymous):

it doesn't really make sense! no idea mate... just go with the math.ceil or be clever and say that if there is only one hot dog left i boil it and have it with my beans! hahaha

OpenStudy (anonymous):

LMAO ill do that, thanks a lot for the help bro. he gonna premark it again, so ill let you know what comes up

OpenStudy (anonymous):

cool!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!