anonymous
  • anonymous
Problem Set 2, #3
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
1 Attachment
anonymous
  • anonymous
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/assignments/pset2.pdf
anonymous
  • anonymous
for some reason it isnt working, when launched it just remains a blank screen

Looking for something else?

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

More answers

anonymous
  • anonymous
I just did it this morning. I'll take a look at it.
anonymous
  • anonymous
The only I see wrong right off the back is you never assigned in in your test statement to fix that you can add 1 argument to your test function which would be n. I'm going to try it now and tell you if it works.
anonymous
  • anonymous
You also didn't assign count in test(). I don't understand what you were trying to do with count in test I don't think those do anything
anonymous
  • anonymous
ok wait let me upload my most recent one
1 Attachment
anonymous
  • anonymous
ok sorry some indentation issues...heres the most recent one, it just returns -5
1 Attachment
anonymous
  • anonymous
ok still in test you are not giving it an argument therefore n is not assigned inside the function test(). Your argument should be test(n).
anonymous
  • anonymous
ok now it just returns -5 once...i guess thats an improvement
anonymous
  • anonymous
In your test function the body of your else statement should be even with "for a in range(0,n)" because the way yours is setup it will only check the first possible solution in stead of all solutions in (0,n) and would you rather me explain everything or post a fixed code.
anonymous
  • anonymous
can you please post a fixed code then if i have any questions ill ask you?
anonymous
  • anonymous
Yea one sec lemme do it really quick.
anonymous
  • anonymous
and i know some people use tuples or lists on this problem, thats not needed right?
anonymous
  • anonymous
No it can be done either way http://dpaste.com/hold/529001/
anonymous
  • anonymous
Do you want to see it done with a list?
anonymous
  • anonymous
no thanks, i havent tried it yet so i'd rather attempt on my own but thanks for all the help!
anonymous
  • anonymous
so basically i just had to get rid of the else statement because it was causing it to check for only one value?
anonymous
  • anonymous
you had to add the argument to test which was test(n). I deleted the print n-5 in test there was no point to it. Your return n-5 should only be return n. I also deleted your n=0 its outside the function and isn't doing anything.
anonymous
  • anonymous
sorry I forgot to comment out the wrong stuff instead of deleting it.
anonymous
  • anonymous
its fine i understood it all, main thing was deleting the else statement...but why exactly do i need an arguement for test?
anonymous
  • anonymous
try it without the arguments you get a name error because functions have local variables. so unless you tell it to take an argument none of the variables you are already using will carry over. Therefor the n in cheese() will not moved to test() unless you tell it to by putting test(n).
anonymous
  • anonymous
Did that help?
anonymous
  • anonymous
yeah thanks
anonymous
  • anonymous
thanks btw im 16 so we are the young ones of this school lolz
anonymous
  • anonymous
Yeah, no problem and thats cool haha I'll be 16 in June.

Looking for something else?

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