Language Python
(New conditional expressions in 2.5)
| Date: | 12/18/06 |
| Author: | Ezequiel Pochiero |
| URL: | n/a |
| Comments: | 1 |
| 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 |
|---|---|---|---|---|
| This example demonstrates the simplicity | Gerold Penz | 07/23/05 | 12 | |
| Creative version | Schizo | 11/06/05 | 17 | |
| Advanced, extensible beer/wall framework | Jamie Turner | 05/17/06 | 5 | |
| minimal version | Oliver Xymoron | 04/20/05 | 4 | |
| Using a iterator class | Eric Moritz | 01/20/06 | 2 | |
| Fully compliant version | Ricardo Garcia Gonzalez | 01/15/06 | 7 | |
| functional, w/o variables or procedures | Ivan Tkatchev | 07/14/05 | 1 | |
| using lambda in LISP style | J Adrian Zimmer | 11/14/06 | 2 | |
| minimal version with singular | Emlyn Jones | 06/13/05 | 3 | |
| Exception based | Michael Galpin | 02/08/08 | 0 |
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