Fizzbuzz#

FizzBuzz implementation.

Code Documentation#

FizzBuzz implementation.

fizzbuzz.fizzbuzz(number: int | float, keyword_mapping: dict[int, str] | None = None) str#

Run FizzBuzz against a number.

Returns the number itself, unless it is divisible by any of the keys in the keyword mapping dictionary, in which case it returns the corresponding value from the dictionary.

Parameters:
  • number – The number FizzBuzz will run against.

  • keyword_mapping – FizzBuzz keyword mapping.

Returns:

The number or the corresponding keyword if the number is divisible by a key.

Examples

>>> fizzbuzz(3)
'Fizz'
>>> fizzbuzz(4)
'4'
>>> fizzbuzz(5)
'Buzz'
>>> fizzbuzz(15)
'FizzBuzz'
>>> fizzbuzz(7, {7: "Riff"})
'Riff'