Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion ten small Python programs
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
BartlebyScrivener  
View profile  
 More options May 27 2007, 10:45 pm
Newsgroups: comp.lang.python
From: BartlebyScrivener <bscrivene...@gmail.com>
Date: 27 May 2007 05:45:44 -0700
Local: Sun, May 27 2007 10:45 pm
Subject: Re: ten small Python programs
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

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