1 00:00:00,180 --> 00:00:07,419 Hi, let's take a test on programming, how programs work. 2 00:00:08,560 --> 00:00:15,419 So, this animation shows a program, yes, not a flowchart, and a program running. 3 00:00:15,519 --> 00:00:18,079 It's a program, but in this case the program is running. 4 00:00:21,000 --> 00:00:28,500 Okay, each block of this program represents two answers, a step, a step on the process, yes, 5 00:00:28,500 --> 00:00:31,679 an instruction, yes, instructions in the program 6 00:00:31,679 --> 00:00:35,500 it's not a process, algorithm or flowchart 7 00:00:35,500 --> 00:00:41,420 ok, the same program 8 00:00:41,420 --> 00:00:44,219 two answers, in this program 9 00:00:44,219 --> 00:00:49,439 what the program does is to draw a square, a simple 10 00:00:49,439 --> 00:00:52,920 square, the user doesn't enter anything 11 00:00:52,920 --> 00:00:57,219 because everything is here, internally 12 00:00:57,219 --> 00:01:01,299 in the program, let's see, so there is no input 13 00:01:01,299 --> 00:01:05,379 data, yes, the user enters, the user 14 00:01:05,379 --> 00:01:09,200 doesn't enter anything, there is no output, there is an output, a square 15 00:01:09,200 --> 00:01:12,920 there is no end, yes, we have here the stop 16 00:01:12,920 --> 00:01:21,319 and the output is a square, good, the output we said 17 00:01:21,319 --> 00:01:24,980 is a square and the length of each 18 00:01:24,980 --> 00:01:27,659 side is 200 steps 19 00:01:27,659 --> 00:01:34,459 okay so it's a 200 by 200 step square 20 00:01:34,459 --> 00:01:40,540 and instead of a square if we want to draw a rectangle 21 00:01:40,540 --> 00:01:42,420 we need to change something 22 00:01:42,420 --> 00:01:48,099 we need to change not the first move 200 steps 23 00:01:48,099 --> 00:01:51,840 but the second one instead of 200, 300 24 00:01:51,840 --> 00:01:57,319 so we need to change two blocks 25 00:01:57,319 --> 00:02:15,370 move 200, 2 move 300. Odd and even numbers. Odd numbers are 1, 3, 5, 7. Even numbers are 2, 4, 6, 8. 26 00:02:16,090 --> 00:02:23,449 Okay, have a look at the program and if the user enters number 1, the output has to say, 27 00:02:23,449 --> 00:02:26,349 the output has to be 28 00:02:26,349 --> 00:02:30,349 1 is an even or odd number 29 00:02:30,349 --> 00:02:33,629 we said odd numbers are 1, 3, 5 30 00:02:33,629 --> 00:02:36,030 so the output has to be 31 00:02:36,030 --> 00:02:38,610 1 is an odd number 32 00:02:38,610 --> 00:02:43,330 1 is an even, 1 is an odd number 33 00:02:43,330 --> 00:02:48,930 the same, but instead of 1, 4 34 00:02:48,930 --> 00:02:50,949 4 is an even number 35 00:02:50,949 --> 00:02:52,990 2, 4, 6 36 00:02:52,990 --> 00:02:58,969 so 4 is an even number 37 00:02:58,969 --> 00:03:01,870 the same, have a look 38 00:03:01,870 --> 00:03:07,050 and when the user enters number 3, that is a not number 39 00:03:07,050 --> 00:03:10,569 the repeat until block is repeated 40 00:03:10,569 --> 00:03:15,490 repeat until block, this is the repeat until block 41 00:03:15,490 --> 00:03:20,439 this block, ok, so when we enter 42 00:03:20,439 --> 00:03:43,560 number 3, okay, n is 3, so, is not 0, no, minus 1, so, no, no, and now n is 3, minus 2, is 1, and go back, here, go back, is n, now is 1, 43 00:03:43,560 --> 00:03:53,199 0, minus 1, minus 1, no, so no, no, that is the second time we are doing this 44 00:03:53,199 --> 00:04:00,000 and n now is 1, minus 2, that is minus 1 45 00:04:00,000 --> 00:04:05,560 so n goes back again, and now n is minus 1 46 00:04:05,560 --> 00:04:09,680 so we stop, we don't have to do this 47 00:04:09,680 --> 00:04:16,560 So how many times did the program run this loop? 48 00:04:16,939 --> 00:04:18,939 Two times, twice 49 00:04:18,939 --> 00:04:21,319 Two times 50 00:04:21,319 --> 00:04:27,899 Now we enter number 6 51 00:04:27,899 --> 00:04:28,959 Let's see 52 00:04:28,959 --> 00:04:31,600 n is number 6 53 00:04:31,600 --> 00:04:33,899 No one of these 54 00:04:33,899 --> 00:04:36,300 So no, no, no, no 55 00:04:36,300 --> 00:04:37,420 One time 56 00:04:37,420 --> 00:04:40,079 6 minus 2 is 4 57 00:04:40,079 --> 00:04:40,839 And back 58 00:04:40,839 --> 00:04:44,459 Now, no, no, no, no, no, second time 59 00:04:44,459 --> 00:04:48,259 4 minus 2 is 2, and back 60 00:04:48,259 --> 00:04:53,279 No, so no, no, no, no, no, that is the third time 61 00:04:53,279 --> 00:04:57,000 2 minus 2 is 0, go back 62 00:04:57,000 --> 00:05:01,339 When n is 0, we don't repeat again, so 3 times 63 00:05:01,339 --> 00:05:05,819 We repeat the sequence 3 times 64 00:05:05,819 --> 00:05:11,060 Comparing numbers 65 00:05:11,060 --> 00:05:34,269 So, in this program the inputs, the inputs is what the user enters, and what the user enters is number 1, enter number 1, and enter number 2. Number 1, number 2, the variables. So, number 1 and number 2. 66 00:05:34,269 --> 00:05:38,670 Possible outputs for this, so we compare two numbers 67 00:05:38,670 --> 00:05:42,810 and the output is what the program shows 68 00:05:42,810 --> 00:05:45,310 and the program says, okay 69 00:05:45,310 --> 00:05:50,389 number one is less than number two, or they are the same number, they are equal 70 00:05:50,389 --> 00:05:53,589 or number one is greater 71 00:05:53,589 --> 00:05:59,189 than number two, these are the three possible outputs 72 00:05:59,189 --> 00:06:02,759 less than 73 00:06:02,759 --> 00:06:06,759 the same number, and greater than 74 00:06:06,759 --> 00:06:16,490 we are using the same program 75 00:06:16,490 --> 00:06:20,490 the user enters 3 and 7, number 1 is 3 76 00:06:20,490 --> 00:06:24,490 number 2 is 7, and the inputs are 77 00:06:24,490 --> 00:06:30,699 they are the same number, here we have a problem 78 00:06:30,699 --> 00:06:34,699 because the inputs are 3 and 7 79 00:06:34,699 --> 00:06:43,720 no, this one 80 00:06:43,720 --> 00:06:47,279 comparing the same program and now the output 81 00:06:47,279 --> 00:06:51,040 and we say that the inputs are number 3 and 7 82 00:06:51,040 --> 00:06:54,699 so 3 is less than 7, do we have this? 83 00:06:54,899 --> 00:06:58,519 yes, 3 is less than 7, so this one 84 00:06:58,519 --> 00:07:08,129 loops, this is a loop, a repeated sequence 85 00:07:08,129 --> 00:07:13,050 ok, this program draws, ok, if we repeat 4 times 86 00:07:13,050 --> 00:07:16,790 move 150 and we turn 90 degrees 87 00:07:16,790 --> 00:07:33,290 four times what we draw is a square a square 150 step square 150 by 150 steps 88 00:07:33,290 --> 00:07:44,779 square the same loop select extraction would you would change to draw now not 89 00:07:44,779 --> 00:07:51,920 150 but 90 by 90 so there we need to repeat four times and we need to turn 90 00:07:51,920 --> 00:08:06,040 90 degrees the only instruction we need to change is move 150 and now we draw a 91 00:08:06,040 --> 00:08:12,399 rectangle sorry a triangle and we need to select two instructions so for a 92 00:08:12,399 --> 00:08:18,139 a triangle we need to repeat not four times but three so this is one of them 93 00:08:18,139 --> 00:08:26,899 and the triangle is 150 the same as this but instead of turning 90 degrees we 94 00:08:26,899 --> 00:08:40,830 need to turn 60 degrees but we need to change this this one odd numbers list a 95 00:08:40,830 --> 00:08:46,830 a list of odd numbers, so the variables n and odd are, let's see 96 00:08:46,830 --> 00:08:52,830 set n to 10 and odd to 1 is one 97 00:08:52,830 --> 00:08:56,830 action that the program internally 98 00:08:56,830 --> 00:09:00,830 does, so the user 99 00:09:00,830 --> 00:09:04,830 doesn't enter these numbers, so they are internal 100 00:09:04,830 --> 00:09:11,230 variables, not input, not output, internal 101 00:09:11,230 --> 00:09:27,820 Have a look, variable n is used to end, n initially is 10, and the loop is from repeat until n is 0 102 00:09:27,820 --> 00:09:34,820 and what we do is to create a list of 10 odd numbers, it says that 103 00:09:34,820 --> 00:09:58,919 So what is n? The number of the quantity of numbers the program shows, odd numbers, the quantity. They control the numbers of time, the process is repeated, good, store odd numbers, no, store even numbers, no, store the number the user enters. 104 00:09:58,919 --> 00:10:02,259 the user doesn't enter anything, so it has to be this 105 00:10:02,259 --> 00:10:06,679 and odd, as we said here 106 00:10:06,679 --> 00:10:10,860 the 10 odd numbers, the first value for 107 00:10:10,860 --> 00:10:14,559 odd is 1, and look 108 00:10:14,559 --> 00:10:18,659 odd here is 1 plus 2 109 00:10:18,659 --> 00:10:23,059 3, the second number, and later on, odd is 110 00:10:23,059 --> 00:10:26,960 3 plus 2, 5, 5 plus 111 00:10:26,960 --> 00:10:30,840 2, 7, 7 plus 2, 9, so 112 00:10:30,840 --> 00:10:35,240 odd is the variable that stores the odd numbers 113 00:10:35,240 --> 00:10:42,529 ok, when n is 8 114 00:10:42,529 --> 00:10:46,590 odd is, let's see, when n is 115 00:10:46,590 --> 00:10:49,669 10, odd, the first odd number 116 00:10:49,669 --> 00:10:53,990 is 1, so let's see how it works 117 00:10:53,990 --> 00:10:58,450 and the first time we go through these 118 00:10:58,450 --> 00:11:02,269 loop is n is 10 minus 1 is 9 119 00:11:02,269 --> 00:11:06,129 and odd is 1 plus 2 is 3, 9 120 00:11:06,129 --> 00:11:10,210 3, again repeat, now is 121 00:11:10,210 --> 00:11:14,230 9 minus 1 is 8 and odd is 122 00:11:14,230 --> 00:11:18,389 3 plus 2 is 5, when n is 8 123 00:11:18,389 --> 00:11:25,679 odd is 5, and we finish 124 00:11:25,679 --> 00:11:32,539 excellent, thank you