On Thu, 13 Oct 2005 [EMAIL PROTECTED] wrote:
> amount is supposed to equal fine because there are a couple of different > fines. there is a fine for going over 90mph that includes a penalty and > then there is a fine for just going over the speed limit as long as it > is under 90. Hi Andradel, Because this is homework, we can not really give you specific reasons why your program isn't working: we can only give you indirect strategies and advice. Has your teacher talked about using and writing functions yet? It looks like you have a single main() function to do all the work, and since it's monolithic, it's hard to test effectively. It would be very useful if you had a separate 'get_fine()' function that took the legal and clocked speed limit values, and returned the fine from those values. If you had such a function, then you'd be able to more easily test it with hardcoded values, like: ###### assert get_fine(100, 50) == 500 ###### so you don't have to continue retyping your input every time you make a change to your program. In fact, I'd recommend temporarily disabling user input for the moment, at least until you get a get_fine() function that passes simple tests. Otherwise, what's the point of asking the user for input, if it always returns a weird answer? If you have questions about this "test-first" approach, feel free to ask about it on the list, and I'm sure folks on the list can give a few examples that demonstrate the technique. Also, consider simplifying the problem statement: it looks like you're trying to handle too much at once, with the end result that none of it is really working right. It's easier to take a program that is running correctly and then adding more things to it, than to take a program that isn't working, and trying to make it correct. Concretely: can you write a get_fine() function that doesn't care about the >90mph penalty first? As it stands, your program will give very strange results even if there is no speeding going on --- why should the police owe the speeder money? _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor