 In the previous segment, we discussed the general form of a program, we discussed the notions of syntax and terms such as control flow, then we also observed that repeat statements can be nested inside other repeat statements. In this segment, we are going to take a review of what has happened and we will answer some questions that you might have in your minds. So for example, we have been doing picture drawing in this lecture sequence and let me now say why we are doing picture drawing. So let us ask what happens in general when you solve any problem. So when you solve any problem, you will need to do some calculations, you will need to take some actions. Now those actions will typically contain patterns and you will have to understand those patterns and a pattern might be something like a certain sequence of calculations is repeated. So what do you do in that case? In that case, you use a repeat statement. So this is a key programming activity. The pattern in the calculation must be mirrored by an appropriate statement in the program. So if it is a simple repetition, then you should have a repeat statement. If something is to be repeated 5 times, you should not write that 5 times. But you should write a repeat statement with count, repeat count 5 and put whatever is to be repeated inside the body. Now if you look at pictures, they also contain patterns. And to draw interesting pictures, you need to use repeat statements competently. So by drawing interesting pictures, you are really getting practice at representing patterns in your programs. And believe me, this is a really important activity, a really important skill while writing programs. There are some other reasons as well. So graphical input and output is actually very convenient and useful. This is because often our programs are about pictorial objects. And graphical output is very important because of the adage that a picture is worth a thousand words. Sometimes what you want to tell is much better expressed by a picture. And by a picture, I do not mean a drawing of a square or a rectangle or a line drawing of some figure or some of a tree or a human face or anything like that. I might mean drawing of a graph. So graphs are very common in science and technology. So what we are learning as we learn picture drawing is also how we are going to draw graphs which are common in science and technology. In fact, data visualization is an upcoming area of computer science precisely for this reason that it is very useful in science and engineering. So really you can think of this whole exercise as a very solid step towards understanding this whole issue of data visualization. And of course, drawing is a lot of fun. I hope you will agree with me and I certainly think you will agree with me when I show you some additional examples. So what is the spirit of the course? So first of all, you have to learn C++ statements and concepts. And I would like to tell you that today already we have covered a lot of ground even though it might have hopefully seemed like just some fun. But believe me, we have done a lot. We have understood patterns and we have understood that when you program, you need to understand patterns. So this is one important point of the entire course understanding patterns. We have taken a step towards it but this is a really important part. There can be other types of patterns which we will see a little bit later. And as I pointed out, this is really important in all of programming. So what is the goal of the course? Well if you can solve a problem by hand, possibly by taking an enormous amount of time and doing a lot of calculations patiently by the end of the book, by the end of the course or end of reading the book, you should be able to write a program for doing that. And typically you will see that what you take, what you need hours to calculate the computer will do in a few seconds. So that is really the goal of the course. Whatever you can do by hand, by laborious calculation, you should be able to do using a program. And of course there may be some things right now, some problems that you do not know how to solve. So for some of those problems, we will also learn some problem solving techniques. One more point about the course is that you have to understand that the computer is your friend. Do not be afraid of using the computer. If you are thinking to yourself, what if I write x, y, z in my program instead of p, q, r? Do not worry about it, do not fret over it. Just do so, just write a program, just change that p, q, r to x, y, z, compile it and run and see what happens. The computer is not going to explode. So there is no cost to being adventurous, there is only game you will learn. And very important thing you have to realize right now. Your knowledge is only good if you exercise it. And how do you exercise your knowledge? How do you say that I know C++ or how do you say that I know programming? Well you have to write programs, that is the real test. So that is definitely the spirit of the course, programming, practical, not theory, well theory and practice. So that really is the spirit of the course. So based on what you have learned so far, you can do these exercises. So for example, the first exercise asks you to draw a 5 pointed star. So let me tell you what I mean there. So this is the star that I am talking about. So it will be drawn using 5 lines and some turning. The question is how much turning do you have to do and the hint tells you how to do that. Now why stop at stars with 5 corners? Why not draw 7 pointed stars? And you could also ask is there only one kind of 7 pointed star or are there several kinds of 7 pointed stars? You should be able to figure this out and you should be also able to draw them. Now you can also draw circles because what is the circle after all? The circle is an n sided polygon in which n goes to infinity and the side length becomes really small. So that is how a circle is drawn on a computer. So go ahead and draw an n sided polygon where n is large and you will see that it looks like a circle. Then this problem asks you to draw 7 identical circles such that they touch each other. So the expected figure is something like this. My drawing is not great but I intended these circles to touch each other. So you can do this. And then the last one is about drawing an array of tiles which are slightly separated from each other. This is a slightly harder exercise. You can think of this design as the design that might appear on the border of a plate. So use your turtle to draw this. Actually you know enough to write a program to do this. So basically you are going to have to combine the ideas that you will have learned in the previous exercises. So one important hint do not give up and one more important hint try out whatever ideas come to your mind try out. You will see that some of them work. In fact you will see even if the ideas do not work they may produce an interesting drawing. They may produce a drawing which is even nicer than this. But anyway persist and get to this drawing. So I am going to conclude this lecture at this time but before that I am going to give you a demo which shows you what kinds of programs you can write at the end of the course. Some of these programs are slightly more advanced than that but only slightly more advanced. In any case they are discussed in the book. So here are some of the things. So we will show you a sequence of drawings interesting drawings that the turtle can draw and you will learn these in sort of a very in the very first few lectures. You will see an animation of cars moving on the screen. You will see animation of a bouncing ball. Then you will see a simulation of an airport. You will draw you will see some drawings of trees. So trees and some abstract diagrams and you will see the simulation of planetary movements planets moving around the stars. So this has been done by actually modeling Newton's laws of motion and Newton's law of gravitation. This is kind of the code that an astronomer would write. Well the astronomer would write a slightly more sophisticated code but this is actually somewhat sophisticated. But you will see that it is actually not that complicated. You know enough science and math to be able to understand these codes. And these codes most of these codes are really very small, 20-30 lines only a couple of them are slightly bigger than 100 lines. So we will stop over here but I will show you a demo and then the lecture will end. So hold on. So let us do this. So I am going to click this video. So the turtle has appeared and it is going to wait a little and then it is going to start and it will draw the square first. So you can treat this as an exercise. How will you draw such a pattern? These expanding circles by the way have also been drawn using simple CPP. So again that could be a good challenge for you to draw after a little bit of the course is over. So here is the turtle executing a program which will draw that plate design. Now I should tell you that in this plate design the pattern repeats 36 times. But when you write the program you should really write the program so that if I want the pattern to repeat 100 times you should be able to do that. So here is one use of computers. So a computer can generalize. So for a human being you may sort of take a lot of trouble and you may draw this single pattern but once you write a program you can generalize it and you can write the program so that it draws pattern with 100 such repeated figures. So this is a curve which is called the Hilbert space filling curve. You will see that the first pattern appears in the second, the second appears in the third, the third appears in the fourth and there is not going to be any fifth pattern because that fifth pattern will become really big but this is an interesting figure named after the German mathematician Hilbert. So here the turtle is actually making copies of itself and then each of those copies are doing a part of the drawing. So I like to call this a Gulmohar tree because the color is really like the Gulmohar flowers which appear in summer in India and I think this is a really pretty tree. So this is a stylized diagram also called a tree in computer science. So you can not only draw diagrams but you can also put numbers and that is what that example shows. Here is a little bit more complex drawing and in this we have these two cars. So they really are made up of several small elements. So they are made up of circles and they are made up of lines and they are made of polygons and it takes a little bit of coordination to make sure that all these elements are moving the way you want them to but that is what programs are for. You can actually write programs which do these things. Here is some kind of a physics experiment if you will. You have a ball which is bouncing inside a rectangular region and it is obeying the rule that it bounces, the angle of bounce back is equal to the angle at which it approaches the ball. And of course it has a pen so it is tracing a path, it is showing the path that it traces. The pen is at the center so the line is not going all the way till the end of the ball, all the way till the ball. Now you will see something interesting happen as it makes this drawing and that is because the velocities, the x and y coordinates of the velocities have small multiples with respect to the sides of the square. Anyway, so now what is going to happen is that it will retrace that same pattern. Here is probably the most complicated example in this and that is the simulation of an aircraft, an airport. So you will see that the aircraft actually keep some distance from them. Once at one point they seemed as if they were too close that is because I have made the picture of the aircraft larger than what it actually is. So you will see that on any line segment there is only one aircraft at a time. So this is the planetary simulation and this is what needs some sophisticated physics, actually not that sophisticated, nothing that you did not learn in standards 11 and 12. With that we conclude this first lecture of the first week of an introduction to programming through C++. Thank you.