Python Project #1: Random Password Generator

preview_player
Показать описание
#Python #Programming #Beginners #Introduction #Project #RandomPasswordGenerator #Password #RPG #datatype #string #list #choice #sample #function

About this video:
This video shows how to create a random password generator using strings and lists as our datatypes and choice() and sample() functions from the random module.

Working on these projects will test and improve our skills at the same time. At the end, we will have used our skills to make something that we can be proud of.

Timestamps:
00:00 Welcome Brief
00:48 Random Password Generator
01:14 Requirements and Constraints
02:28 Flow-Chart
03:30 Coding and Testing the Output
17:08 Improvements
18:37 Recap/ Summarization

Code:
from random import choice, sample

letters_lower = "abcdefghijklmnopqrstuvwxyz"
letters_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
special_chars = "~!@#$%^&*()_+-{}[]"

pool_all_chars = letters_lower + letters_upper + numbers + special_chars

lower_1 = choice(letters_lower)
lower_2 = choice(letters_lower)
upper_1 = choice(letters_upper)
upper_2 = choice(letters_upper)
num_1 = choice(numbers)
sp_char_1 = choice(special_chars)

ex_char_1 = choice(pool_all_chars)
ex_char_2 = choice(pool_all_chars)
ex_char_3 = choice(pool_all_chars)
ex_char_4 = choice(pool_all_chars)

temp_pwd = lower_1 + lower_2 + upper_1 + upper_2 + num_1 + sp_char_1 + ex_char_1 + ex_char_2 + ex_char_3 + ex_char_4
print("".join(sample(temp_pwd, len(temp_pwd))))
Рекомендации по теме