-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdef fizz buzz.py
More file actions
31 lines (26 loc) · 1007 Bytes
/
Copy pathdef fizz buzz.py
File metadata and controls
31 lines (26 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def checkio(number: int) -> str:
# Your code here
# It's main function. Don't remove this function
# It's using for auto-testing and must return a result for check.
# replace this for solution
x=""
if number % 3 == 0 and number % 5 == 0:
x = 'Fizz Buzz'
elif number % 3 == 0:
x = 'Fizz'
elif number % 5 == 0:
x = 'Buzz'
else:
x = str(number)
return x
# Some hints:
# Convert a number in the string with str(n)
# These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
print('Example:')
print(checkio(15))
assert checkio(15) == "Fizz Buzz", "15 is divisible by 3 and 5"
assert checkio(6) == "Fizz", "6 is divisible by 3"
assert checkio(5) == "Buzz", "5 is divisible by 5"
assert checkio(7) == "7", "7 is not divisible by 3 or 5"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")