WEBVTT 0 00:00.270 --> 00:06.600 All right, guys, in the next lesson, I've got a leap year coding challenge for you, and this is 1 00:06.600 --> 00:12.840 a really interesting challenge. Although it is a little bit challenging, but it's really cool because 2 00:13.020 --> 00:18.900 have you ever wondered what makes a particular year a leap year and what makes another year, not a 3 00:18.900 --> 00:19.460 leap year? 4 00:19.800 --> 00:23.510 And it's easy enough to say that every four years it's a leap year. 5 00:23.880 --> 00:30.000 But if you just got given a random year and you had to work out if it was a leap year, then there's 6 00:30.000 --> 00:33.100 actually rules that you can follow to figure this out. 7 00:33.630 --> 00:42.360 So the rules are that on every year that is evenly divisible by 4, is a leap year, except every 8 00:42.360 --> 00:44.820 year that is evenly divisible by 100. 9 00:45.090 --> 00:52.710 So it's so if it's divisible by 4, but it's divisible by 100, then it's not a leap year unless 10 00:52.710 --> 00:56.690 that year is also evenly divisible by 400. 11 00:57.210 --> 01:02.850 So the rules are a little bit complex, but it might be easier if you look through some of the examples. 12 01:03.270 --> 01:09.450 So, for example, if we wanted to figure out whether if year 2000 is a leap year, 2000 divide by four 13 01:09.450 --> 01:12.460 divides cleanly, 500 with no remainder 14 01:12.600 --> 01:17.550 so it's a leap year. When we divide 2000 by 100, then it's 20 15 01:17.550 --> 01:19.260 so it also divides cleanly. 16 01:19.260 --> 01:21.170 So it's actually now not a leap year. 17 01:21.630 --> 01:27.360 But, but, but, 2000 divide by 400 equals 5 with no remainder 18 01:27.390 --> 01:30.630 so finally, it actually is a leap year. 19 01:31.140 --> 01:37.950 And you can look through the different examples and also if you scroll down, you can 20 01:37.950 --> 01:44.100 take a look at this website of known leap years and they show you step by step each of the rules that 21 01:44.100 --> 01:45.330 we talked through just now. 22 01:45.690 --> 01:50.370 And you can test different years, such as the year 2000. 23 01:50.760 --> 01:56.880 And you can see it step by step to see how they figured out whether if it is a leap year or not. 24 01:57.300 --> 02:02.520 Now, I also recommend actually watching this video that I linked to up at the top 25 02:02.850 --> 02:08.640 if you're not familiar with the concept of leap years. And even if you do understand leap years, it's 26 02:08.640 --> 02:14.940 still a fantastic video to really understand how we're adjusting for a mismatch in the Earth's rotation 27 02:15.210 --> 02:16.470 with the seasons. 28 02:16.740 --> 02:22.800 So I recommend taking a look at the video, reading through each of these statements and taking a look 29 02:22.800 --> 02:28.680 at the known leap years and the website that it links to, and then to start thinking about how you 30 02:28.680 --> 02:30.120 would write this logic. 31 02:30.570 --> 02:37.890 Now, in order to map out the logic, I recommend creating a flow chart of your own on draw.io and to 32 02:37.890 --> 02:42.010 use the flow chart to see how your code should flow. 33 02:42.420 --> 02:47.970 Now, if you want a little bit of extra help, I'm about to reveal the flow chart that I've created. 34 02:48.270 --> 02:53.580 If you want to first try to create your own and see if you get it right, then pause the video now. 35 02:54.630 --> 02:55.050 All right. 36 02:55.050 --> 02:57.460 So let's take a look at the flow chart that I created. 37 02:57.630 --> 03:02.760 If you click on this link in hint #3, you'll be taken to a page that looks like this. 38 03:03.030 --> 03:10.040 And so if we map out those rules and we click start, we see is it clearly divisible by four? 39 03:10.170 --> 03:12.420 If no, then it's definitely not a leap year. 40 03:13.020 --> 03:15.450 But if it is, then we have to check the next thing. 41 03:15.780 --> 03:17.930 Is it cleanly divisible by 100? 42 03:18.390 --> 03:18.900 No. 43 03:18.910 --> 03:20.630 Well, then it's definitely a leap year. 44 03:20.670 --> 03:23.430 But if it's yes, then we have to check the final thing. 45 03:23.910 --> 03:26.220 Is it cleanly divisible by 400? 46 03:26.520 --> 03:28.150 If yes, then it's a leap year. 47 03:28.200 --> 03:30.120 If no, it's not a leap year. 48 03:30.300 --> 03:34.880 And that flow chart basically translates these three lines of logic. 49 03:35.370 --> 03:40.380 Now, if English is not your first language, then I recommend to take a look at the flow chart and 50 03:40.380 --> 03:44.040 also take a look at the rules for a leap year in your own language. 51 03:44.670 --> 03:50.400 But once you're happy that you understand what's going on, then it's time to tackle the challenge and 52 03:50.400 --> 03:51.280 write your code. 53 03:51.810 --> 04:00.210 Now, remember, you have to output exactly the words 'Leap year.' or 'Not leap year.' 54 04:00.210 --> 04:05.010 and look at the capitalization and where the spaces and full stops go. 55 04:05.490 --> 04:10.310 That way, when you check solution, you'll actually be able to pass your code if everything is correct. 56 04:10.800 --> 04:14.490 So head over to the next lesson and tackle this challenge now.