Language Python
(standard version)
| Date: | 04/20/05 |
| Author: | Fredrik Lundh |
| URL: | n/a |
| Comments: | 0 |
| Info: | n/a |
| Score: |
#!/usr/local/bin/python
# python version of 99 bottles of beer, compact edition
# by Fredrik Lundh (fredrik_lundh@ivab.se)
def bottle(n):
try:
return { 0: "no more bottles",
1: "1 bottle"} [n] + " of beer"
except KeyError: return "%d bottles of beer" % n
for i in range(99, 0, -1):
b1, b0 = bottle(i), bottle(i-1)
print "%(b1)s on the wall, %(b1)s,\n"\
"take one down, pass it around,\n"\
"%(b0)s on the wall." % locals()
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| This example demonstrates the simplicity | Gerold Penz | 07/23/05 | 9 | |
| Creative version | Schizo | 11/06/05 | 16 | |
| minimal version | Oliver Xymoron | 04/20/05 | 3 | |
| Advanced, extensible beer/wall framework | Jamie Turner | 05/17/06 | 4 | |
| Exception based | Michael Galpin | 02/08/08 | 0 | |
| Using a iterator class | Eric Moritz | 01/20/06 | 2 | |
| using lambda in LISP style | J Adrian Zimmer | 11/14/06 | 0 | |
| Fully compliant version | Ricardo Garcia Gonzalez | 01/15/06 | 6 | |
| New conditional expressions in 2.5 | Ezequiel Pochiero | 12/18/06 | 1 | |
| functional, w/o variables or procedures | Ivan Tkatchev | 07/14/05 | 1 | |
| minimal version with singular | Emlyn Jones | 06/13/05 | 3 |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments