1 00:00:01,170 --> 00:00:05,450 Hello and welcome back to the next video of this course in programming cities. 2 00:00:05,490 --> 00:00:10,010 Now in this video we will learn about the control statements in case of Cartland. 3 00:00:10,020 --> 00:00:16,050 Now there are some changes in Gears of control statements in case of Cartland such as we can use the 4 00:00:16,050 --> 00:00:21,000 if else condition as an expression an insert of switch statement. 5 00:00:21,030 --> 00:00:24,150 We have re-instatement in case of Cartland. 6 00:00:24,330 --> 00:00:29,220 So let us first check out the if else conditional statements in case of Cartland. 7 00:00:29,220 --> 00:00:34,560 Now here I have simply defined two values equal to do and be equal to 5. 8 00:00:34,560 --> 00:00:38,990 Now here I will simply define a valid max value. 9 00:00:39,210 --> 00:00:40,470 Let's see in. 10 00:00:40,810 --> 00:00:42,090 And now down the side. 11 00:00:42,090 --> 00:00:42,940 I was simply write. 12 00:00:42,990 --> 00:00:53,890 Typical if else condition if it is greater than B then simply assign max value equal to a right and 13 00:00:53,890 --> 00:01:04,190 then is max value equal to B and then finally we are simply going to print the max value right. 14 00:01:04,420 --> 00:01:06,790 Let us note in the chord. 15 00:01:07,000 --> 00:01:14,590 So here in the outbuild we get 5 so we have simply written code to find the maximum value of these two 16 00:01:14,680 --> 00:01:18,520 numbers and B right now in Cartland we have. 17 00:01:18,620 --> 00:01:20,140 If expressions. 18 00:01:20,140 --> 00:01:23,560 Now we can use the if condition as an expression. 19 00:01:23,620 --> 00:01:25,350 So how to do that. 20 00:01:25,780 --> 00:01:33,730 So in that case instead of defining the max value here what we do is simply assign it to the max value 21 00:01:33,880 --> 00:01:34,860 directly. 22 00:01:34,960 --> 00:01:38,210 And here I will simply remove it. 23 00:01:38,340 --> 00:01:43,030 The max value and now leads straight to clean up our record. 24 00:01:43,050 --> 00:01:45,600 So here what I am doing is this. 25 00:01:45,670 --> 00:01:47,310 If as an expression. 26 00:01:47,400 --> 00:01:56,040 Now if it is greater than B then simply return a and assign it to the max value variable is simply returned 27 00:01:56,070 --> 00:02:01,170 B which is the maximum value and assign it to this very bill and at the end. 28 00:02:01,170 --> 00:02:02,720 Simply put into value. 29 00:02:02,720 --> 00:02:10,700 Let us note in the chord so in the output again we get 5 so in Scotland we can make the if condition 30 00:02:10,760 --> 00:02:12,380 to return some value. 31 00:02:12,380 --> 00:02:18,800 Now suppose if I have the multiple lines of code inside the if condition so which value will be returned 32 00:02:18,890 --> 00:02:21,770 and stored to the max value variable. 33 00:02:21,770 --> 00:02:24,000 Now suppose I have a quarter block. 34 00:02:24,110 --> 00:02:25,820 So here what do I have is. 35 00:02:25,880 --> 00:02:30,860 I am having the cord block if condition here and inspired here. 36 00:02:30,980 --> 00:02:35,110 Now I suppose if I have multiple lines of code here let's see. 37 00:02:35,120 --> 00:02:44,440 Print is greater and simply copy the word from here and pasted here and here. 38 00:02:44,450 --> 00:02:47,230 Simply put in B is greater right. 39 00:02:47,390 --> 00:02:53,000 So in this situation where we have multiple lines of code within the if block and also as log. 40 00:02:53,120 --> 00:02:55,670 So which of the following will we return. 41 00:02:55,670 --> 00:02:56,840 Now as for the rule. 42 00:02:56,840 --> 00:03:01,550 The last statement that is defined inside the if condition will be returned. 43 00:03:01,700 --> 00:03:06,690 So here the last part is a and here the last piece of cord is B. 44 00:03:06,830 --> 00:03:10,770 So here it will be returned and here B will be returned. 45 00:03:11,030 --> 00:03:14,520 So this code will be executed and then it will be returned. 46 00:03:14,540 --> 00:03:18,780 And similarly this code will be executed and then B will be returned. 47 00:03:19,100 --> 00:03:21,430 And now let us run the code. 48 00:03:21,500 --> 00:03:28,590 So here we get B is greater and at last we are printing the value of max value variable right. 49 00:03:28,970 --> 00:03:34,160 So in this way we are actually using the condition as the expression. 50 00:03:34,160 --> 00:03:37,000 Now this if condition is returning some value. 51 00:03:37,130 --> 00:03:40,220 So that is why we call it if as expression.