diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..dfa58d9 --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,17 @@ +def fizz_buzz(num): + + if num % 3 == 0 and num % 5 == 0: + return 'FizzBuzz' + + if num % 3 == 0: + return 'Fizz' + + if num % 5 == 0: + return 'Buzz' + + return str(num) + + +if __name__ == '__main__': + for i in range(1, 101): + print(fizz_buzz(i)) diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py new file mode 100644 index 0000000..3c9c347 --- /dev/null +++ b/fizzbuzz_test.py @@ -0,0 +1,17 @@ +import unittest +from fizzbuzz import fizz_buzz + + +class test_fb(unittest.TestCase): + + def test_default_case(self): + self.assertEqual(fizz_buzz(1), '1') + + def test_fizz(self): + self.assertEqual(fizz_buzz(6), 'Fizz') + + def test_buzz(self): + self.assertEqual(fizz_buzz(10), 'Buzz') + + def test_fizzbuzz(self): + self.assertEqual(fizz_buzz(30), 'FizzBuzz') diff --git a/helloworld.py b/helloworld.py deleted file mode 100644 index 449b948..0000000 --- a/helloworld.py +++ /dev/null @@ -1,2 +0,0 @@ -def get_greetings(): - return 'Hello World!' diff --git a/helloworld_test.py b/helloworld_test.py deleted file mode 100644 index 4c27dfe..0000000 --- a/helloworld_test.py +++ /dev/null @@ -1,5 +0,0 @@ -from helloworld import get_greetings - - -def test_get_helloworld(): - assert get_greetings() == 'Hello World!'