Skip to content

DKamalini/Week-5-Python-Modules-Libraries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Week-5-Python-Modules-Libraries

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))

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published