1
00:00:03,180 --> 00:00:06,330
Next topic to be revised is code blocks.

2
00:00:06,330 --> 00:00:12,420
By code blocks I mean things like while loops for loops much case if live else.

3
00:00:13,680 --> 00:00:18,270
So these are multiple lines of code which have to stand together.

4
00:00:18,270 --> 00:00:22,350
For example, these two lines here make up a wild loop.

5
00:00:22,350 --> 00:00:28,320
So if you start with that line, you have to write the next lines indented under that line.

6
00:00:29,040 --> 00:00:31,770
So that's like a unit, a code block.

7
00:00:31,770 --> 00:00:39,810
Now, this wild loop here is an infinite loop in the sense that this will run forever because this condition

8
00:00:39,810 --> 00:00:41,130
here is always true.

9
00:00:41,130 --> 00:00:45,330
So that means this line will be executed over and over again.

10
00:00:45,330 --> 00:00:47,700
It will ask the user to enter inputs.

11
00:00:47,700 --> 00:00:57,990
Once the the user will enter that input, then it asks the user again to enter an input twice, thrice,

12
00:00:57,990 --> 00:00:58,740
etc..

13
00:01:01,590 --> 00:01:03,120
While this year.

14
00:01:04,690 --> 00:01:07,660
Will run until this.

15
00:01:08,930 --> 00:01:10,310
Condition is satisfied.

16
00:01:10,310 --> 00:01:12,890
So this is some sort of finite loop.

17
00:01:14,210 --> 00:01:16,400
So it will ask the user to enter a password.

18
00:01:16,400 --> 00:01:20,810
But if the user happens to enter, pass one in the command line.

19
00:01:23,860 --> 00:01:24,310
Van.

20
00:01:24,310 --> 00:01:31,540
This condition will not be satisfied anymore because this condition says that, Oh, run this until

21
00:01:31,540 --> 00:01:34,570
the password is different from past one.

22
00:01:34,570 --> 00:01:39,700
So if the password is the same as past one, then the loop will not run anymore.

23
00:01:40,060 --> 00:01:50,230
And after the loop runs its last iteration, then the code after the wild loop is executed.

24
00:01:50,230 --> 00:01:54,490
So in this case, password is correct will be executed.

25
00:01:54,490 --> 00:01:56,200
For example, this is what happens.

26
00:01:56,200 --> 00:01:57,790
The user enters pass.

27
00:01:59,060 --> 00:02:03,700
Pass is not the same as pass one, so the loop will run again.

28
00:02:03,710 --> 00:02:04,660
Pass two.

29
00:02:04,670 --> 00:02:05,630
It's not the same.

30
00:02:05,630 --> 00:02:06,800
The loop run again.

31
00:02:06,810 --> 00:02:07,430
Pass one.

32
00:02:07,430 --> 00:02:09,740
Yes, pass one is the same as pass one.

33
00:02:09,740 --> 00:02:12,470
So in that case the loop will not run again.

34
00:02:12,470 --> 00:02:14,900
So password is correct will be executed.

35
00:02:14,900 --> 00:02:18,170
This line here for loops.

36
00:02:18,170 --> 00:02:25,100
For loops are also loops, but they are designed to run.

37
00:02:25,790 --> 00:02:30,200
As many times as there are items in a sequence such as the list.

38
00:02:30,200 --> 00:02:32,600
So we have this usernames list here.

39
00:02:32,720 --> 00:02:35,960
And so this loop will iterate three times.

40
00:02:35,960 --> 00:02:38,240
It will go through each of these items.

41
00:02:40,910 --> 00:02:45,140
And then capitalize that item and print them out in the terminal.

42
00:02:45,410 --> 00:02:46,400
As you can see here.

43
00:02:49,580 --> 00:02:50,810
Much case.

44
00:02:54,370 --> 00:02:57,670
Match case is a controlled flow code block.

45
00:02:59,200 --> 00:03:01,010
Let's see how we would use it here.

46
00:03:01,030 --> 00:03:06,520
So this program asks the user to enter a user name, so the user enters a username sim.

47
00:03:08,950 --> 00:03:14,050
And so the program then tries to match the user's value.

48
00:03:14,050 --> 00:03:22,690
So this variable username username, it tries to match the value of that variable against several cases.

49
00:03:24,960 --> 00:03:32,760
In this case it will execute print welcome user because the user entered sim in the.

50
00:03:33,630 --> 00:03:34,710
Command line.

51
00:03:36,920 --> 00:03:46,370
So match case can be used when you are simply trying to find out if a value is the same as another value.

52
00:03:46,490 --> 00:03:57,350
But for more complex comparisons, for example, in here we have this password pass and then this conditional

53
00:03:57,350 --> 00:03:57,790
block.

54
00:03:57,800 --> 00:03:58,700
If LS.

55
00:03:58,700 --> 00:04:04,310
So this now is trying to apply a more complex condition.

56
00:04:06,390 --> 00:04:13,230
If the length of the passwords is greater than three, it will do this else.

57
00:04:13,530 --> 00:04:17,790
If it's not greater than three, it will say password is weak.

58
00:04:18,510 --> 00:04:24,180
So and if else, conditional block is more appropriate for this scenario.

59
00:04:30,620 --> 00:04:35,600
And a conditional block can also include an l if condition.

60
00:04:36,290 --> 00:04:43,010
So when you want to count for more than two cases, for example, if the length of the password is greater

61
00:04:43,010 --> 00:04:49,550
than three, print that if the length of the password is equal to four prints, password is medium.

62
00:04:49,880 --> 00:04:51,080
Otherwise.

63
00:04:52,910 --> 00:04:54,230
Password is weak.

64
00:04:55,550 --> 00:04:58,670
So this line here will only be executed when.

65
00:05:00,740 --> 00:05:02,910
This condition is not evaluated.

66
00:05:02,960 --> 00:05:03,350
True.

67
00:05:03,350 --> 00:05:06,290
And this condition also is not evaluated through.

68
00:05:08,020 --> 00:05:10,480
One more topic for this video.

69
00:05:10,570 --> 00:05:11,680
F Strings.

70
00:05:13,410 --> 00:05:22,020
Let's consider that we have some value stored in variable, or maybe some functions are producing these

71
00:05:22,020 --> 00:05:23,160
values, right?

72
00:05:24,450 --> 00:05:30,930
If you want to construct a string where you want to enter some dynamic values, for example, some strings

73
00:05:30,930 --> 00:05:33,990
which are stored in some variables or some functions.

74
00:05:36,930 --> 00:05:39,960
Then you'd use this syntax.

75
00:05:39,960 --> 00:05:47,790
So you start the string with an F in front, and then inside the string you either enter literal text.

76
00:05:49,300 --> 00:05:54,790
All you enter variables, but variables should be entered inside curly brackets.

77
00:05:55,420 --> 00:05:59,850
You can also add some simple codes in these curly brackets.

78
00:05:59,860 --> 00:06:05,770
For example, here I have the variable and I've applied the capitalized methods and this expression

79
00:06:05,770 --> 00:06:06,910
will return.

80
00:06:09,270 --> 00:06:09,900
That.

81
00:06:10,590 --> 00:06:13,290
String, but with the end capitalized.

82
00:06:13,650 --> 00:06:18,150
Of course, you can also keep it like that if you don't want any to be cannibalized.

83
00:06:21,650 --> 00:06:27,380
And of course, you can enter more than one place holder as we have here, too.

84
00:06:27,500 --> 00:06:34,880
So message now will be containing that content with Nyah and inside the string.

85
00:06:35,780 --> 00:06:42,830
You'll see how f strings will become very useful in almost every application that we will build.

86
00:06:43,880 --> 00:06:44,960
And that's above this video.

87
00:06:44,960 --> 00:06:45,650
In the next one.

88
00:06:45,650 --> 00:06:47,780
Let's look at external files.

89
00:06:47,780 --> 00:06:48,380
See you there.

