Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Magnie Mozios' Fizz Buzz program.
- # MagnieTheReal[at]gmail.com -- Copyright 2014 -- All Mine, except line 25.
- # Version 1.0 original, working, program.
- # Version 1.1 for cleaner output.
- __version__ = '1.1'
- # Declare the characters.
- f = ord('f')
- i = ord('i')
- z = ord('z')
- b = ord('b')
- u = ord('u')
- # Make writing 'zz' easier.
- zz = chr(z) * 2
- # Add all the characters together to make a string.
- fizz = chr(f) + chr(i) + zz
- buzz = chr(b) + chr(u) + zz
- # Declare the numbers, import math for necessary functions used in declarations.
- import math
- three = int((math.pi * 13.37)) / 14.0
- # Thanks to hobbes[at]fallingduck.net for this.
- five = float(int((math.acos(math.e - 2) * (math.pi ** 2)) - 2))
- # Go through 1 to 100
- for i in xrange(1, 100):
- # Print the result
- print ''.join(( # Use tuple so input is one argument.
- str(i) + ' ', # Print the current number
- (fizz) if not (i % three) else '', # Print 'fizz' if divisible by 3.
- (buzz) if not (i % five) else '' # Print 'buzz' if divisible by 5.
- ))
Advertisement
Add Comment
Please, Sign In to add comment