Next topic to be revised is code blocks.
By code blocks I mean things like while loops for loops much case if live else.
So these are multiple lines of code which have to stand together.
For example, these two lines here make up a wild loop.
So if you start with that line, you have to write the next lines indented under that line.
So that's like a unit, a code block.
Now, this wild loop here is an infinite loop in the sense that this will run forever because this condition
here is always true.
So that means this line will be executed over and over again.
It will ask the user to enter inputs.
Once the the user will enter that input, then it asks the user again to enter an input twice, thrice,
etc..
While this year.
Will run until this.
Condition is satisfied.
So this is some sort of finite loop.
So it will ask the user to enter a password.
But if the user happens to enter, pass one in the command line.
Van.
This condition will not be satisfied anymore because this condition says that, Oh, run this until
the password is different from past one.
So if the password is the same as past one, then the loop will not run anymore.
And after the loop runs its last iteration, then the code after the wild loop is executed.
So in this case, password is correct will be executed.
For example, this is what happens.
The user enters pass.
Pass is not the same as pass one, so the loop will run again.
Pass two.
It's not the same.
The loop run again.
Pass one.
Yes, pass one is the same as pass one.
So in that case the loop will not run again.
So password is correct will be executed.
This line here for loops.
For loops are also loops, but they are designed to run.
As many times as there are items in a sequence such as the list.
So we have this usernames list here.
And so this loop will iterate three times.
It will go through each of these items.
And then capitalize that item and print them out in the terminal.
As you can see here.
Much case.
Match case is a controlled flow code block.
Let's see how we would use it here.
So this program asks the user to enter a user name, so the user enters a username sim.
And so the program then tries to match the user's value.
So this variable username username, it tries to match the value of that variable against several cases.
In this case it will execute print welcome user because the user entered sim in the.
Command line.
So match case can be used when you are simply trying to find out if a value is the same as another value.
But for more complex comparisons, for example, in here we have this password pass and then this conditional
block.
If LS.
So this now is trying to apply a more complex condition.
If the length of the passwords is greater than three, it will do this else.
If it's not greater than three, it will say password is weak.
So and if else, conditional block is more appropriate for this scenario.
And a conditional block can also include an l if condition.
So when you want to count for more than two cases, for example, if the length of the password is greater
than three, print that if the length of the password is equal to four prints, password is medium.
Otherwise.
Password is weak.
So this line here will only be executed when.
This condition is not evaluated.
True.
And this condition also is not evaluated through.
One more topic for this video.
F Strings.
Let's consider that we have some value stored in variable, or maybe some functions are producing these
values, right?
If you want to construct a string where you want to enter some dynamic values, for example, some strings
which are stored in some variables or some functions.
Then you'd use this syntax.
So you start the string with an F in front, and then inside the string you either enter literal text.
All you enter variables, but variables should be entered inside curly brackets.
You can also add some simple codes in these curly brackets.
For example, here I have the variable and I've applied the capitalized methods and this expression
will return.
That.
String, but with the end capitalized.
Of course, you can also keep it like that if you don't want any to be cannibalized.
And of course, you can enter more than one place holder as we have here, too.
So message now will be containing that content with Nyah and inside the string.
You'll see how f strings will become very useful in almost every application that we will build.
And that's above this video.
In the next one.
Let's look at external files.
See you there.