1. How to import modules in Python?
-We use the import keyword.
import math
import random
import datetime
2. What is the use of random and datetime libraries?
-random → helps to generate random numbers, choices, and passwords.
-datetime → helps to get today’s date, time, and work with calendars.
3. Program: Password Generator
import random
import string
def generate_password(length=8):
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
return password
# Example
print("Generated Password:", generate_password(12))