I'm taking a stab at writing some real-life practical modules based on where I'm at with the lectures and readings. Can anyone help me troubleshoot why I don't get any output with the following:
#exhaustive enumeration test to determine concentration from known absorbance#
conc=0 #starting with a concentration of 0#
Absorbance=(0.0049*conc**3)-(0.0604*conc**2)+(0.0972*conc)+0.6692 #3rd level polynomial curve fit of standard curve#
while Absorbance!=0.69: #absorbance value for which concentration is unknown#
if Absorbance>=0.69: #restrict accuracy of answer#
print conc, 'ug/ml is the concentration'
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 :)
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.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Without seeing the proper indentation, it's tough to troubleshoot Python. One subtle thing that may be a problem is that conc = 0 initializes conc as an integer. I would imagine that it would be promoted by conc += 0.000001, but maybe not. Since the code isn't working, it won't kill anything to change it to:
conc = 0.0
which will init it as a float.
More importantly, the only assignment of Absorbance is before the while loop, so that makes it an endless loop.
There are a few problems here. First, you are not changing Absorbance inside the while loop so it will be and infinite loop. Second, Absorbance is likely never going to equal exactly 0.69 so again infinite loop try <= or put the if inside the while and use a break satement. Third, this would be slow so you would likely want to think about a bisection search or similar aside from simple calculating it which I am sure is not the point.
One more thing, if you are posting code you are likely better off dropping it into a pastebin or similar code site and providing the link.
Not the answer you are looking for? Search for more explanations.
please use a code pasting site:
thanks for the guidance. Is there someplace that I can find syntax definitions for all the commands? For example, when you type raw_input( a pop up appears that defines what information is requested ([prompt])->string. This was really helpful in trying to understand what I'm supposed to be doing.
You can type help() in python for help on something like help(abs). Try also help(__builtins__), lots of scrolling here. You can also check out http://docs.python.org/library/
You can also do dir(__builtins__) for a list of builtin functions and like dir(float) for methods you can use with float. etc
the documentation.s should be installed on your computer. the Tutorial is a must. for windows and Idle, F1 will bring up the documentation - i find this version easier to use than the online version. can't say about linux versions or ipython.
and the beginners links on the wiki first page have good stuff