1 00:00:00,210 --> 00:00:03,810 Before we start, did you try solving the workbook yourself? 2 00:00:03,840 --> 00:00:09,600 If not, please click the link in the resources folder and follow the instructions for this workbook. 3 00:00:10,820 --> 00:00:14,810 First we have to make a for loop that counts from 0 to 19. 4 00:00:14,840 --> 00:00:15,530 Easy enough. 5 00:00:15,530 --> 00:00:19,340 We already know that the start is going to have to be zero. 6 00:00:21,260 --> 00:00:25,610 And the for loop is going to keep running so long as AI is less than 20. 7 00:00:26,800 --> 00:00:29,800 So I is still going to run for 19. 8 00:00:29,800 --> 00:00:34,510 But once it reaches 20, this condition is going to be false and the loop will break. 9 00:00:34,510 --> 00:00:38,680 And every single time the loop runs, we're going to increase the counter by one. 10 00:00:38,950 --> 00:00:45,790 And every single time we need to just print the number, I guess easy enough. 11 00:00:47,300 --> 00:00:50,570 Not going to visualize the runtime for that task. 12 00:00:50,570 --> 00:00:55,520 Number two, using an if l statement mark each number as even or odd. 13 00:00:55,670 --> 00:01:01,460 This is beautiful because we're going to be implementing some control flow inside of our for loop. 14 00:01:01,460 --> 00:01:06,650 So every time the loop runs we're going to check if the counter modulus to. 15 00:01:08,310 --> 00:01:09,390 Equals zero. 16 00:01:10,740 --> 00:01:14,420 If that's the case, then we know the number is even so we can print. 17 00:01:14,430 --> 00:01:16,890 I followed by the verdict. 18 00:01:17,690 --> 00:01:21,770 We just have to print another line and then say even. 19 00:01:23,500 --> 00:01:26,290 Otherwise we know the number is odd. 20 00:01:27,960 --> 00:01:32,880 So you'll remember that Modulus returns the remainder of a division. 21 00:01:33,060 --> 00:01:38,490 So if the number divided by two returns a remainder, that equals zero. 22 00:01:38,520 --> 00:01:40,500 We know its even, otherwise. 23 00:01:40,500 --> 00:01:41,340 It's odd. 24 00:01:41,370 --> 00:01:43,800 Now let us just visualize the runtime. 25 00:01:43,800 --> 00:01:47,550 Put one breakpoint over here and press debug. 26 00:01:50,750 --> 00:01:57,270 So I start at zero zero divided by two returns a remainder that equals zero. 27 00:01:57,290 --> 00:02:00,320 So zero is even nice. 28 00:02:01,680 --> 00:02:02,100 A-plus. 29 00:02:02,100 --> 00:02:04,380 Plus updates our counter by one. 30 00:02:06,110 --> 00:02:12,890 One divided by two does not return a remainder of zero, so else is going to get executed, which means 31 00:02:12,890 --> 00:02:14,780 the number one is odd. 32 00:02:15,880 --> 00:02:18,970 A-plus plus is going to increase our counter to two. 33 00:02:20,000 --> 00:02:26,690 Two divided by two returns a remainder of zero, which means two is even, and we can keep that going 34 00:02:26,690 --> 00:02:29,720 until we reach 19. 35 00:02:33,110 --> 00:02:37,010 And our for loop runs from 0 to 19. 36 00:02:37,010 --> 00:02:44,390 Every single time it runs, it's able to evaluate if the current number is even or if that number is 37 00:02:44,390 --> 00:02:45,080 odd.