Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
66 lines (46 loc) · 1.05 KB

File metadata and controls

66 lines (46 loc) · 1.05 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

Python FizzBuzz

This segment is intended to be used to teach how to use the Python debugger along with Pytest.

Setup

  1. Create a virtual environment
$ python3 -m venv venv
  1. Activate the environment
$ source venv/bin/activate
  1. Install the dependencies
pip install -r requirements.txt

You can now run the tests with the command

$ pytest

FizzBuzz Function

fizzbuzz is a function which returns the string representation of numbers from 1 to n.

But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.

Example:

n = 15,

Return:
[
    "1",
    "2",
    "Fizz",
    "4",
    "Buzz",
    "Fizz",
    "7",
    "8",
    "Fizz",
    "Buzz",
    "11",
    "Fizz",
    "13",
    "14",
    "FizzBuzz"
]

Implementation Not working

However this function is not passing all it's tests. Use the debugger to make the program pass the given tests.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.