00:01
Okay, good day, ladies and gentlemen.
00:05
This is problem number 8 .3 from the book on python.
00:11
And this problem specifically asked us to create a program that checks a password.
00:21
So this program has four different parts to it, particularly it wants us to drop the user for a password.
00:30
Okay, so how do you? you do this? well, the best way to do it, i think, and this is pretty much a standard way to do it, is in your console, you just want to go, maybe we'll call it pass.
00:47
This is what our password's going to be called.
00:51
It's going to be equal to input.
00:57
Enter a password.
00:59
Enter password.
01:09
The input function just takes user input and stores it into the as a string i should emphasize it takes user input and stores it in the variable pass so it takes in a string it takes in input it stores it as a string and and then you can use this variable in the rest of your program okay and and the next step, the next thing we have to do is we have to check the length.
01:45
So to check the length, now what that means is what i have to do is the, so with this, with a lot of like a lot of the different data structures in python, there's a simple, there's a simple function.
02:08
It's called length or l -e -n.
02:10
Of pass.
02:13
So length of pass will check the length of the password.
02:19
And we want it to be greater than eight characters.
02:24
So we want this to be greater than or equal to eight.
02:31
Okay.
02:33
And the next condition we have to check is we have to check that the password only contains letters and digit.
02:41
Now, this is an interesting issue, okay? so how would you check that the password contains only a digit? well, this means particularly that when we check the password, so suppose our password is a, b, c, d, e, f, okay? so this is equal to pass, pass is equal to that.
03:10
Then our program has to check and see when it's when it iterates through the when it's going through the various entries of the path of the password they have to be all carrot letters or digits so in particular then one way to do that is to use the the module will what they call is alpha numb.
03:45
So is l numb? is l numb will check to make sure that password checks, returns returns true if password is letters and numbers and false otherwise.
04:17
And false otherwise.
04:18
So in particular, then, we want pass is numb to equal to true.
04:31
So we want pass, we want this to be true.
04:42
So we want this to equal to true.
04:48
Okay.
04:51
Now, the last condition we have to check on is we have to check.
04:56
And make sure that it contains at least two digits.
05:03
So how would you check to see whether or not pass contains one digit? well, what i was thinking about is what i want to do is to check if pass has one digit in it.
05:29
I can just iterate through, iterate through the characters of pass.
05:48
And if the character is a digit, is a digit, then my counter will be, will add one to it.
06:10
So in other words, i would add, i'm going to count the number of digits in the, i'm going to count the number of digits in the character by literally passing through each character in the digit and counting one to a counter if i come across any digits.
06:34
And then what i want is in particular is the counter to be in this case to be greater than or equal to two.
06:45
Okay, so what counter will do, counter is counter counts the number of counts the number of digits in pass.
07:11
Okay, so in particular then, this one i need to actually do, i actually need to write an algorithm or a, sorry, a little routine to do this.
07:27
And now how do i do that? well, first off, probably what i want to do is i'm going to set my counter to equal to zero.
07:35
So starting out, i'm going to just set my counter equal to zero.
07:38
Okay, and then one and then i'm going to go for k in the range of zero to, of course, the length of password, because i don't know what that length is, but i'm going to, i want to pass through each character.
08:07
Okay.
08:08
Now what do i, how do i, now what do i want to do? if password of k, so in other words, that particular character in the password is digit equals to true, but what is this statement referred to? well, it's saying that it's the kath entry of my password is a digit because that's what is digit checks.
08:50
For if it is a digit so in other words this is true what am i going to do well if it is a digit then of course like i said i want to add one to the counter i'm going to go counter plus equals to one okay and it's this this this this little routine here so this oops um okay this this sort of routine here what it's going to do is it's going to, it's going to count the number of the number of digits in my password.
09:50
And of course, once it's done, so once it's iterated through, once it's iterated, once the routine, is iterated through.
10:07
So once the routine is iterated through, well, i want, then my hope is, or if the password is good, password is good if counter is greater than two, or greater than or equal to two...