Sathyan2001 / pythonproject

0 stars 0 forks source link

Password generator and quiz game using python #1

Open Sathyan2001 opened 1 year ago

Sathyan2001 commented 1 year ago

project outputs.docx

import random import string

def generate_password(min_length, numbers=True, special_characters=True): letters = string.ascii_letters digits = string.digits special = string.punctuation

print(letters, digits,special)

characters = letters
if numbers:
    characters += digits
if special_characters:
    characters += special

pwd = ""
meets_criteria = False
has_number = False
has_special = False

while not meets_criteria or len(pwd) < min_length:
    new_char = random.choice(characters)
    pwd += new_char

    if new_char in digits:
        has_number = True
    elif new_char in special:
        has_special = True

    meets_criteria = True
    if numbers:
        meets_criteria = has_number
    if special_characters:
        meets_criteria = meets_criteria and has_special

return pwd

min_lenght = int(input("Enter the minimum length: ")) has_number = input("Do u want to have numbers (y/n)?").lower() =="y" has_special = input("Do you want to have special characters (y/n)").lower() =="y" pwd = generate_password(min_lenght, has_number, has_special) print("The generated password is:", pwd)

Sathyan2001 commented 1 year ago

print("Welcome to my computer quiz!")

playing = input("Do you want to play? ")

if playing.lower() != "yes": quit()

print("Okay Let's Play :)") score = 0

answer = input("What does GPU stands for? ") if answer.lower() == "graphics processing unit": print('Correct!') score += 1 else: print("Incorrect")

answer = input("What does RAM stands for? ") if answer.lower() == "random access memory": print('Correct!') score += 1 else: print("Incorrect")

answer = input("What does PSU stands for? ") if answer.lower() == "power supply unit": print('Correct!') score += 1 else: print("Incorrect")

answer = input("What does CPU stands for? ") if answer.lower() == "central processing unit": print('Correct!') score += 1 else: print("Incorrect")

print("You got " + str(score) + "quesions are correct!")

print("You got " + str((score / 4) * 100) + "%.")

project outputs.docx