Thank you message 4 this has solved my problem I can now work out the next part of my program. Thank you so much.
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Saturday, 16 April 2011 8:47 AM To: [email protected] Subject: Tutor Digest, Vol 86, Issue 56 Send Tutor mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/tutor or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of Tutor digest..." Today's Topics: 1. Help to explain commenting (Andr?s Chand?a) 2. Re: Python on TV (Alan Gauld) 3. Help - accumulator not working (Lea) (Lea Parker) 4. Re: Help - accumulator not working (Lea) (Joel Goldstick) ---------------------------------------------------------------------- Message: 1 Date: Fri, 15 Apr 2011 18:21:43 +0200 From: "Andr?s Chand?a" <[email protected]> Subject: [Tutor] Help to explain commenting Message-ID: <[email protected]> Content-Type: text/plain; charset="iso-8859-1" Hello everybody, I could finally complete succesfully the code I was working with. As I'm quite new to python, many of the things I have in my code are copied from different sources, and I do not undertand all of them, well, I have to deliver this code for a project, and in the best documented way that I could, I already commented all that I know, and I suppouse wrongly in some parts. So the request is, if you can take a look at the code, comment the parts that are not yet commented, correct the errors, and propouse some improvement in the parts you think diserves it. I attach the code in a tgz file, if the attached can not be seen then this link: http://www.chandia.net/compart/NMT-2.4-20110415.tar.gz Thanks in advance to all of you and to the people that already helped me. _______________________ ????????????andr?s chand?a P No imprima innecesariamente. ?Cuide el medio ambiente! -------------- next part -------------- A non-text attachment was scrubbed... Name: NMT-2.4-20110415.tar.gz Type: application/x-gzip Size: 4177 bytes Desc: not available URL: <http://mail.python.org/pipermail/tutor/attachments/20110415/937a8c20/attach ment-0001.bin> ------------------------------ Message: 2 Date: Fri, 15 Apr 2011 20:35:14 +0100 From: "Alan Gauld" <[email protected]> To: [email protected] Subject: Re: [Tutor] Python on TV Message-ID: <[email protected]> Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response "bob gailer" <[email protected]> wrote >> The show should be here - Pause at 1 minute 20 for the Python >> screnshot: >> >> http://fwd.channel5.com/gadget-show/videos/challenge/surprise-special >> -part-4 > > I am told "the video ... cannot be viewed from your currrent country > ..." I don't know if YouTube will be any more obliging but try this: http://www.youtube.com/watch?v=oDNZP1X30WE&list=SL Python can be seen at around 29 mins 45 secs... Enjoy (I hope) Alan G. ------------------------------ Message: 3 Date: Sat, 16 Apr 2011 07:52:22 +1000 From: "Lea Parker" <[email protected]> To: <[email protected]> Subject: [Tutor] Help - accumulator not working (Lea) Message-ID: <[email protected]> Content-Type: text/plain; charset="us-ascii" Hello I am trying to create this program for a uni assignment. I cannot get it to add the expenses to the accumulator I have set. Would you mind having a look and letting me know if I have something in the wrong place or indented incorrectly. Perhaps I am missing something. There could be other things wrong but I need to fix this first and then I can focus on the next thing. I have difficulty trying to fix lots of things at once so if you could just comment on the problem and I will ask again if I can't work out the next problem I have. I like to have a go myself first. J My code is: """This program is to calculate if the user is over or under budget for the month""" def main(): # Create an accumulator total_expense = 0.0 # Ask user for the monthly budget budget = float(raw_input('Enter the amount of your budget for the month: $')) # Calculate a series of expenses expense = float(raw_input('Enter your first expense $')) # Accumlate expense total_expense = total_expense + expense # Continue processing as long as the user # does not enter 0 while expense != 0: #Get another expense expense = float(raw_input('Enter the next expense or 0 to finish $')) #Calculate surplus surplus = budget - total_expense #Display results print 'Your total expenses for the month $', total_expense print 'Your surplus amount after expenses $', surplus # Call the main function. main() Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/tutor/attachments/20110416/b09f472e/attach ment-0001.html> ------------------------------ Message: 4 Date: Fri, 15 Apr 2011 18:47:21 -0400 From: Joel Goldstick <[email protected]> To: [email protected] Subject: Re: [Tutor] Help - accumulator not working (Lea) Message-ID: <[email protected]> Content-Type: text/plain; charset="utf-8" On Fri, Apr 15, 2011 at 5:52 PM, Lea Parker <[email protected]> wrote: > Hello > > > > I am trying to create this program for a uni assignment. I cannot get > it to add the expenses to the accumulator I have set. Would you mind > having a look and letting me know if I have something in the wrong > place or indented incorrectly. Perhaps I am missing something. > > > > There could be other things wrong but I need to fix this first and > then I can focus on the next thing. I have difficulty trying to fix > lots of things at once so if you could just comment on the problem and > I will ask again if I can?t work out the next problem I have. I like to have a go myself first. > J > > > > My code is: > > > > """This program is to calculate if the user is over or under budget > > for the month""" > > > > > > def main(): > > > > # Create an accumulator > > total_expense = 0.0 > > > > # Ask user for the monthly budget > > budget = float(raw_input('Enter the amount of your budget for the > month: $')) > > > above here is good > > > # Calculate a series of expenses > > expense = float(raw_input('Enter your first expense $')) > > > I would remove the input above and move it to your loop. > # Accumlate expense > > total_expense = total_expense + expense > > above you don't need this since you haven't added anything yet (see below) > > I set expense to 1 just to get the loop started. It could be anything but 0 > # Continue processing as long as the user > > # does not enter 0 > > while expense != 0: > > > > #Get another expense > > expense = float(raw_input('Enter the next expense or 0 to > finish > $')) > > > > #Calculate surplus > > surplus = budget - total_expense > > > > #Display results > > print 'Your total expenses for the month $', total_expense > > print 'Your surplus amount after expenses $', surplus > > > > # Call the main function. > > main() > > > > Thank you. > > _______________________________________________ > Tutor maillist - [email protected] > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > def main(): # Create an accumulator total_expense = 0.0 # Ask user for the monthly budget budget = float(raw_input('Enter the amount of your budget for the month: $')) expense = 1 total_expense = 0 while expense != 0: #Get another expense expense = float(raw_input('Enter the next expense or 0 to finish $')) #Calculate surplus total_expense = total_expense + expense surplus = budget - total_expense print budget, total_expense #Display results print 'Your total expenses for the month $', total_expense print 'Your surplus amount after expenses $', surplus main() Good luck with your course -- Joel Goldstick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/tutor/attachments/20110415/1b6d83b6/attach ment.html> ------------------------------ _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor End of Tutor Digest, Vol 86, Issue 56 ************************************* _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
