0% found this document useful (0 votes)
21 views

Python_basic_2

This document describes a Python-based Password Generator that creates strong random passwords using letters, numbers, and symbols. It includes the Python code for generating passwords, allowing users to specify the length and whether to include digits and symbols. The program features user input handling and error management for invalid inputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Python_basic_2

This document describes a Python-based Password Generator that creates strong random passwords using letters, numbers, and symbols. It includes the Python code for generating passwords, allowing users to specify the length and whether to include digits and symbols. The program features user input handling and error management for invalid inputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Password Generator

Your Name
March 24, 2025

1 Introduction
This document presents a Python-based Password Generator. The program
generates strong random passwords using letters, numbers, and symbols.

2 Python Code
1 import random
2 import string
3
4 def g e n e r a t e _ p a s s w o r d ( length =12 , use_digits = True , use_symbols = True )
:
5 characters = string . ascii_letters
6 if use_digits :
7 characters += string . digits
8 if use_symbols :
9 characters += string . punctuation
10
11 password = ’ ’. join ( random . choice ( characters ) for _ in range (
length ) )
12 return password
13
14 def main () :
15 print ( " Welcome to the Password Generator ! " )
16
17 try :
18 length = int ( input ( " Enter password length ( default 12) : " )
or 12)
19 use_digits = input ( " Include numbers ? ( y / n ) : " ) . strip () .
lower () == " y "
20 use_symbols = input ( " Include symbols ? ( y / n ) : " ) . strip () .
lower () == " y "
21
22 password = g e n e ra t e _ p a s s w o r d ( length , use_digits ,
use_symbols )
23 print ( f " \ n Generated Password : { password }\ n " )
24 except ValueError :
25 print ( " Invalid input ! Please enter a number for length .
")
26

1
27 if __name__ == " __main__ " :
28 main ()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy