annotate Demo/scripts/beer.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 272eccc573e2
children 34999a1aea9b 7d16b42fcdbd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9669
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 #! /usr/bin/env python
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # By GvR, demystified after a version by Fredrik Lundh.
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 import sys
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 n = 100
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 if sys.argv[1:]: n = int(sys.argv[1])
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 def bottle(n):
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 if n == 0: return "no more bottles of beer"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 if n == 1: return "one bottle of beer"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 return str(n) + " bottles of beer"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 for i in range(n):
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 print bottle(n-i), "on the wall,"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 print bottle(n-i) + "."
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 print "Take one down, pass it around,"
272eccc573e2 100 bottles of beer on the wall example.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 print bottle(n-i-1), "on the wall."