import random
import string
random.seed(10)
letters = string.ascii_lowercase
rand_letters = random.choices(letters,k=5) # where k is the number of required rand_letters
print(rand_letters)
['o', 'l', 'p', 'f', 'v']
import random
def key_gen():
keylist = random.choice('abcdefghijklmnopqrstuvwxyz')
return keylist
number = 0
list_item = ''
while number < 20:
number = number + 1
list_item = list_item + key_gen()
print(list_item)
import string
import random
def random_char(y):
return ''.join(random.choice(string.ascii_letters+string.digits+li) for x in range(y))
no=int(input("Enter the number of character for your password= "))
li = random.choice('!@#$%^*&( )_+}{')
print(random_char(no)+li)
def create_key(key_len):
key = ''
valid_characters_list = string.letters + string.digits
for i in range(key_len):
character = choice(valid_characters_list)
key = key + character
return key
def create_key_list(key_num):
keys = []
for i in range(key_num):
key = create_key(key_len)
if key not in keys:
keys.append(key)
return keys
import string
import random
import sys
#make sure it's 3.7 or above
print(sys.version)
def create_str(str_length):
return random.sample(string.ascii_letters, str_length)
def create_num(num_length):
digits = []
for i in range(num_length):
digits.append(str(random.randint(1, 100)))
return digits
def create_special_chars(special_length):
stringSpecial = []
for i in range(special_length):
stringSpecial.append(random.choice('!$%&()*+,-.:;<=>?@[]^_`{|}~'))
return stringSpecial
print("how many characters would you like to use ? (DO NOT USE LESS THAN 8)")
str_cnt = input()
print("how many digits would you like to use ? (DO NOT USE LESS THAN 2)")
num_cnt = input()
print("how many special characters would you like to use ? (DO NOT USE LESS THAN 1)")
s_chars_cnt = input()
password_values = create_str(int(str_cnt)) +create_num(int(num_cnt)) + create_special_chars(int(s_chars_cnt))
#shuffle/mix the values
random.shuffle(password_values)
print("generated password is: ")
print(''.join(password_values))
import random
def Random_Alpha():
l = ['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']
return l[random.randint(0,25)]
print(Random_Alpha())