WEBVTT 0 00:01.230 --> 00:06.870 I'll come back in this lecture I'm going to show you how you can use boolean expressions in a suchit 1 00:08.400 --> 00:12.920 that's not I'm going to create a simple code. 2 00:13.160 --> 00:17.280 Well tell us about whether a number is positive negative or zero. 3 00:17.680 --> 00:24.910 This type of sui state and again like this is so we just condition this time instead of a variable. 4 00:25.030 --> 00:29.120 I'm going to type a boolean value through ok. 5 00:29.180 --> 00:32.250 At I case clouds like this. 6 00:32.370 --> 00:36.580 Let's assume that it is an integer reachable declared somewhere. 7 00:36.990 --> 00:44.510 If it's positive than the bool expression be true right then it will be equal to this we just condition 8 00:44.750 --> 00:46.190 because it's true as well. 9 00:48.360 --> 00:50.070 So it will be executed 10 00:53.000 --> 00:56.150 writes OK on you. 11 00:56.150 --> 01:02.750 Remember this the type so if the case conditions should be identical to the type of the each condition 12 01:02.800 --> 01:03.880 right. 13 01:04.040 --> 01:10.640 So since a type of serious condition is bool so I can type a case condition as a bold expression as 14 01:10.640 --> 01:14.130 you know Eble expression yields Zabiullah value. 15 01:14.130 --> 01:21.060 I can type such a bold expression because the beaches condition is all bull go guess is the type of 16 01:21.060 --> 01:28.150 the condition expression from this value just true not both the type of the sweetness condition and 17 01:28.150 --> 01:29.720 the k's condition. 18 01:29.850 --> 01:30.770 Har bool. 19 01:31.330 --> 01:38.090 You can type in Boola expression as a case condition OK let's add one more case clause here. 20 01:39.780 --> 01:46.050 Look at another case clause to detect and to rable All right. 21 01:46.170 --> 01:50.160 Now let's add another case or the zero to do that. 22 01:50.280 --> 01:53.090 I can add a default clause instead of a case clause. 23 01:53.220 --> 01:55.850 It's because there are no more options left. 24 01:56.220 --> 02:02.970 A number can be positive or negative but can't be boffed right so it should be zero and the default 25 02:02.970 --> 02:06.180 clause is great for detecting that OK. 26 02:06.210 --> 02:11.370 This switch statement works because go wrong a switch statements from top to bottom. 27 02:11.590 --> 02:18.350 It first tries the first case condition at the top then it tries the next one and the next and so on. 28 02:18.590 --> 02:23.450 And if none of the case clauses match then it goes and executes the default class. 29 02:23.590 --> 02:28.670 Of course if there is one by the way one more thing is left to do Ingo. 30 02:28.840 --> 02:32.140 So which is condition by default is true. 31 02:32.350 --> 02:35.000 So you don't need to type 2 as a condition. 32 02:35.140 --> 02:38.950 Let's remove the true value here from the condition like this. 33 02:40.510 --> 02:43.040 Better now it's more concise. 34 02:43.120 --> 02:44.970 The same rules still apply. 35 02:45.920 --> 02:53.900 Since the switches condition is a bull value so all the case conditions also should be bool expressions. 36 02:54.470 --> 02:58.130 All right now this statement is ready. 37 02:58.250 --> 03:00.280 Let's take a look at it inside the code editor 38 03:05.600 --> 03:06.090 OK. 39 03:06.160 --> 03:10.960 Here it is this change the comments to printed on colors instead. 40 03:11.910 --> 03:13.340 I'm fast forwarding. 41 03:13.710 --> 03:16.830 All right OK ready let's run it now. 42 03:19.750 --> 03:26.410 It says positive because the IRA airball is tyin it has a positive number of Wisley OK. 43 03:26.410 --> 03:27.780 Now let's make its negative 44 03:30.820 --> 03:31.770 and run it again. 45 03:33.080 --> 03:38.920 No it prints negative unless the let's make it 0 and 1. 46 03:40.090 --> 03:41.960 This time it prints 0. 47 03:42.040 --> 03:48.870 It works good ok you learnt how boolean expressions work with switch statements. 48 03:48.870 --> 03:50.460 Seen the next picture of a.