Will anybody review my problem set 2 for correctness? capture = () x = input("Package size 1: ") y = input("Package size 2: ") z = input("Package size 3: ") for n in range(1,201): can_buy = 0 for a in range(0,(n/x)+1): for b in range(0,(n/y)+1): for c in range(0,(n/z)+1): if x*a + y*b + z*c == n: can_buy = 1 print n, " can by bought: ",a,b,c if can_buy == 0: print n, " cannot be bought" capture += (n,) print "Largest number of McNuggets that cannot be bought in exact quantity: ",capture

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

Will anybody review my problem set 2 for correctness? capture = () x = input("Package size 1: ") y = input("Package size 2: ") z = input("Package size 3: ") for n in range(1,201): can_buy = 0 for a in range(0,(n/x)+1): for b in range(0,(n/y)+1): for c in range(0,(n/z)+1): if x*a + y*b + z*c == n: can_buy = 1 print n, " can by bought: ",a,b,c if can_buy == 0: print n, " cannot be bought" capture += (n,) print "Largest number of McNuggets that cannot be bought in exact quantity: ",capture

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

Hey your code works but on the very last line you don't want it to print all the captures only the last so change capture to capture[-1] the negative one represents the last place in the tuple. Also your range is really high so either you can take out the print statements and it will run faster or make your range like (1,50) I already know the answer that's why I say 50 but yes normally you would need a higher range.
If you have another question on what I did or whatever feel free to ask.
Hey Onyx, thanks a lot. I'm now your fan. As for the last line, I think the [-1] got cut off by the chat box without me realizing it!

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question