Hi, everyone. In this module, we are studying "Control Statement". Control statements are used to control the data processing process. So, the control statement is a component of three statements. One is "if", "elif", "else" statement. Obviously we already studied if-clause and if-else statement. Those three are belonging to the same control statement based on the if clause. So I'm going to explain today "if", "elif" and "else" statement. And I'm adding two more "while loop" and "for loop". Those are two statements very fundamental in pure Python or standard library of Python. And "break" and "continue" often use with "while" and "for" loops. So that's why I'm also explaining the concept of a "break" and "continue". Then let me introduce "augmented assignment" and "formatted string". Those are also basic tools of coding. That's why I'm introducing them here. And then two more built-in functions are introduced. Those two built-in functions are very often used in coding. The "range" function and "len" function. Len is a shortened word of length. So, it simply returns the number of items in a sequence. So, counting the length of the dataset. Then, in the middle of explaining the control statement, I'm going to also introduce the basic concept of a "list". This is very important building block of Python coding. So later we are going to study in detail "list" data type, "list" object. Now, let's get into the first topic we are going to study. If-elif-else statement, here is an example. So, based on temperature, we are identifying what season it is. So here's the input function it asks us "What is today's temperature in Celsius?" Then probably someone will provide the number. It converted into an integer, and it is assigned to the "temp" variable, right? Then the "if" condition begins. If the temp is greater than or equal to 25, "It is Summer", the sentence will be printed. If the temperature is less than 25 and greater than 10, then "It's Spring or Fall" will be printed. And if the number is less than 10, then "It's Winter" statement will be printed. So basically if-elif-else statement is dividing the whole number into three mutually exclusive subgroups. One is greater than or equal to 25. The other group is less than 25 and greater than or equal to 10. And the last group is less than 10. So, using if-elif-else, we can divide the whole range of numbers into three groups. So, let me execute this cell. It's asking a number, then"34". And "It's summer" is printed. So, you can type in any number, but any number can belong to either one of the three groups, right? Here's "if" statement. Five "if" statements are written. So using these five if statements, I am trying to classify, or I am trying to convert total grades into a letter grade. So, asking a number, a grade, a total grade. Then someone will type total grade here. Then, the number that information is converted into a floating number. And then, it is assigned to the "grade" variable. If the grade is greater than or equal to 90, "A" is printed. Less than 90 and greater than or equal to 80, it is "B". Then there is "C" and "D". And if the grade is less than 60, "F" will be printed. So, let's execute, [typing] "86" so "B" is returned. And you can type in any number like "50" "F". The grade ranges from zero to 100. The whole range is subdivided into five groups, mutually exclusive five groups. They are created based on five "if" statements. But let's change a little bit the code, because you already studied "if-else" statement. What about we use "else" instead of the last "if" statement? So activate "else" and the last two code lines. And make the right above two code lines dormant. So, it is not working anymore. Now let's execute, like "91". But the problem here is that "A" and "F" is printed together. Why did it happen? So then again, what about 75? "C" and "F". Hmm, something wrong, right? What about "65"? Then in this case only "D" is printed. This is what I actually wanted to get. But what about like 45? "F". So if you give a number that belongs to the last group between 70 and 60. "D" is printed without any problem. If you type a number less than 60, "F" is returned. Working correctly! But if you type in any number above, above "70", then two grades, letter grades are printed like "82", "B", and "F". It means that, this coding is wrong not correct. What is the cause of that problem? Think about it. Why did that happen? Because "else", this "else" matching with right above, immediately above "if" clause. So whenever right above "if" clause is not satisfied, "else" is activated. So if you type "91", this "if" clause is satisfied. "A" is printed. Then the second line is also checked, not satisfied, no action. The third "if" clause is also checked, not satisfied. So no action. "if" the last "if" clause is checked, not satisfied. So, no action. If this "if" clause is not satisfied, then "else" is activated and "F" is printed. That's the problem. That's causing that problem. So how can we avoid this kind of errors in coding? The first rule is if you are using multiple "if" clauses, don't use "else" together. Use only "if" clauses. Another alternative I'll explain soon. Think about again, in this cell, you are executing this cell. Then each line is interpreted and computer checking if the conditions are satisfied or not. Then line by line it is checked, and the answer is returned. Because four if-clauses are not belonging to one block of coding, they are separate lines actually. So, line by line is checked. Then what about we use this method, if-elif-else statement? We are doing the same job with if-elif-else statement. Asking any number between 0 and 100, that is the total grade. Then letter grade is assigned to that total grade. In this case, if you look at "elif" statement, the condition statement is simpler than before. Because minimum values are only stated in this case. Using this if-elif-else statement, the whole grade range between 0 and 100 is subdivided into five groups. They are mutually exclusive. But rather than using five "if" clauses, using if-elif-else statements, we can do the job more efficiently. In this case, if we are using elif statement, whenever a condition is met, whenever a condition is satisfied, the process is done. Stops there and then asking another number. So this is faster than the cases with only "if" statements. That's why if-elif-else is used often quite a lot in coding. Especially when you are trying to subdivide the whole range of groups into multiple pieces, using if-elif-else statement is a good choice. Now, before closing this video clip, let me ask a review question. True or False: it is better to not use "else" if you are using multiple if conditions. Oh, this is what I just explained while I am teaching if-elif-else, statement. If multiple ifs are used, then don't use else because it creates an error in many cases. So, but if you are using else then, it should be used only with one if. If or else you are dividing the whole group into two mutually exclusive subgroups. In that case use if and else.