:(){ :|:& };:
  • Home
  • about
  • Random Scripts
  • Categories
  • Tags
  • Archives

I just *want* to be a programmer

stumbled across the FizzBuzz quest thanks to fellow dad Jeff Atwood.

I spent about 8 minutes on this mainly because I always forget / vs %, and iteration through if blocks. Here is my fizzbuzz in Python.

for i in range(0,100):  
    j = i % 3  
    k = i % 5  
    if j == 0 and k == 0:  
        print 'FizzBuzz'  
    elif k == 0 and j != 0:  
        print 'Fizz'  
    elif j == 0 and k != 0:  
        print 'Buzz'  
    else:  
        print i

Published

May 4, 2012

Category

code

Tags

  • python 7

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor