| |
comp.lang.python |
On May 26, 1:43 pm, Steve Howell <showel...@yahoo.com> wrote: > ------ Something like # uses Python string formatting but really I think it will just be a distraction rd
> 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)
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?
# http://docs.python.org/lib/typesseq-strings.html