Skip to content

Commit 895fb03

Browse files
committed
added fizzbuzz code
1 parent 8850af9 commit 895fb03

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

fizzbuzz.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def fizzbuzz(yourNum):
2+
if yourNum < 1:
3+
return "Fail!"
4+
if yourNum % 3 == 0 and yourNum % 5 != 0:
5+
return "Fizz"
6+
if yourNum % 3 != 0 and yourNum % 5 == 0:
7+
return "Buzz"
8+
if yourNum % 3 == 0 and yourNum % 5 == 0:
9+
return "FizzBuzz"
10+
return input
11+
12+
def test_fizzbuzz():
13+
assert fizzbuzz(0) == "Fail!"
14+
assert fizzbuzz(-1) == "Fail!"
15+
assert fizzbuzz(3) == "Fizz"
16+
assert fizzbuzz(6) == "Fizz"
17+
assert fizzbuzz(5) == "Buzz"
18+
assert fizzbuzz(10) == "Buzz"
19+
assert fizzbuzz(15) == "FizzBuzz"
20+
assert fizzbuzz(30) == "FizzBuzz"
21+

0 commit comments

Comments
 (0)