Python for Beginners: Build a Password Generator – Hands-On Coding Practice | Navid Ansari | Skillshare

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Python for Beginners: Build a Password Generator – Hands-On Coding Practice

teacher avatar Navid Ansari

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      01 Password generator introduction

      0:23

    • 2.

      02 Create all character variables

      3:05

    • 3.

      03 Use while loop

      2:38

    • 4.

      04 Creating random password

      3:09

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

1

Student

--

Projects

About This Class

Want to learn Python in a fun, practical way? In this hands-on course, you’ll build a Password Generator from scratch—a useful tool that reinforces core Python concepts like loops, variables, randomness, and user input.

Perfect for beginners, this project-based class will help you:
 Write clean Python code step by step
 Work with strings, loops, and randomness like a pro
 Create a real-world tool you can customize and use
 Boost your confidence in Python programming

By the end, you’ll have a working password generator and the skills to tackle more Python projects. No prior experience needed—just bring your curiosity!

Meet Your Teacher

Teacher Profile Image

Navid Ansari

Teacher

Hello, I'm Navid.

See full profile

Level: Beginner

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. 01 Password generator introduction: In this practice, we want to create a Python project for password generators. So user will run our application and they say, what should be the length of the password and our application, we'll give them a randomly generated password that is hard to hack, right? So let's see how we can do that. 2. 02 Create all character variables: For creating this password generator app. I want a combination of lowercase letters, uppercase letters, numbers, and symbols. So first, we should gather all of them and randomly between them, select some part of it, right? So let's see how we can do that. For doing that, I want to go to desktop in here, right click, create a new folder and I want to call it pass word generator, right? And with that done, I want to open that folder in VS code. So go in here, open folder, go to desktop, password generator, head select folder, and know in here I want to create a new file. I want to call it pass Gen, right, dot PY. So with this, let me zoom a little bit so you can see it better. First thing first, I want to collect all the uppercase, lowercase letters. After that, the numbers, after that, the symbols, right? So in here, I will create a variable. I will call it lowercase letters. Is equal to ABCD to the end, EF GHIJ. You can just search it in Internet, copy and paste it over here. After that, upper case letters is equal, ABCD, EF, and so on, right? Next, I want to put the numbers. I will call this variable. Numbers is equal a string of zero, one, two, three, four, five, six, seven, eight, nine. Next, we need the symbols. So in here, let's just say symbols is equal, again, a string of all of these symbols. You can add to it. You can delete some part of it. You decide what you want to do. Now we want to combine all of these inside just one variable and randomly pick some part of it. So in here, I will create a new variable. I will call it all characters is equal lowercase letters, plus we can add a string together, concatenate them together, right? After that upper case letters, after that numbers, right, and after that symbols. That's it. Now, let's just show that. We say print all characters. With that done, let's just go here, go to terminal and create a new terminal. And in here, I want to say PY. Pass at tab after that, I will put the rest for you, head inter. Now, you can see, we have a string that consists of some symbol, some numbers, some upper case, and some lower case. And no, we want to randomly get some of these characters and use it as a password. Let me show you how you can do that in next. 3. 03 Use while loop: Know that we have all the characters that you want to generate password from. We need to tell the user first what this application is. After that, tell them to choose the password length. So in here, first thing that I want to do, I want to change the print. I don't want to show all the characters. I want to say, welcome to password generator, right? After that, I want to get the length of the password that user want from inputs. So I will say input. And in there, I will say, how long do you want your password to be after that question mark and after that in a space. So it looks much better. And because they will put a number there, and we need to convert it to a integer. So at the beginning here, we say int, so with this, we are converting whatever they put to integer, and after that, we can save it inside the variable. I will call it password length is equal to this, right. Now with that done, I only use a le loop, right. So for a vile loop, we need a counter. So I will create a counter first. Counter is equal to zero. And after that, use a Wil loop while Counter is less than password length. With that, first, increase the counter. You can do it at the end, but in here, just increase the counter. Counter is equal to counter plus one. Or in a set of this, we can say counter plus equal to one. It will do the same for us, right? For testing that, let's just use a print and show the counter, right? Control is to save, no, let's just run it. And it says, Welcome to password generator. How long do you want your password to be? Let's just say ten. So you can see it start let me show it to you 1-10. That's it. No, we want to find a way to generate our password easily. And there is a library that is called Random that you want to use. You try to do that. You can just search in Google, search for Random library in Python, and figure it out how you can do that, how you can generate the password, and we will do it in next video. 4. 04 Creating random password: No, for actually generating our password, what I want to do, I don't want to show the counter. In here, I want to use random library. So first, we need to import it. At top in here, I will say import random. That is our library that you want to use. And with that, we have access to the random library, and from it, what I want to use, I want to use choice, right? With this choice, we can tell it to from all the characters. Give me one character, right? So what it will do, choose a random element from a non empty sequence. So from these characters, this choice method will randomly get one character and give it to us in here. Now, with the return of this choice method, we can save it inside a variable. I will call it random. Care is equal to this. So every time it will give us another character. Let's just show that character print. Random car just like that. Control S to save. Now if we run, let's just put four in there, and now you can see it did give us uppercase Q, lowercase F, uppercase E, and six. So it did generate a password, but we need to combine all of them together. So for combining them all together, we need a variable as well. So in here, let me create a variable. I want to call it password is equal to empty string. Now, in here, I don't want to show the password. Each time I want to say password is equal password, plus random character, right? So with that done, after this while loop finishes, we can show it, right? So in here, we can say print, password. Just like that control as to say, no run. If you put four in there, you can see it did give us the password completely. Let's just run it again. For example, put ten in there. Now, you can see, it's really a good password, right? This way of doing it is good, but we can make it more professional. How we can do it like we did it for counter, we can say plus equal to the random character. It will do exactly the same thing. Let's just test that node. And if you put ten in there, you can see it did give us a password. Now, next thing that I want to do. I want to use FS string. So in here, I will say F after that double quotation. And in here, your pass word, column and space. After that, a color bracket and show the password, right? Just like that. Now if we run, let's just put 100 this time, and you can see it did give us a really long password. Let's just test it one more time. Let's just put 20, for example, and now you can see where password is this and we can copy it, right? That's a good password. Nobody can hike that, right? Congratulations on finishing this project as well.