Skip to content

Commit

Permalink
FizzBuzz naturally
Browse files Browse the repository at this point in the history
  • Loading branch information
David Simandl committed Apr 8, 2015
1 parent 05a900e commit 1b1e4ca
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1 +1,4 @@
bower_components/
.idea
__pycache__
*.pyc
15 changes: 15 additions & 0 deletions FizzBuzz/FizzBuzz.py
@@ -0,0 +1,15 @@
def fizz_buzz_wonder(input_func):
user_input = input_func()
if user_input.lower() == 'fizz':
return 'Fizz!'
elif user_input.lower() == 'buzz':
return 'Buzz!'
else:
return 'FizzBuzz!'

def prompt_for_input():
return input('Enter "Fizz" or "Buzz": ').strip()

if __name__ == '__main__':
print(fizz_buzz_wonder(prompt_for_input))
print("Did I get the job?")
1 change: 1 addition & 0 deletions FizzBuzz/__init__.py
@@ -0,0 +1 @@
__author__ = 'dsimandl'
15 changes: 15 additions & 0 deletions FizzBuzz/tests.py
@@ -0,0 +1,15 @@
import unittest
import fizzbuzz

# We have to have tests naturally

class FizzBuzzTest(unittest.TestCase):

def test_some_fizz(self):
self.assertEqual(fizzbuzz.fizz_buzz_wonder(lambda: 'Fizz'), 'Fizz!')

def test_some_buzz(self):
self.assertEqual(fizzbuzz.fizz_buzz_wonder(lambda: 'Buzz'), 'Buzz!')

def test_some_fizz_buzz(self):
self.assertEqual(fizzbuzz.fizz_buzz_wonder(lambda: 'Hi!'), 'FizzBuzz!')

0 comments on commit 1b1e4ca

Please sign in to comment.