multiple modules

This commit is contained in:
2024-04-23 18:49:18 +02:00
parent d8042f277c
commit 9b044b6077
4 changed files with 99 additions and 27 deletions

View File

@@ -1,8 +1,27 @@
"""
# Numerix
Fancy numerics made easy.
"""
# Functions defined directly in __init__.py can be imported directly
# from the package (e.g. from numerix import add_four):
def add_four(x):
"""Add four to a number.
Parameters
----------
x: int or float
A number.
Returns
-------
y: int or float
`x` plus 4.
"""
return x + 4
# Functions from the modules of the package can be imported into the
# namespace of the package:
from .addition import add_two

View File

@@ -1,17 +1,6 @@
from .numbers import one
def __add_secret(x):
return x + 7
def add_two(x):
return x + 2
def one_plus_two():
return add_two(one())

View File

@@ -1,9 +1,5 @@
from .addition import add_two
def one():
return 1
def random():
return 4 # this number was obtained from a fair die
def three():
return add_two(1)