Labs ICT
🎓 SIWES/IT Login

Packages

1 min read | Python Tutorial
🎓

Doing SIWES / IT attachment?

Get a structured training programme, a supervised digital logbook, and a completion certificate with LabsICT SIWES / IT.

Explore SIWES / IT Training

Packages

A package is a folder containing an __init__.py file and one or more module files. Packages let you organize related modules into a hierarchy.

# Directory structure:
# mypackage/
#   __init__.py
#   mathops.py

# mathops.py
def add(a, b):
    return a + b

def multiply(a, b):
    return a * b

# main.py
from mypackage import mathops

print(mathops.add(5, 3))
print(mathops.multiply(4, 2))

Install third-party packages with pip:

pip install requests

import requests
response = requests.get("https://api.github.com")
print(response.status_code)