We use two files, both stored in the same directory.
Create a file named mymodule.py
. Save it in your cs100/ch1
folder.
# function definition
def myfunction():
print("this is a function from a module")
Create another file named notes5-functions.py
. Save it in the same location in cs100/ch1
folder. In it, you can import the module you just created.
# importing the module we made
import mymodule
# calling a function from the module we created
mymodule.myfunction()