Sure, here's an example of a Python program that demonstrates the use of a user-defined package
First, let's create a package directory called "my_package". Inside this directory, we will create two files: __init__.py and my_module.py.
In my_module.py, we will define a simple function called greet():
def greet(name):
print(f"Hello, {name}!")
In __init__.py, we will import my_module and make the greet() function available to users of the package:
from .my_module import greet
Now, let's create a Python file called main.py, which will use our user-defined package:
import my_package
my_package.greet("Alice")
When we run main.py, it will import the my_package package and use the greet() function to greet Alice. Here's what the output should look like:
Hello, Alice!
That's it! This is a very simple example, but you can use this pattern to create more complex packages with multiple modules and functions.