inicoud 3 years ago #6.00x 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# conc=conc+0.000001 if Absorbance>=0.69: #restrict accuracy of answer# print conc, 'ug/ml is the concentration'

1. rsmith6559

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.

2. msmithhnova

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.

3. msmithhnova

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.

4. bwCA

5. inicoud

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.

6. msmithhnova

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/

7. msmithhnova

You can also do dir(__builtins__) for a list of builtin functions and like dir(float) for methods you can use with float. etc

8. bwCA

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. http://docs.python.org/

9. bwCA

and the beginners links on the wiki first page have good stuff http://wiki.python.org/moin/