Jeff Atwood made a post on his blog today about a simple test used to screen prospective programmers looking for a job. The reason: many people who claim to be programmers fail to solve the simplest of problems. The test:
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Just for kicks, I knocked out the program in Python in a few short seconds to see if I could do it.
# FizzBuzz test.
for x in range(1,101):
if( (float(x%3)==0) & (float(x%5)==0) ):
print 'FizzBizz'
elif( float(x%3)==0 ):
print 'Fizz'
elif( float(x%5)==0 ):
print 'Bizz'
else:
print x
I started teaching myself
So why Python? Well, I wanted a language that is relatively easy to learn and is multipurpose. Python was the obvious choice in my eyes. I figure if it’s good enough for Google, it’s good enough for me. A few of my favorite programs like