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

im still on ps12 #4. I made some modifications but Im not getting the right answer..... can anybody help me spot the 'bug'? http://dpaste.com/hold/592934/

OpenStudy (anonymous):

what kind of output are you getting?

OpenStudy (anonymous):

I'm getting numbers beyond maxPop in my graph, but i thought I was preventing this with lines 491-492..

OpenStudy (anonymous):

On line 481, popDen is probably always 0. On line 537 you forgot to actually call update.

OpenStudy (anonymous):

On line 334 you forgot the self. to call the method getResistance

OpenStudy (anonymous):

As an aside, avoid using from module import * Always import exactly what you need/want so as not to clutter your name space.

OpenStudy (anonymous):

hey polpak! thanks for replying! I finally discovered the core cause of why my output was wrong: in my for loop on lines 546, 547, I had forgotten to increment mutationVariable(line 545) by one each time through the loop and was not getting the mean value of the resistant viruses I had. Oh and I did catch most of the other stuff as I went through and tested/debugged my code except my forgetting to call update in line 537 ( i couldn't figure out why my graph was flat lining after 150... ). Thanks a Ton! I still remember when you helped me with the primes problem....haha

OpenStudy (anonymous):

It's been a while =) I've mostly been helping out over in Mathematics. But I still pop by here now and then.

OpenStudy (anonymous):

here's my fixed code: http://dpaste.com/593185/

OpenStudy (anonymous):

also, what do you mean by importing exactly what I need? Do you mean something like from math import sqrt ?

OpenStudy (anonymous):

yes exactly. import * is bad because any variable or function or whatever that is in the module suddenly becomes part of your module.

OpenStudy (anonymous):

Oh ok. I'll try to do that from now on :)

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!
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!