1 00:00:00,330 --> 00:00:02,190 Bichon Break STICKMAN. 2 00:00:03,280 --> 00:00:09,280 So in this video, we are going to discuss that use of public statement, what is the required syntax 3 00:00:09,280 --> 00:00:12,460 to write the brick statement and when should use the bricks? 4 00:00:12,460 --> 00:00:14,200 That statement in our python coding. 5 00:00:14,800 --> 00:00:20,320 So in Python, brick and continuous statements can alter the flow of a normal loop in this video will 6 00:00:20,320 --> 00:00:24,180 be considering the brick statement in the next video will be discussing the continuum. 7 00:00:24,340 --> 00:00:30,640 But this break and continue these two statements can alter the normal flow of a loop. 8 00:00:31,300 --> 00:00:35,460 The loops iterate over a block of code until test exhibition is false. 9 00:00:35,770 --> 00:00:39,130 So until the test expression is false, the loop will go on executing. 10 00:00:39,400 --> 00:00:45,670 But sometimes the wish to terminate the current iteration or even the while, even the whole loop without 11 00:00:45,670 --> 00:00:47,870 checking the test expression. 12 00:00:48,130 --> 00:00:54,340 So if they want to alter the sequence, if it come out from the loop construct, even if the test expression 13 00:00:54,340 --> 00:00:57,120 is true, I can go for this break statement. 14 00:00:57,520 --> 00:01:02,290 So the break and the continuous statements that are used in these cases, whenever you are trying to 15 00:01:02,290 --> 00:01:05,300 alter the flow of control in a in a loop body. 16 00:01:07,430 --> 00:01:14,060 Brigs stickpin syntax in Python, the bricks department dominates the loop containing it, control of 17 00:01:14,060 --> 00:01:18,240 the program flows to the statement immediately after the body of the loop. 18 00:01:18,470 --> 00:01:19,880 So let us suppose that is the loop. 19 00:01:20,180 --> 00:01:22,720 The loop having multiple statements are written. 20 00:01:22,820 --> 00:01:24,290 So there is one blek is there? 21 00:01:24,470 --> 00:01:29,270 And when the break will get executed, then the next statement after the loop will get the control. 22 00:01:29,570 --> 00:01:35,360 So that immediate statement after this loop body will get the control because the controller is coming 23 00:01:35,360 --> 00:01:40,660 out from this loop and it will come to the line, which is just after this loop construct. 24 00:01:41,270 --> 00:01:46,640 If the public statement is inside a nested loop, that is a loop inside the loop, then break will dominate 25 00:01:46,640 --> 00:01:49,760 the innermost loop and control will come to the outer loop. 26 00:01:49,760 --> 00:01:52,130 In that case, how to write the public statement. 27 00:01:52,310 --> 00:01:54,470 All letters must be in lowercase. 28 00:01:54,650 --> 00:01:59,330 So be R, so all letters must be in the lowercase to write the statement. 29 00:02:02,140 --> 00:02:03,320 Flowchart of brick. 30 00:02:04,150 --> 00:02:09,940 So here the computer will come in getting into the loop so that now the highest expression of the loop 31 00:02:09,940 --> 00:02:15,840 in the condition is false, then obviously there is no need to execute the loops or exit loop address. 32 00:02:16,150 --> 00:02:19,780 If it is when it is true, then it will be checked with the brick statement. 33 00:02:19,780 --> 00:02:20,440 Is there or not. 34 00:02:20,600 --> 00:02:23,470 If the brick statement is there, then it will exit the loop. 35 00:02:23,470 --> 00:02:29,340 Otherwise, when the brick statement is not there, then remaining body of the loop will get executed 36 00:02:29,500 --> 00:02:35,950 and this process will be repeated until this test expression is producing false or if there is some 37 00:02:35,950 --> 00:02:38,320 Brigstock when it will come out from this loop. 38 00:02:38,320 --> 00:02:39,460 That is the exit loop here. 39 00:02:39,820 --> 00:02:43,090 So for the better understanding, let us go for one practical demonstration. 40 00:02:43,270 --> 00:02:49,200 There will be Schwing using some coding that how this Brick Teckman can be used by Tom. 41 00:02:50,450 --> 00:02:56,990 In this demonstration, we are discussing the use of public statement in by conquering so import, import 42 00:02:56,990 --> 00:03:04,580 random, as are all these ileus, we are importing the random model and Raynham is a call to our daughter 43 00:03:04,590 --> 00:03:11,870 and arrange one of 20 different range method will generate a random number in between one to 19 because 44 00:03:11,870 --> 00:03:16,400 20 will be the exclusive limit and wanting to be the inclusive lower limit. 45 00:03:17,060 --> 00:03:22,070 So the number to be guests, whatever the value is getting generated in between one to 19, which will 46 00:03:22,160 --> 00:03:25,250 be assigned to random and random, is getting printed here. 47 00:03:26,000 --> 00:03:30,530 So I is equal to one like that, which we are falling in an infinite loop. 48 00:03:30,530 --> 00:03:33,020 So we will be executing an infinite loop. 49 00:03:33,390 --> 00:03:33,770 True. 50 00:03:34,250 --> 00:03:37,030 So Pynt, no guest isso valuable. 51 00:03:37,030 --> 00:03:39,550 I will get printed so exposed to one here. 52 00:03:39,950 --> 00:03:42,350 So if I is to run numbers. 53 00:03:42,350 --> 00:03:49,280 So whenever this random is equal to I, in that case we are printing this statement and a rickman's 54 00:03:49,280 --> 00:03:55,220 the public statement is getting executed and this statement actually stops the loop and exits from the 55 00:03:55,220 --> 00:03:59,240 loop as it will other the value of I will get increased by one. 56 00:03:59,240 --> 00:04:02,100 I need to get prepared itself for the next iteration. 57 00:04:02,480 --> 00:04:04,390 So let us go for the execution. 58 00:04:05,090 --> 00:04:09,890 So here you can find that the number who has been guest in between one to 19 eSport. 59 00:04:10,310 --> 00:04:13,520 So this is called the one the loop has got executed for. 60 00:04:14,040 --> 00:04:18,620 The loop has got executed for three also for also the loop has got executed. 61 00:04:18,620 --> 00:04:23,180 But when the food is basically random, that is also containing food. 62 00:04:23,480 --> 00:04:24,610 So food is going to fall on. 63 00:04:24,650 --> 00:04:32,030 The condition is true that just coming out from this while constructor after printing this line, a 64 00:04:32,080 --> 00:04:36,940 random number has been gainst successfully and then we are exiting from this while. 65 00:04:37,100 --> 00:04:39,470 So now if you write down a statement after this. 66 00:04:41,780 --> 00:04:46,670 If you read this statement after this, you can find that the statement will get printed. 67 00:04:46,700 --> 00:04:49,500 So now here here's the random number has guessed number 12. 68 00:04:49,550 --> 00:04:55,670 The loop has got excluded for is to want to do a random number, has been guessed successfully and then 69 00:04:55,670 --> 00:04:57,780 end up the program is getting executed. 70 00:04:58,310 --> 00:04:59,870 So in this, we discussed that. 71 00:04:59,870 --> 00:05:01,270 What is the purpose of Blake? 72 00:05:01,280 --> 00:05:07,610 Mixtec minutes actually stop start looping and then it will exit from the loop construct. 73 00:05:08,030 --> 00:05:13,610 And using this python demonstrated the use of break in our respective example. 74 00:05:14,340 --> 00:05:15,500 Thanks for watching this video.