A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

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

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    If you have another question on what I did or whatever feel free to ask.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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!

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.