mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
1.5 KiB
1.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 696655d24b614176d4c9b78c | Challenge 169: FizzBuzz Mini | 29 | challenge-169 |
--description--
Given an integer, return a string based on the following rules:
- If the number is divisible by 3, return
"Fizz". - If the number is divisible by 5, return
"Buzz". - If the number is divisible by both 3 and 5, return
"FizzBuzz". - Otherwise, return the given number as a string.
--hints--
fizz_buzz_mini(3) should return "Fizz".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_mini(3), "Fizz")`)
}})
fizz_buzz_mini(4) should return "4".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_mini(4), "4")`)
}})
fizz_buzz_mini(35) should return "Buzz".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_mini(35), "Buzz")`)
}})
fizz_buzz_mini(75) should return "FizzBuzz".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_mini(75), "FizzBuzz")`)
}})
fizz_buzz_mini(98) should return "98".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(fizz_buzz_mini(98), "98")`)
}})
--seed--
--seed-contents--
def fizz_buzz_mini(n):
return n
--solutions--
def fizz_buzz_mini(n):
if n % 3 == 0 and n % 5 == 0:
return "FizzBuzz"
if n % 3 == 0:
return "Fizz"
if n % 5 == 0:
return "Buzz"
return str(n)