Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

Someone please find the bug in my code for problem sat 2a. I am always getting 78 as a result not 49.

OpenStudy (anonymous):

attached is the code.

OpenStudy (anonymous):

Take a look at your ranges in isSolution. range(1,21) gives you [1,2,3,..,20]. Is there a number of nugget packages that you're missing? On another note, your script is mixing tabs and spaces. That can lead to indentation errors if you mix them in the same block. There are editors that allow you to "view whitespace". The preferred indentation block for Python is four spaces.

OpenStudy (anonymous):

Thanks GabeF for reading my code and telling me the errors. I have made the range(1,21) to range(0,21) but now it is giving me ans 43. is the ans 43 ryt?

OpenStudy (anonymous):

43 is correct. 49 is possible with 2 20's and a 9.

OpenStudy (anonymous):

Thanks dude

OpenStudy (anonymous):

well i have improved the codes efficiency a little bit... pls look at it and give criticism.

OpenStudy (anonymous):

the second attached code.

OpenStudy (anonymous):

This part: if((n-6)==a): return True else: return False is equivalent to: return (n-6)==a

OpenStudy (anonymous):

okk.. i got it. Thanks.

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!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
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!