Language Python
(New conditional expressions in 2.5)
| Date: | 12/18/06 |
| Author: | Ezequiel Pochiero |
| URL: | n/a |
| Comments: | 0 |
| Info: | http://www.python.org |
| Score: |
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
"""99 Bottles of Beer, by Ezequiel Pochiero. (Requires Python 2.5)"""
song=''
for n in range(99,0,-1):
s1= `n`+(' bottles' if n!=1 else ' bottle')
s2 = (`n-1` if n-1!=0 else 'no more')+(' bottles' if n!=2 else ' bottle')
song += '%s of beer on the wall, %s of beer. \n\
Take one down and pass it around, %s of beer on the wall.\n\n' % (s1,s1,s2)
song += 'No more bottles of beer on the wall, no more bottles of beer. \n\
Go to the store and buy some more, 99 bottles of beer on the wall.'
print song
Download Source | Write Comment
Alternative Versions
| Version | Author | Date | Comments | Rate |
|---|---|---|---|---|
| Creative version | Schizo | 11/06/05 | 11 | |
| This example demonstrates the simplicity | Gerold Penz | 07/23/05 | 4 | |
| Advanced, extensible beer/wall framework | Jamie Turner | 05/17/06 | 3 | |
| minimal version | Oliver Xymoron | 04/20/05 | 3 | |
| Fully compliant version | Ricardo Garcia Gonzalez | 01/15/06 | 5 | |
| Using a iterator class | Eric Moritz | 01/20/06 | 2 | |
| using lambda in LISP style | J Adrian Zimmer | 11/14/06 | 0 | |
| functional, w/o variables or procedures | Ivan Tkatchev | 07/14/05 | 1 | |
| Exception based | Michael Galpin | 02/08/08 | 0 | |
| minimal version with singular | Emlyn Jones | 06/13/05 | 2 |
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