Created
July 19, 2012 16:41
-
-
Save jasonsperske/3145186 to your computer and use it in GitHub Desktop.
Fizz/Buzz in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My First Python program | |
# Based on this spec: http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html | |
def fbFilter(n): return n % 5 == 0 or n % 3 == 0 | |
def fbPrinter(n): | |
if n % 15 == 0: | |
return 'FizzBuzz' | |
elif n % 5 == 0: | |
return 'Buzz' | |
elif n % 3 == 0: | |
return 'Fizz' | |
map(fbPrinter, filter(fbFilter, range(1, 100))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment