0% found this document useful (0 votes)
12 views10 pages

Random Password Generator

Uploaded by

vishnuteja2612
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views10 pages

Random Password Generator

Uploaded by

vishnuteja2612
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Random

password
Generator
TEAM MEMBERS
22EG107A51 – P.Manikanta Rishi.
22EG107A04 – B.Rishitha.
22EG107A54 – P.Satya Narayana.
22EG107A07 – B.Bhoomika.
22EG107A06 – B.Vivek.
RANDOM MODULE
The “random” module is a built-in Python module that provides functionalities for
working with random numbers and random data. It is commonly used for tasks like
generating random numbers
The “choice()” method found in the random module, is used for picking a random
element from a sequence
Advantages of choice() method
1.Random Selection.
2.Uniform Distribution.
Example for random.choice()

import random
my_list = [1, 2, 3, 4, 5]
random_element = random.choice(my_list)
print(random_element)#3 (or) 4 (or) 2 (or)……..
String module
The string module in Python is a part of the standard library and provides a collection of string
constants and functions that are useful for working with strings

The methods of the string module are

1.string.ascii_letters

2.string.punctuations

3.string.digits
1. string.ascii_letters

This constant is a string containing all the uppercase and lowercase letters of the English alphabet.
Specifically, it includes the letters from 'a' to 'z' and 'A' to ‘Z’

Ex->

import string

letters = string.ascii_letters

print(letters)

Output:

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
2. string.punctuation
This constant is a string containing all the common punctuation characters. It includes characters like
commas, periods, exclamation marks, question marks, colons, semicolons, and various other symbols
used for punctuation.

Ex->

import string

punctuation_chars = string.punctuation

print(punctuation_chars)

Output:

!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~
3. string.digits

This constant is a string containing all the Arabic numerals from '0' to ‘9’

Ex->

import string

numeric_chars = string.digits

print(numeric_chars)

Output:

0123456789
“Random password generator”
import random , string

def generate_random_password(self, length):

characters = string.ascii_letters + string.digits + string.punctuation

password = ''.join(random.choice(characters) for i in range(length))

return password

password=generate_random_password(int(input("Enter the length of the password to be : "))

print(password)

Output:
Enter the length of the password to be : 12

.cc4CK?>>&{<
Thank you

You might also like