Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 5 additions & 0 deletions fizzbuzz_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from fizzbuzz import fizzbuzz


def test_fizzbuzz():
assert fizzbuzz(3) == 'fizz'
2 changes: 0 additions & 2 deletions helloworld.py

This file was deleted.

5 changes: 0 additions & 5 deletions helloworld_test.py

This file was deleted.