PROJECT :-
Password Generator
Display "Welcome to the PyPassword Generator!"
Ask the user for how many letters they want in the password and store in nr_letters
Ask the user for how many symbols they want in the password and store in nr_symbols
Ask the user for how many numbers they want in the password and store in nr_numbers
Initialize an empty list called password
Repeat nr_letters times:
Randomly select a letter from the predefined letters list
Add the selected letter to the password list
Repeat nr_symbols times:
Randomly select a symbol from the predefined symbols list
Add the selected symbol to the password list
Repeat nr_numbers times:
Randomly select a number from the predefined numbers list
Add the selected number to the password list
Display the generated password list (which is ordered: letters, then symbols, then numbers)
Shuffle the elements in the password list to randomize the order
Display the shuffled password list
Initialize an empty string called final_password
For each character in the shuffled password list:
Add the character to the final_password string
Display "Your password is:" followed by the final_password string
CREATION 1 — Password Strength Meter (stay with basic tools)
Enhance your generator so after creating the final password it prints a strength message based on simple rules:
Compute three checks (each gives 1 point):
Length ≥ 12 → +1
Contains at least one symbol and at least one number → +1
Contains both lowercase and uppercase letters → +1
Strength messages:
Score 3 → "Very Strong"
Score 2 → "Strong"
Score 1 → "Weak"
Score 0 → "Very Weak"
Constraints / hints
Do all checks using for loops and if (no functions).
You may use simple boolean flags (e.g., has_symbol = False) and set them True when found.
Print the password and then: Password strength: Strong (or whichever).
Why: Teaches combining loops, conditionals, and string inspection.
Solution is in my Github Repo
link in comments
Question : 2
CREATION 2 — Batch Generator + Uniqueness Check
Allow the user to request N passwords (N from input), each using the same nr_letters, nr_symbols, nr_numbers specification. Generate N passwords, store them in a list, and ensure all passwords in the list are unique:
Ask: "How many passwords would you like to generate?" → count.
Generate count passwords and append to all_passwords list.
If a newly generated password already exists in all_passwords, generate a new one (repeat until unique).
At the end print all passwords, one per line, and print "Generated X unique passwords."
Constraints / hints
Use a while loop to retry if duplicate found.
Keep everything in memory (list of strings).
Don’t use sets (we want to practice list membership): use if new_pass in all_passwords.
Why: Practice loops, membership checks, building lists, and basic collision handling.
Solution is in my Github Repo
link in comments
Debugging Question
Q1 :- Type & Shuffle Bug
Fix the buggy version below so it runs without error and the final printed password is a string (not a list) and properly shuffled.
Buggy snippet
BUGGY: missing int casting, wrong shuffle usage
nr_letters = input("How many letters?\n")
nr_symbols = int(input("How many symbols?\n"))
nr_numbers = int(input("How many numbers?\n"))
password = []
for i in range(nr_letters):
password.append(random.choice(letters))
random.shuffle(password)
print("Your password is: " + password)
Problems to fix
nr_letters must be numeric.
random.shuffle shuffles lists in-place (OK) but you cannot + a list to a string.
Make final output a string.
What I expect you to change
Convert nr_letters to int.
Build final string from the list before printing.
Ensure no runtime errors.
Solution :-
DEBUGGING 2 — Empty-Input / Edge Case Crash
Fix the code below so it does not crash when the user enters 0 for all counts or leaves a blank for counts (non-integer). If user inputs 0 for every category, print "Cannot create empty password — please enter at least 1 character." and stop gracefully.
Buggy snippet
nr_letters = int(input("Letters: "))
nr_symbols = int(input("Symbols: "))
nr_numbers = int(input("Numbers: "))
password = []
for i in range(nr_letters):
password.append(random.choice(letters))
for i in range(nr_symbols):
password.append(random.choice(symbols))
for i in range(nr_numbers):
password.append(random.choice(numbers))
random.shuffle(password)
final = ""
for c in password:
final += c
print(final)
Problems to fix
If the user presses Enter without typing a number, int() throws an error.
If all inputs are 0 → list empty → password empty; you must handle that case and print a helpful message.
You must handle non-integer input without the program crashing.
Hints
Use try/except ValueError around conversions.
Check if nr_letters + nr_symbols + nr_numbers == 0: then print message and exit (no crash).
Keep the rest of the logic the same after validation.
Solution is in my Github Repo
link in comments
Thank you Day 04 Is COMPLETED.
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.