tutor-requ...@python.org编写:
>Send Tutor mailing list submissions to > tutor@python.org > >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 > tutor-requ...@python.org > >You can reach the person managing the list at > tutor-ow...@python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Tutor digest..." > > >Today's Topics: > > 1. Re: html checker (Alan Gauld) > 2. HELP! (Mark Rourke) > 3. python help? (patrick Howard) > > >---------------------------------------------------------------------- > >Message: 1 >Date: Tue, 02 Oct 2012 00:46:31 +0100 >From: Alan Gauld <alan.ga...@btinternet.com> >To: tutor@python.org >Subject: Re: [Tutor] html checker >Message-ID: <k4da0m$919$1...@ger.gmane.org> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed > >On 01/10/12 20:59, Matthew Dalrymple wrote: > >> i don't really understand the pop and push or even stacks for that >> matter...the professor i have isn't really the best at teaching...so if >> anyone could give me a hand with any of this that would be appreciated > >The Raw materials topic in my tutor has a short intro to stacks. It >says, in part: >---------------- >Stack > >Think of a stack of trays in a restaurant. A member of staff puts a pile >of clean trays on top and these are removed one by one by customers. The >trays at the bottom of the stack get used last (and least!). Data stacks >work the same way: you push an item onto the stack or pop one off. The >item popped is always the last one pushed. This property of stacks is >sometimes called Last In First Out or LIFO. One useful property of >stacks is that you can reverse a list of items by pushing the list onto >the stack then popping it off again. The result will be the reverse of >the starting list. Stacks are not built in to Python, VBScript or >JavaScript. You have to write some program code to implement the >behavior. Lists are usually the best starting point since like stacks >they can grow as needed. >----------------- > >As c smith points out, Python lists have a pop/push mechanism as >standard which makes implementing a stack in Python fairly trivial. > >To expand on how reversing works consider pushing the string foo onto >the stack then popping it off again: > >s = 'foo' >stack = [] >stack.push(s[0]) # stack -> ['f'] >stack.push(s[1]) # stack -> ['o','f'] >stack.push(s[2]) # stack -> ['o','o','f'] > >c1 = stack.pop() # stack -> ['o','f'], c1 = 'o' >c2 = stack.pop() # stack -> ['f'], c1 = 'o', c2 = 'o' >c3 = stack.pop() # stack -> [], c1 = 'o', c2 = 'o', c3 = 'f' > >print c1+c2+c3 # prints 'oof' the reverse of s > >HTH, > >-- >Alan G >Author of the Learn to Program web site >http://www.alan-g.me.uk/ > > > >------------------------------ > >Message: 2 >Date: Sun, 30 Sep 2012 15:31:47 -0400 >From: Mark Rourke <mark.rour...@gmail.com> >To: tutor@python.org >Subject: [Tutor] HELP! >Message-ID: <50689e23.4050...@gmail.com> >Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" > >hello, I am a college student in my first year of computer programming, >I was wondering if you could look at my code to see whats wrong with it. > ># Mark Rourke ># Sept 29, 2012 ># Write a program to calculate the sales tax at the rate of 4% and 2% >respectively ># Thereafter compute the total sales tax (sum of the state tax and the >county tax) ># and the total purchase amount (sum of the purchase amount and the >total sales tax). ># Finally, display the amount of purchase, the state sales tax, the >county sales tax, >#the total sales tax and the total amount of the sale. > >#Variable Declarations >#Real purchaseAmount, stateSalesTax, countySalesTax, totalSalesTax, >totalPurchaseAmount >#Constant Real SALES_TAX = 0.4, COUNTY_TAX = 0.02 > >#Display "Input Purchase Amount: $" > >#input the hours worked and hourly wage wage > >SALES_TAX = 0.4 > >COUNTY_TAX = 0.02 >print("----------------------------------------------------------") >print(("This program calculates the sales tax at the rate of 4% and 2% >respectively, as well sum of the state tax")) >print("----------------------------------------------------------") > >purchaseAmount = input("Please input the Purchase Amount: $") > >#Calculate the State Sales Tax, County Sales Tax, Total Sales Tax, Total >Purchase Amount > >purchaseAmount = int(purchaseAmount) > >stateSalesTax = int(purchaseAmount * SALES_TAX) > >countySalesTax = int(purchaseAmount * COUNTY_TAX) > >totalSalesTax = int(stateSalesTax + countySalesTax) > >totalPurchaseAmount = int(purchaseAmount + totalSalesTax) > >#Output the results > >Display ("Purchase Amount:$") purchaseAmount >Display ("The State Sales Tax $") SALES_TAX >Display ("The County Sales Tax: $") COUNTY_TAX >Display ("The Total Sales Tax: $") totalSalesTax >Display ("The Total Amount of the Purchase: $") totalPurchaseAmount > >-- > >Mark Rourke > >T: 705-728-6169 >M: 705-331-0175 >E: mark.rour...@gmail.com > >-------------- next part -------------- >An HTML attachment was scrubbed... >URL: ><http://mail.python.org/pipermail/tutor/attachments/20120930/bcfa6c04/attachment-0001.html> > >------------------------------ > >Message: 3 >Date: Sun, 30 Sep 2012 01:02:57 -0500 >From: patrick Howard <philo...@gmail.com> >To: tutor@python.org >Subject: [Tutor] python help? >Message-ID: <b723a488-ec4b-4e2f-ad02-ef8ab9a94...@gmail.com> >Content-Type: text/plain; charset="windows-1252" > >I have to write a program that takes an input file, with students names and >various grades. >My vindictive teacher also added grades that are not supposed to count, so I >need to pick the grades that are 'HM1-4"; not HW, or TEST or anything else. >Then when these are listed in order with that persons name, sort the list >alphabetically. I know that this is '.sort; >But, how do I get it to sort only names, AND keep the right grades with them. >Below is a list of parameters? Can you help me please? > >-------------- next part -------------- >An HTML attachment was scrubbed... >URL: ><http://mail.python.org/pipermail/tutor/attachments/20120930/e28346b3/attachment.html> >-------------- next part -------------- >A non-text attachment was scrubbed... >Name: parameters.png >Type: image/png >Size: 111589 bytes >Desc: not available >URL: ><http://mail.python.org/pipermail/tutor/attachments/20120930/e28346b3/attachment.png> > >------------------------------ > >Subject: Digest Footer > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor > > >------------------------------ > >End of Tutor Digest, Vol 104, Issue 8 >************************************* _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor