Мой профиль
ACTIVITY 47 / 50

Your own module

Try as many times as you need

Let’s understand

An ordinary .py file can also be a module. This workshop includes helpers.py with a function called triple. Import it just as you imported a function from math. Modules let one part of a program reuse another.

Listen to the explanation

Example

# helpers.py
def triple(n):
    return n * 3
YOUR MISSION

Import triple from helpers. Read a number and print triple of it.

I need a hint

Use from helpers import triple.

How to find an error
  1. Read the last line of the error message.
  2. Find the indicated line. Check quotes, parentheses and indentation.
  3. Change one thing and run again.
helpers.py
def triple(n):
    return n * 3

main.py

4 spaces

Your draft stays in this browser.

Result

Python
Your program’s output will appear here. Click Run.