Skip to content

Latest commit

 

History

History
32 lines (19 loc) · 416 Bytes

File metadata and controls

32 lines (19 loc) · 416 Bytes

Modules in Python

A module is just a Python file.

If you create: math_utils.py

That file is a module.

Anything inside it (variables, functions) can be reused.

For Example:

math_utils.py

def add(a, b):
    return a + b

Importing a Module

import math_utils

result = math_utils.add(2, 3)

Key rule:

You must use the module name as a prefix.

This prevents naming conflicts.