# my_module.py
def greet(name):
return f"Hello, {name}!"
pi = 3.14159
# main.py
import my_module
print(my_module.greet("Alice")) # Output: Hello, Alice!
print(my_module.pi) # Output: 3.14159
# Importing specific items
from my_module import greet, pi
print(greet("Bob")) # Output: Hello, Bob!
print(pi) # Output: 3.14159
# Renaming imported module
import my_module as mm
print(mm.greet("Charlie")) # Output: Hello, Charlie!
# Using built-in module
import math
print(math.sqrt(16)) # Output: 4.0
print(math.pi) # Output: 3.141592653589793
# Creating a package
# Directory structure:
# my_package/
# __init__.py
# module1.py
# module2.py
# Importing from package
from my_package import module1
module1.some_function()
# Using third-party module
import requests
response = requests.get("https://api.example.com")
print(response.status_code)