Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion ten small Python programs

View parsed - Show only message text

Path: g2news1.google.com!postnews.google.com!q66g2000hsg.googlegroups.com!not-for-mail
From: BartlebyScrivener <bscrivene...@gmail.com>
Newsgroups: comp.lang.python
Subject: Re: ten small Python programs
Date: 27 May 2007 05:45:44 -0700
Organization: http://groups.google.com
Lines: 35
Message-ID: <1180269944.944150.135930@q66g2000hsg.googlegroups.com>
References: <mailman.8216.1180205410.32031.python-list@python.org>
NNTP-Posting-Host: 68.13.72.138
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1180269945 12782 127.0.0.1 (27 May 2007 12:45:45 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sun, 27 May 2007 12:45:45 +0000 (UTC)
In-Reply-To: <mailman.8216.1180205410.32031.python-list@python.org>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070310 Firefox/2.0.0.3 (Debian-2.0.0.3-1),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: q66g2000hsg.googlegroups.com; posting-host=68.13.72.138;
   posting-account=sIWf_w0AAAA3kNSH2l-i5wJAjZxAFDpd

On May 26, 1:43 pm, Steve Howell <showel...@yahoo.com> wrote:

>     ------
>     parentRabbits, babyRabbits = (1, 1)
>     while babyRabbits < 100:
>         print 'This generation has %d rabbits' %
> babyRabbits
>         parentRabbits, babyRabbits = (babyRabbits,
> parentRabbits + babyRabbits)
>
>     ------
>     # def defines a method in Python
>     def tax(itemCharge, taxRate = 0.05):
>         return itemCharge * taxRate
>     print '%.2f' % tax(11.35)
>     print '%.2f' % tax(40.00, 0.08)
>

For the person new to programming (doesn't come from C or other
languages), I think you need to add a separate explanation of string
formatting and how it works, or at least add a comment that tells them
you are using string formatting so that they can search and find out
how it works. If your aim is to teach simple programming concepts, why
confuse them so early on with fancy interpolation?

Something like

# uses Python string formatting
# http://docs.python.org/lib/typesseq-strings.html

but really I think it will just be a distraction

rd



Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google