• JUPYTER
  • FAQ
  • View as Code
  • Python 3 (ipykernel) Kernel
  • View on GitHub
  • Execute on Binder
  • Download Notebook
  1. learn-python3
  2. notebooks
  3. beginner
  4. exercises
In [ ]:
# Let's make sure pytest and ipytest packages are installed
# ipytest is required for running pytest inside Jupyter notebooks
import sys

!{sys.executable} -m pip install pytest
!{sys.executable} -m pip install ipytest

# These are needed for running pytest inside Jupyter notebooks
import ipytest

ipytest.autoconfig()

1. Creating your first test case¶

There is an implementation for get_divisible_by_five function in the cell below. Your task is to create a test case for this function to verify that it works correctly.

In [ ]:
def get_divisible_by_five(numbers):
    """Returns a list of numbers which are divisible by five in the list got as an argument"""
    result = []
    for num in numbers:
        if not num % 5:
            result.append(num)

    return result
In [ ]:
%%ipytest

def test_get_divisible_by_five():
    # Your implementation here

This website does not host notebooks, it only renders notebooks available on other websites.

Delivered by Fastly, Rendered by OVHcloud

nbviewer GitHub repository.

nbviewer version: 8b013f7

nbconvert version: 7.2.3

Rendered (Tue, 10 Jun 2025 07:09:25 UTC)