As part of a Python focus group started at work, we had the following exercise - as the first of many - set to us. The problem is the wll known fizz buzz one:

Write a program that processes a list of numbers from 1 to 100. For each number, if the number is a multiple of 3, print “FIZZ”; if the number is a multiple of 5, print “BANG”; otherwise, print the number. You are *NOT* allowed to use any *IF/ELSE* statements in your code. You can use the list-accessing ternary operator hack, but whilst I’ll accept your homework if you do, you’ll miss out on the prize (alcoholic), which goes to the most concise code (not including whitespace).

Kerry and Nigel have already posted their solutions, which I’m afraid are much more concise than mine - I was mostly happy to find a way to do it without any conditional logic (including an or) and too lazy to look further. So here’s mine:

def fizzbang():
 # Numbers from 1 to 100
 numbers = range(1,101)
# 3,6,9,...,99
 multiples_of_3 = range(3,101,3)
 # 5,10,15,...,95,100
 multiples_of_5 = range(5,101,5)
 # 15,30,45,60,75,90
 multiples_of_3_and_5 = range(15,101,15)
# Replace all muliples of 3 with FIZZ
 for i in multiples_of_3:
  numbers[i-1] = "FIZZ"

# Replace all muliples of 5 with BANG
 for j in multiples_of_5:
  numbers[j-1] = "BANG"

# Replace all muliples of both 3 and 5 with FIZZ BANG
 for k in multiples_of_3_and_5:
  numbers[k-1] = "FIZZ BANG"

for x in numbers:
  print x

Go on, poke some holes in it.