diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..a8cb67f --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,32 @@ +#!/usr/bin/python +import sys +import getopt + + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) + print_fizzbuzz(int(args[0])) + except EOFError: + sys.exit(0) + + +def print_fizzbuzz(input_num): + for i in range(1, input_num+1): + if fizzbuzz(i) != "pass": + print("%s %s" % (i, fizzbuzz(i))) + + +def fizzbuzz(input_num): + if input_num % 3 == 0 and input_num % 5 != 0: + return ("fizz") + elif input_num % 3 != 0 and input_num % 5 == 0: + return ("buzz") + elif input_num % 3 == 0 and input_num % 5 == 0: + return ("fizz buzz") + else: + return "pass" + + +if __name__ == "__main__": + main() diff --git a/fizzbuzz_test.py b/fizzbuzz_test.py new file mode 100644 index 0000000..69efa1e --- /dev/null +++ b/fizzbuzz_test.py @@ -0,0 +1,5 @@ +from fizzbuzz import fizzbuzz + + +def test_fizzbuzz(): + assert fizzbuzz(3) == 'fizz' 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!'