Simple Password Generator in Python
Skills:
AI Pair Programming80%
Key Takeaways
The video demonstrates how to build a simple password generator in Python using the random library, string functions, and conditional statements to create a customizable password generator.
Full Transcript
[Music] what is going on guys welcome back in today's video we're going to build a simple password generator in python so let us get right into it so creating a password generator in python is a very simple thing the only thing we need to do is we need to import the random and then we're going to create a bunch of strings containing all possible characters that we can use for the password so let's say we have for example upper case letters here this is one thing and we're just going to make a string here with 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 there you go then we're going to say lowercase letters and we don't need to write uh everything again we can just say uppercase letters dot lower using the string function here then we can also say numbers we're actually digits and we can say this is a string of 0 1 2 3 4 5 6 7 8 9. that's it and last but not least we can add all kinds of symbols so we're going to say symbols equals and you can include whatever you want here you can say for example i'm going to include include parentheses square brackets curly brackets uh commas semicolons colons dots uh everything you want actually underlines slash uh with backslash you need to be a little bit careful because if you do just backslash it's not going to count this as backslash you need to do backslash backslash backslash if you actually want to do uh backslash and uh then we're going to say question mark and plus and star and hashtag and i don't know what whatever you want so we're going to include all those here we can also include a white space uh and then what we're going to do is we're going to make booleans for selecting uh which things we want to include in the password that we're generating so we're going to say upper lower digits actually digits is already used so let's say nums for numbers uh and then sims for symbols okay then we're going to set all those to true in the beginning we can later on set them to false if we want uh or we can also set them to true or false uh based on the user input if you want to do that i'm just going to do it directly in the script and then we're going to uh to create a um a string for the final password so we're going to say password equals and an empty string now what we're going to do is we're going to say um or actually we're not going to do the password yet we're going to create first of all a string containing all the things that we're going to use so we're going to say if upper if it's true we're going to say creating a empty string up here we're going to say all plus equals uppercase letters which means that if we chose to use uppercase letters we're going to include them into the final string so then we're going to say if lower same thing all plus equals lowercase letters then we're going to say if digits or actually we said nums if nums all plus equals digits and then last but not least if sims all plus equal symbols so that's it we then have a final string depending on which of those indicators here are true or false we have a full string with all the things that we want to use and then last but not least what we're going to do is we're going to set the length to whatever we want it so let's say 20 and we're going to set the amount of passwords that we want to generate so let's say we want to generate 10 passwords for now and now we can get into the actual generation we've now chosen uh what kind of uh characters we want to use we've chosen the length of the password and the amount of passwords it won't generate so what we're now going to do is we're just going to go ahead and say 4 x in range length or actually amount first uh for x in range amount we're just going to say password equals and we're going to join them on an empty string here so we're going to join if you don't know what the join function does check out the python tips and tricks tutorial about the join function and what we're going to do is we're going to say random sorry random.sample which means it's just going to take anything out of the full string that we have random.sample all length which means that we're using the all string the complete string with all the things all the characters that we're using and we define the length of this string to be 20. so we're going to take 20 samples out of that string after that we can go ahead and print the password and actually we're done so that's actually everything we need to do in order to create a password generator looking down here we see that we have generated uh only five passwords why is that am i maybe running an old script here i think i'm i am there you go um this is actually the script that i uh that we have written uh right now so you can see we have 10 passwords here generated with all kinds of symbols numbers and letters we can also go ahead and say okay i'm not interested in symbols i don't want to use symbols here so we can rerun that and you can see that we don't have any symbols in the password we can set this to true again and say i don't want any letters in the password so we're going to say false and false here and there you go we'll only get numbers and symbols uh we can also of course go ahead and increase the length to 40 and create like 20 passwords here not a problem and you can see uh what do we have here sample oh yeah we cannot do uh length 40 of course because we don't have enough characters if we don't set all these to true because sample means that we cannot reuse characters so let's get this back to 40 but use everything and you can see that we have longer passwords here as well now you can also go ahead and repeat uh repeat those things by just doubling the string or something like that and one last thing that we can do here is we can also use a seat which is not very reasonable but if you want to do this uh you can use a seat a seat has the effect that you will always get the same password so in this case whenever i rerun the script i get different passwords here as you can see they're not the same however if i say my seed or actually just seed equals for example neural nine i can go ahead and say random dot seed seed and we will always get the same results so i get u o m o if i rerun this i get again u o m o and all the other passwords are the same as well so i don't know why you want to use that if you want to use that but i would not recommend it just wanted to show you that this works but that is how you build a password generator in python so that's it for this video i hope you enjoyed it i hope you learned something if so let me know by hitting the like button and leaving a comment in the comment section down below also make sure you subscribe to this channel in order to see more future videos for free and if you don't want to miss a single video click the notification bell activate it uh it should be somewhere right beside the subscribe button so if you want to make sure you don't miss out any videos go ahead and click that other than that thank you very much for watching see you in the next video and bye [Music] you
Original Description
Today we are building a simple password generator in Python.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
🐍 The Python Bible Book: https://www.neuralnine.com/books/
👕 Programming Merch: https://www.neuralnine.com/shop
🌐 Social Media & Contact 🌐
📱 Website: https://www.neuralnine.com/
📷 Instagram: https://www.instagram.com/neuralnine
🐦 Twitter: https://twitter.com/neuralnine
🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/
📁 GitHub: https://github.com/NeuralNine
🎵 Outro Music From: https://www.bensound.com/
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from NeuralNine · NeuralNine · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
Python Beginner Tutorial #5 - Loops
NeuralNine
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
Python Beginner Tutorial #7 - Functions
NeuralNine
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
Python Beginner Tutorial #9 - File Operations
NeuralNine
Python Beginner Tutorial #10 - String Functions
NeuralNine
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
Python Intermediate Tutorial #6 - Queues
NeuralNine
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
Python Intermediate Tutorial #9 - Recursion
NeuralNine
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
Python Intermediate Tutorial #11 - Logging
NeuralNine
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
Python Machine Learning #4 - Support Vector Machines
NeuralNine
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
Making Text Images Readable Again with Python and OpenCV
NeuralNine
Neural Networks Simply Explained (Theory)
NeuralNine
Motion Filtering with OpenCV in Python
NeuralNine
Top 5 Programming Languages To Learn in 2020
NeuralNine
Simple TCP Chat Room in Python
NeuralNine
Image Classification with Neural Networks in Python
NeuralNine
Edge Detection with OpenCV in Python
NeuralNine
S&P 500 Web Scraping with Python
NeuralNine
Simple Sentiment Text Analysis in Python
NeuralNine
Introduction - Algorithms & Data Structures #1
NeuralNine
More on: AI Pair Programming
View skill →
🎓
Tutor Explanation
DeepCamp AI