I'm baaaack! I kept getting ideas for what I (and some of you) thought was a finished yen-USD.py. And some of the good advice I got was to move on to other things. I did for a while, but I kept thinking up new revisions. The script has more than doubled in length. I'd previously posted v4 at <http://www.rcblue.com/Python/yen-USD-v3.txt>.
Here's v10: <http://www.rcblue.com/Python/yen-USD-v10.txt> New functions: again() divide2StringDecimals() multiply2StringDecimals() roundNumber() -- replaced setPrecision() printVariablesNotChanging() formatNumber() removeCommasFromNumbers() rather radically revised function: again() -- offers several more choices The most important change is that because I realized I wanted the program to be a general solution and give accurate answers for even very large amounts of Yen or USD, I decided to operate with (number) strings only, except when necessary in getRate() and getAmount() to error check user inputs. Those floats are not used in the calculations of Yen or USD. The most difficult function for me to write was roundNumber(), which of course couldn't rely on the use of the built-in round() or the formatting of strings (see the line "format = "%." + str(precision) + 'f'" in setPrecision() in v3). Lack of experience with the slicing of lists caused many headaches. I didn't succeed in debugging until I put in print statements wherever a value changes, and trying many different integer strings and places (the arguments of roundNumber()). A good lesson, I think. I hope some of the Tutors will take a look at the new functions, especially roundNumber(). Did I just reinvent the wheel? Should it be broken up into more sub-functions (there's only one now)? It works, but is it Pythonic? Etc. I'm also curious about multiply2StringDecimals() and divide2StringDecimals(). Again, am I reinventing the wheel with these? Is there a simpler way to multiply and divide big decimals with precision? Thanks in advance, Dick Moores _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor