Password Strength Checker
Checks password length and complexity.
The program
import re
password = input("Enter password: ")
strength = 0
if len(password) >= 8:
strength += 1
if [Link](r"[A-Z]", password):
strength += 1
if [Link](r"[a-z]", password):
strength += 1
if [Link](r"[0-9]", password):
strength += 1
if [Link](r"[!@#$%^&*()]", password):
strength += 1
if strength == 5:
print("Strong password")
elif strength >= 3:
print("Moderate password")
else:
print("Weak password")
2. Simple Log File Analyzer
Counts errors, warnings, and info messages in a log file.
Example log file ([Link]):
INFO User logged in
ERROR Database connection failed
WARNING Disk space low
INFO File uploaded
ERROR Invalid password
The program
def analyze_log(file_name):
errors = 0
warnings = 0
infos = 0
with open(file_name, "r") as file:
for line in file:
if "ERROR" in line:
errors += 1
elif "WARNING" in line:
warnings += 1
elif "INFO" in line:
infos += 1
print("Log Analysis Result")
print("-------------------")
print(f"Errors : {errors}")
print(f"Warnings : {warnings}")
print(f"Info : {infos}")
analyze_log("[Link]")