Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Python

(minimal version with singular)

Date:06/13/05
Author:Emlyn Jones
URL:n/a
Comments:2
Info:http://www.python.org
Score: (2.72 in 18 votes)
a,t="\n%s bottle%s of beer on the wall","\nTake one down, pass it around"
for d in range(99,0,-1):print(a%(d,"s"*(not d-1==0))*2)[:-12]+t+a%(d-1 or 'No',"s"*(not d-2==0))

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
This example demonstrates the simplicityGerold Penz07/23/054
Creative versionSchizo11/06/0512
minimal versionOliver Xymoron04/20/053
Advanced, extensible beer/wall frameworkJamie Turner05/17/063
Exception basedMichael Galpin02/08/080
Using a iterator classEric Moritz01/20/062
Fully compliant versionRicardo Garcia Gonzalez01/15/065
New conditional expressions in 2.5Ezequiel Pochiero12/18/060
using lambda in LISP styleJ Adrian Zimmer11/14/060
functional, w/o variables or proceduresIvan Tkatchev07/14/051

Comments

>>  Sean McKean said on 06/21/05 23:09:41

Sean McKean Here's a shorter version (163 bytes) that includes punctuation:

a,s="\n%s bottle","s of beer on the wall,"
for d in range(99,0,-1):print((a%d+s[d==1:])*2)[:-13]+",\nTake one down, pass it around,"+a%(d-1 or"No";)+s[d==2:-1]+"."

>>  Sean McKean said on 06/21/05 23:29:58

Sean McKean Sorry, didn't know about the 100 character line limit.
Here's the correct version:

a,s,t="\n%s bottle","s of beer on the wall,",",\nTake one down, pass it around,"
for d in range(99,0,-1):print((a%d+s[d==1:])*2)[:-13]+t+a%(d-1 or"No";)+s[d==2:-1]+"."

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!

Name:

eMail:

URL:

Security Code:
  
Comment: