A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

Pset2part3 I've got a working piece of code for it but I looked up the solution for it and other people say its 43. Why is my code giving me 50? http://dpaste.com/hold/525967/

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

    hey kNicola are the two study groups different you responded to the last post on retro.openstudy, is this a different study group?

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

    add print numSmall, numMedium, numLarge to your code. There is an obvious error when it comes to calculating numSmall.

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

    It stems from your calculation of numLeft.

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

    I don't get what's wrong with it that is why on the next line i divide by 6? and where do you want me to add the print function?

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

    Add the print function right after numSmall=numSmall/6

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

    I added the print but its a huge loop and is giving me a lot of numbers which i don't want to sit and test by hand.

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

    That's fine, but you should have noticed that numSmall routinely went into the negatives, while numMedium and numLarge functioned correctly.

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

    Yes I did but in line i have a checker to take out negative solutions.

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

    line 9

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

    Oh, I know what the problem is. Sorry for all of this. Your counter is set too high. It's supposed to be 5 not 6. def mcdonalds(): count=0 numNuggets=1 while count<5: x=solution(numNuggets) if x==1: count=count+1 else: count=0 numNuggets=numNuggets+1 print numNuggets mcdonalds()

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

    Thanks I actually noticed this when I was debugging but I did it the other way and made my counter start at 1. But I forgot to change the resets to 1. Thank you so much I have been stuck on this problem for a few days.

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

    Should i post my final solution so other people can see what I did?

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

    Hah, no problem. I felt really dumb there for a little while. You had your checking system set up differently from mine so I thought it was a problem with it. The negatives definitely threw me off. Sure, post it up.

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

    Yeah everyone has there own style of coding. So its not your fault it's more so my fault for not putting in comments to help out.

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

    For anyone who is working on this problem and needs a reference here is my completed code. http://dpaste.com/hold/525984/

  16. 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.