Re: Programming Issues
On 09/19/2012 07:01 PM, Nathan Spicer wrote: Dave, You sent this response privately, which isn't the way the mailing list works. Private responses are good for thank-yous and for personal remarks of no interest to others. But you're short-circuiting the helping process if you don't let everyone else see what you're saying here. I'll forward my response to the list, so others can jump in. You also top-posted, rather than putting your remarks after what you're quoting. I'm running Python 3.2. I think doing raw input is what the instructor is looking for. What version of Python does the instructor think you're using? raw_input is not in Python 3.2, being renamed to input(). The 2.x logic of input() is fortunately gone, as it was quite unsafe. I know a need to do a loop, but the problem is i don't know ho to do this. An open-ended loop can be done with the while statement. What I mean by open-ended is that you have no way of predicting how many times it will loop, because it depends on data you don't have ahead of time. The other type of loop is the for loop, where the loop will normally progress till it processes all items in a sequence. A while loop might look something like: def ask_user(): amount = get_amount() while amount != 0: do_some_stuff(amount) amount = get_amount() print done with program # And your top-level code might look something like: if __name__ == __main__: ask_user() If that makes sense to you, then write the functions that this one calls. If you don't understand this loop, then ask us to elaborate. And if you don't understand what this while statement itself does, ask your professor. There is no code, because i'm not sure how or what to write. So far we've done simple inputs. Are you aware of any examples similar to my problem, that i could look at and possibly base my program accordingly? Thanks, Nathan -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Issues
Ask the user for the amount of change expressed in cents. Your program must compute and display the number of half-dollars, quarters, dimes, nickels, and pennies to be returned. Return as many half-dollars as possible, then quarters, dimes, nickels, and pennies, in that order. Your program must allow the user to continue entering different amounts of change until they enter 0 to indicate they are finished. If the user enters a negative number, inform them of their mistake and ask them to enter a correct value. Perhaps you can start with pseudo-code (http://en.wikipedia.org/wiki/Pseudo_code) and ask for help writing that in Python. I'll get you started. Ask for a number. If number = 0, stop. If number 0, ask again. With values 50, 25, 10, 5 and 1: if number value: coincount = integer portion of number divided by value print coincount, value remaining number = ... I've broken the pseudo-code into two parts because they are, in some sense, different programs. You might try to write one, then the other. In other words, starting by writing this in Python: Ask for a number. If number = 0, stop. If number 0, ask again. If number 0, print number and quit. -- http://mail.python.org/mailman/listinfo/python-list
Fwd: Programming Issues
-- Forwarded message -- From: Nathan Spicer njsp...@gmail.com Date: Tue, Sep 18, 2012 at 8:32 PM Subject: Programming Issues To: webmas...@python.org Hello, My name is Nathan Spicer. I'm taking a computer programming class using python. I have a project that's due in a week and I'm not certain how to d this. I'm totally new to this form of programming. I've stated the scope of the project below. Any form of help would be great. Ask the user for the amount of change expressed in cents. Your program must compute and display the number of half-dollars, quarters, dimes, nickels, and pennies to be returned. Return as many half-dollars as possible, then quarters, dimes, nickels, and pennies, in that order. Your program must allow the user to continue entering different amounts of change until they enter 0 to indicate they are finished. If the user enters a negative number, inform them of their mistake and ask them to enter a correct value. -Code that is formatted to be easy to read Thank you for your time, Nathan Spicer -- http://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Programming Issues
On 09/18/2012 08:47 PM, Nathan Spicer wrote: -- Forwarded message -- From: Nathan Spicer njsp...@gmail.com Date: Tue, Sep 18, 2012 at 8:32 PM Subject: Programming Issues To: webmas...@python.org Hello, My name is Nathan Spicer. I'm taking a computer programming class using python. I have a project that's due in a week and I'm not certain how to d this. I'm totally new to this form of programming. I've stated the scope of the project below. Any form of help would be great. Ask the user for the amount of change expressed in cents. Your program must compute and display the number of half-dollars, quarters, dimes, nickels, and pennies to be returned. Return as many half-dollars as possible, then quarters, dimes, nickels, and pennies, in that order. Your program must allow the user to continue entering different amounts of change until they enter 0 to indicate they are finished. If the user enters a negative number, inform them of their mistake and ask them to enter a correct value. -Code that is formatted to be easy to read Thank you for your time, Nathan Spicer What version of Python are you learning? And you're stuck where? There are lots of ways to ask a user a question, ranging from raw_input() to presenting a wxPython dialog box. The choice depends on what version you're using, and what GUI library if any you have available. Then you have to validate the string you get, and then do some computations, displaying the result. The whole thing needs to be inside a loop. Show us the code you've got so far, and indicate where the exception is happening, with full traceback. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list