-
Create a module
In real projects, you would write the code in multiple files. The code written in one file, may need to be used from a program block in another file.
Example:
def sayhello(name):
print(“Hello,” + name)Save the above code in a file with hello.py
Using a module
Now we can use the module we just created, by using the import statement:
Import the module named hello, and call the sayhello function:
Example:
import hello
hello.sayhello(“David”)