Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,480 --> 00:00:01,630
Welcome back.
2
00:00:01,650 --> 00:00:05,920
Let's try and do an exercise to tie everything that we've learned up until now.
3
00:00:05,920 --> 00:00:10,080
Together we're going to create a password checker.
4
00:00:10,080 --> 00:00:15,970
Now what we want to do is to create some sort of an input that we're going to ask.
5
00:00:15,990 --> 00:00:18,690
So we're going to use the input function.
6
00:00:18,870 --> 00:00:23,180
And here we're going to ask for a user name.
7
00:00:23,220 --> 00:00:26,040
Then we're going to ask for another input.
8
00:00:26,040 --> 00:00:38,380
It's going to be the password and then at the end with the input we want to print something the lines
9
00:00:38,470 --> 00:00:45,900
of password and then we'll have maybe the actual password in here.
10
00:00:46,240 --> 00:00:50,950
And it will say is another variable here long.
11
00:00:51,610 --> 00:01:01,810
So what we want to do is the password and then maybe the password length so that let's say we printed
12
00:01:01,810 --> 00:01:07,570
our user name JJ and then we give it a password of secret.
13
00:01:08,200 --> 00:01:12,550
Well we should print the password.
14
00:01:12,550 --> 00:01:21,910
Secret is 1 2 3 4 5 6 letters long.
15
00:01:21,930 --> 00:01:30,410
Now obviously we all want to show or display the password maybe for security reasons.
16
00:01:30,470 --> 00:01:42,800
So we want to convert this secret to 1 2 3 4 5 6 2 stars so your task is to convert these two and puts
17
00:01:44,120 --> 00:01:44,690
And you know what.
18
00:01:44,740 --> 00:01:48,070
Let's also do a greeting where we say the user name here.
19
00:01:48,880 --> 00:02:01,680
So we're going to say Hey J.J. your password which will be marked in the star is 6 letters long.
20
00:02:01,740 --> 00:02:08,780
Now one neat trick here that you haven't learned yet and you might want to use here is this.
21
00:02:08,800 --> 00:02:10,660
They can do with strings.
22
00:02:10,780 --> 00:02:18,630
I can go star times make sure that the star is a string.
23
00:02:18,830 --> 00:02:21,430
Multiply it by 10.
24
00:02:21,680 --> 00:02:23,300
And if I print this out
25
00:02:28,190 --> 00:02:30,650
I get 10 stars.
26
00:02:30,710 --> 00:02:37,280
So you may want to use this functionality when we're doing this.
27
00:02:37,330 --> 00:02:37,740
All right.
28
00:02:37,790 --> 00:02:38,860
Positive video.
29
00:02:38,860 --> 00:02:39,690
Give it a go.
30
00:02:39,690 --> 00:02:48,790
If you can remember the goal is to print the username and have the password blocked with how many characters
31
00:02:48,790 --> 00:02:51,580
the password is.
32
00:02:51,590 --> 00:02:52,100
All right.
33
00:02:52,100 --> 00:02:52,870
Pause a video.
34
00:02:52,940 --> 00:02:59,360
If not I'm going to get going with the answer so the first thing we're gonna try and do is I'm going
35
00:02:59,360 --> 00:03:00,780
to create two inputs.
36
00:03:01,460 --> 00:03:08,100
So the first one I'm going to get the user name going to assign into the variable user name.
37
00:03:08,210 --> 00:03:13,360
And it's going to say what is your username.
38
00:03:15,000 --> 00:03:19,810
Then the second one will be the password and the password.
39
00:03:19,970 --> 00:03:28,750
Well we'll say what is your password and although this is a simple example this is something that you
40
00:03:28,750 --> 00:03:36,640
will see with other big Web sites like Instagram or maybe Netflix when you're logging in.
41
00:03:36,670 --> 00:03:40,900
So now that I've stored this information into a variable I can use it.
42
00:03:40,900 --> 00:03:41,580
Right.
43
00:03:41,680 --> 00:03:45,560
I can print and we'll do an F string to make our lives easier.
44
00:03:46,270 --> 00:03:47,860
So I've added the F here.
45
00:03:47,860 --> 00:03:59,150
And what we'll do is this will say user name your password and will add the password.
46
00:03:59,290 --> 00:04:12,650
Here is and then we'll add another variable here which is the password length.
47
00:04:12,810 --> 00:04:15,700
So how are we going to calculate that.
48
00:04:15,710 --> 00:04:17,170
Well let's try something here.
49
00:04:17,180 --> 00:04:21,670
Let's see if I can use the length function and in here.
50
00:04:21,670 --> 00:04:23,150
Do password.
51
00:04:24,380 --> 00:04:29,350
Let's see what happens here what is my username.
52
00:04:29,390 --> 00:04:33,790
Let's go with Andre what is my password.
53
00:04:33,810 --> 00:04:36,540
Let's just type in secret here.
54
00:04:37,950 --> 00:04:40,650
I get Andre your password.
55
00:04:40,780 --> 00:04:43,260
Well I can't speak English properly.
56
00:04:43,300 --> 00:04:47,150
My password secret is 6 while 6 1.
57
00:04:47,850 --> 00:04:48,400
That's right.
58
00:04:48,400 --> 00:04:53,290
6 letters long awesome.
59
00:04:53,840 --> 00:05:03,650
So this is working because with an F string I can create or add a python expression in here using the
60
00:05:03,650 --> 00:05:05,520
length password.
61
00:05:05,840 --> 00:05:07,280
But there's an issue here right.
62
00:05:07,280 --> 00:05:09,220
We don't want to actually print out secret.
63
00:05:09,220 --> 00:05:15,470
We want to print it out in these star form and this is a good discussion topping on readability of your
64
00:05:15,470 --> 00:05:16,220
code.
65
00:05:16,250 --> 00:05:22,100
Now this is a simple example but we can make this code a little bit cleaner.
66
00:05:22,100 --> 00:05:34,260
For example we can break things down so that we'll have password length will be length password.
67
00:05:34,780 --> 00:05:36,160
So we're calculating the length.
68
00:05:36,180 --> 00:05:40,490
So this is going to store 6 or whatever the input of our password is.
69
00:05:40,750 --> 00:05:42,030
And it's nice and descriptive.
70
00:05:42,040 --> 00:05:52,930
It's easy for other developers to understand and then in here I can also have hidden password and this
71
00:05:52,930 --> 00:06:03,810
hidden password will be the password length and we're going to use that star string and multiply it
72
00:06:03,990 --> 00:06:05,510
by the password length.
73
00:06:05,580 --> 00:06:12,920
Let's make this a little bit bigger so that now our code can be understood.
74
00:06:13,020 --> 00:06:15,220
Well in an easier fashion.
75
00:06:15,390 --> 00:06:21,740
So we have the password length so we're gonna say username your password password.
76
00:06:22,020 --> 00:06:25,730
But we want to make sure that it's the hidden password so we'll copy this over here.
77
00:06:27,850 --> 00:06:34,670
So username your password we're gonna print out hit and password is and then we're going to copy password
78
00:06:34,670 --> 00:06:36,140
length.
79
00:06:36,160 --> 00:06:44,040
Now I argue that this reads better because each line is doing something simple.
80
00:06:44,260 --> 00:06:46,630
And then finally we're printing the output.
81
00:06:47,480 --> 00:06:54,340
And although this is a small simple example this idea of readability and making and writing code that
82
00:06:54,340 --> 00:06:55,470
makes sense.
83
00:06:56,300 --> 00:06:57,970
Is an important concept.
84
00:06:58,310 --> 00:07:02,380
So let's see if this works when you click on my username.
85
00:07:02,660 --> 00:07:03,740
Andre.
86
00:07:03,740 --> 00:07:10,220
This time around my password is going to be super secret and look at that Andre.
87
00:07:10,430 --> 00:07:15,600
Your password did it it is eleven letters long.
88
00:07:15,610 --> 00:07:17,560
Good job getting this far.
89
00:07:17,560 --> 00:07:19,190
Hopefully you got that.
90
00:07:19,270 --> 00:07:20,500
I'll see you in the next video.
8080
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.