Changeset 391 for python/trunk/Demo/scripts/beer.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Demo/scripts/beer.py
r2 r391 1 1 #! /usr/bin/env python 2 2 3 # By GvR, demystified after a version by Fredrik Lundh. 4 3 5 import sys 6 4 7 n = 100 5 if sys.argv[1:]: n = int(sys.argv[1]) 8 if sys.argv[1:]: 9 n = int(sys.argv[1]) 10 6 11 def bottle(n): 7 12 if n == 0: return "no more bottles of beer" 8 13 if n == 1: return "one bottle of beer" 9 14 return str(n) + " bottles of beer" 10 for i in range(n): 11 print bottle(n-i), "on the wall," 12 print bottle(n-i) + "." 15 16 for i in range(n, 0, -1): 17 print bottle(i), "on the wall," 18 print bottle(i) + "." 13 19 print "Take one down, pass it around," 14 print bottle( n-i-1), "on the wall."20 print bottle(i-1), "on the wall."
Note:
See TracChangeset
for help on using the changeset viewer.