Answers for "random password generator in python with explainantion"

1

python random password generator

import random

alph = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ
             abcdefghijklmnopqrstuvwxyz
             1234567890 !@#$%^&*(){}[]<>,.')
out = ''
for char in string:
    out += random.choice(alph)
    
print(out)
Posted by: Guest on April-08-2020
1

random password generator in python project

import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
print("Welcome to the PyPassword Generator!")
nr_letters = int(input("How many letters would you like in your password?n")) 
nr_symbols = int(input(f"How many symbols would you like?n"))
nr_numbers = int(input(f"How many numbers would you like?n"))
password_list = []
for char in range(1, nr_letters + 1):
  password_list.append(random.choice(letters))
for char in range(1, nr_symbols + 1):
  password_list += random.choice(symbols)
for char in range(1, nr_numbers + 1):
  password_list += random.choice(numbers)

random.shuffle(password_list)
password = ""
for char in password_list:
  password += char
print(f"Your password is: {password}")
Posted by: Guest on August-09-2021
-2

randomly generated password python

import random
import os

letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', ]

def random_password_generation():
  randnum = random.randrange(0, 10)
  randletter = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter = randletter.lower()
  else:
    randletter = randletter.upper()

  randnum2 = random.randrange(0, 10)
  randletter2 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter2 = randletter2.lower()
  else:
    randletter2 = randletter2.upper()

  randnum3 = random.randrange(0, 10)
  randletter3 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter3 = randletter3.lower()
  else:
    randletter3 = randletter3.upper()

  randnum4 = random.randrange(0, 10)
  randletter4 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter4 = randletter4.lower()
  else:
    randletter4 = randletter4.upper()

  randnum5 = random.randrange(0, 10)
  randletter5 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter5 = randletter5.lower()
  else:
    randletter5 = randletter5.upper()

  randnum6 = random.randrange(0, 10)
  randletter6 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter6 = randletter6.lower()
  else:
    randletter6 = randletter6.upper()

  randnum7 = random.randrange(0, 10)
  randletter7 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter7 = randletter7.lower()
  else:
    randletter7 = randletter7.upper()

  randnum8 = random.randrange(0, 10)
  randletter8 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter8 = randletter8.lower()
  else:
    randletter8 = randletter8.upper()

  randnum9 = random.randrange(0, 10)
  randletter9 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter9 = randletter9.lower()
  else:
    randletter9 = randletter9.upper()

  randnum10 = random.randrange(0, 10)
  randletter10 = random.choice(letters)

  if(random.randrange(0,2) == 1):
    randletter10 = randletter10.lower()
  else:
    randletter10 = randletter10.upper()

  random_password = (randnum, randletter, randnum2, randletter2, randnum3, randletter3, randnum4, randletter4, randnum5, randletter5, randnum6, randletter6, randnum7, randletter7, randnum8, randletter8, randnum9, randletter9, randnum10, randletter10)

  random_password = str(random_password)

  print('randomly generated password:', random_password.replace("'", "").replace(" ", "").replace(",", "").replace(",", "").replace(")", "").replace("(", ""))

  print(' ')

  again_ask()

def again_ask():
  again = input('again? y/n: ')
  again = again.lower()

  if(again == 'y'):
    os.system('clear')
    random_password_generation()

  elif(again == 'n'):
    os.system('clear')
    print('Ok then.')
    exit()

  elif(again != 'y' or 'n'):
    print(' ')
    print('do it propper this time!')
    print(' ')
    again_ask()

random_password_generation()
again_ask()
Posted by: Guest on February-14-2021

Code answers related to "random password generator in python with explainantion"

Python Answers by Framework

Browse Popular Code Answers by Language