"""Lesson 9: Modules and Packages
This lesson introduces code organization with modules and built-in packages for reusable functionality.
"""
Importing a built-in module.
import math
print("Square root of 16:", math.sqrt(16))
print("Pi rounded:", round(math.pi, 3))
Use a specific function from a module.
from datetime import datetime
print("Current date and time:", datetime.now())
# Create a small reusable utility function.
def format_price(amount):
return f"${amount:,.2f}"
print(format_price(1234.5))
Real-world example:
organizing helpers in separate files
.
Top comments (0)