How do I teach Python to kids?

How do I teach Python to kids?

My main work is related to data and programming on R, but in this article I want to talk about my hobby, which even brings some income. I have always been interested in telling and explaining something to friends, classmates and classmates. It was also always easy for me to find a common language with children, I don’t know why. In general, I believe that raising and educating children is one of the most important activities of all, and my wife is a teacher. So, about a year ago, I advertised in a local Facebook group, got a group, and started teaching scratch and python once a week. Now I have five groups, my own class in the house and individual lessons. How I came to such a life and exactly how I teach children, I will tell in this article.

I live in Canada, Calgary, Alberta, so some points will be related to local specifics.

The room

Having a place to practice was a major problem from the very beginning. I tried looking for offices and classes to rent by the hour, but not very successfully. Our university and SAIT - the local equivalent of MIT - take classes with and without computers. The prices there turned out to be not very humane, but in the end it turned out that the university does not let minors in, and SAIT generally rents only to its students. So that option was dropped. There are many office centers that rent meeting rooms and offices by the hour, there are entire companies that offer a bunch of options from a full-fledged class to a room for four people. I had hopes, since Alberta is an oil province, we have had a low-level crisis since 2014, and many business areas are empty. I hoped in vain, the prices turned out to be so high that I didn’t even believe it at first. It is easier for owners to sit in empty offices and pay expenses than to dump.

At that moment, I remembered that I regularly pay taxes, and whether our dear state, or rather, the city of Calgary, has anything there. It turned out that there really is. The city has arenas for playing hockey and other figure skating, and in these arenas there are rooms where tough ice warriors discuss strategies for future battles. In short, each arena has a couple of rooms with tables, chairs, a white board and even a sink with a kettle. The price is quite divine - 25 Canadian tugriks per hour. I initially decided to do classes for an hour and a half, so I set the price for a class of $ 35 per nose in a group of five people to compensate for the rent, well, to put something in my pocket. In general, I liked to train in arenas, it solved one of the problems - most Russian speakers live in the south, and I live in the north of the city, so I chose the arena approximately in the middle. But there were also inconveniences. The Canadian bureaucracy is good and friendly, but, to put it mildly, it can be a little slow. There are no problems when you get used to the rhythm and plan ahead, but sometimes there are unpleasant moments. For example, on the city’s website, you can conveniently choose the time and place, reserve a room, but you can’t pay, in any way. They make phone calls and accept card payments. You can go to the office and pay in cash. There was a funny but not very pleasant moment when I was waiting for their call to pay for the second lesson, I did not wait, and on the last day I was fifteen minutes late to the office. I had to approach the guards with an impudent muzzle and lie that the room was booked. We Canadians take our word for it, they calmly let me in and didn’t check anything, but I wouldn’t do that if people weren’t already on their way to class.

So I did winter and spring, and then there were changes that became the last straw. First, the office was closed to visitors and offered to accept payments by phone around the corner. I sat in the aisle for at least half an hour before I got through. Secondly, if before my dear aunt took payment from me for an hour and a half, now some girl picked up the phone and said that the payment was only for an hour. At that time, I had a group of three, then two people, and the extra $ 12.5 was not superfluous at all. Of course, I am ideological, but if my wife kicks me out into the street, then there will be no one to teach. I was still unemployed then.

And I decided to go to the library. Libraries rent out beautiful rooms for free, but there is one thing - you cannot conduct commercial activities. Even charitable organizations are not allowed to collect money there. I was told that this is not particularly controlled, the main thing is not to take money at the entrance right there, but I really don’t like to break the rules. Another problem is that the rooms are often busy and it is difficult to schedule classes at the same time in one place. I taught in libraries in the summer and early winter, I had to choose those where there was a place, as a result I changed five or six libraries. Then I began to book a place two months in advance, and then, it turned out to be done only in one small library, in the rest there were regularly no places at the right time. And then I decided to make a computer class at home. I hung up the board, bought a second table and a couple of old monitors on the ad. At work, the company bought me a new powerful laptop, because on my computer the analysis took almost 24 hours. In total, I had a new old computer, an old old computer, a laptop that had my small screen crushed and an ancient netbook on which I crushed the screen myself. I connected them all to monitors and installed Linux mint everywhere, except for the netbook, on which I installed a very light distribution, it seems pappy. I also have an old new laptop bought for $200, I connected it to the TV. More importantly, our host recently changed the windows for us, and the room now has new white frames instead of the terrible collapsed squalor. The wife keeps the living room, kitchen and second bedroom as a kindergarten, so the whole floor turned out to be purely pedagogical. So, now everything is fine with the room, let's go directly to teaching.

Scratch

I begin to give the basics of programming with the Scratch language. This is a language that uses ready-made blocks, invented at the time at MIT. Most kids have already seen scratch at school, so they quickly get used to it. There are ready-made programs and lesson plans, but I don’t like them at all. Some strange ones - create your own story, for example. The whole program consists of countless blocks say '<...>' for 2 seconds. It can be seen that very creative people came up with it, but with this approach, you can teach how to write a classic Indian spaghetti code. From the very beginning, I talk about principles like DRY. Other collections of tasks are quite good, but the kids quickly get to the point and start making them like a machine gun. As a result, in one lesson they do what they should have done in five. And it takes a lot of personal time to search and select tasks. In general, scratch is more like not a language, but an IDE, where you just need to remember where to click and where to look for something. As soon as the students are more or less mastered, I try to translate them into python. I even have a seven-year-old girl who writes simple programs in python. What I see as the benefit of scratch is that it has such basic concepts that are learned in a playful way. For some reason it is very difficult for everyone without exception to understand the idea of ​​a variable. At first, I quickly ran through this topic and moved on until I came across the fact that they did not know what to do with it at all. Now I devote a lot of time to variables and constantly return to them. You have to do stupid swotting. I change different variables on the screen and make them say their value. Scratch also has control structures and value checks, such as while, for or if in python. They are given quite easily, only there are problems with nested loops. I try to give several tasks with a nested loop, and so that its action is visual. After that, I move on to functions. Even for adults, the concept of function is not obvious, and even more so for children. For a long time I am crucifying what a function is in general, talking about a factory that receives objects as input, but gives out goods, about a cook who makes food from raw products. Then we make a program to “make a sandwich” with products, and then we make a function out of it, to which products are passed as parameters. On the study of functions, I finish with scratch.

Python

It's easier with python. There is a good book called Python for Kids, and I use it to teach. Everything is standard there - lines, order of operations, print(), input() etc. Written in easy language, with humor, children like it. It has a flaw common to many programming books. As in a well-known joke - how to draw an owl. Oval - circle - owl. From simple concepts too abrupt transition to rather complex concepts. It takes me several sessions to attach an object to the dot method. On the other hand, I'm not in a hurry, I repeat the same thing in different ways until at least some kind of picture emerges. I start with variables and hammer them again, this time in python. Variables are a curse.

A quick-witted student, who a couple of months ago deftly clicked the variables on the scratch, looks like a ram at a new gate and cannot add the X with the Y, which are clearly written on the board in the line above. We repeat! What does a variable have? Name and meaning! What does the equal sign mean? Assignment! How do we check equality? Double equal sign! And so we repeat again and again, until complete enlightenment. Then we move on to functions, where the explanation about arguments takes the longest. Named arguments, by position, by default, and so on. We haven't made it to class yet. In addition to python, we study popular algorithms from the book, more on that later.

Actually, training

My lesson is arranged like this - for half an hour I give a theory, check knowledge, consolidate what I have learned. Hour - labs. Often I get carried away and broadcast up to an hour, then half an hour remains for practice, respectively. When I was learning python, I reviewed the course Algorithms and Data Structures Khiryanova from MIPT. I really liked his presentation and the structure of the lectures. His idea is that frameworks, syntax, libraries become obsolete. Architecture, teamwork, version control systems - it's too early. As a result, there are algorithms and data structures that have long been known and will always be in a similar form. I myself remember only integers from the institute Pascal. Since my students are mostly young, from seven to fifteen years old, I believe that it is more important for their future to lay the foundations than to quickly write a platformer in python. Although, they want a platformer more, and I understand them. I give them simple algorithms - a bubble, a binary search in a sorted list, reverse Polish notation using a stack, but we analyze each one in great detail. It turned out that modern children do not know in principle how a computer works, I also tell you. I try to tie several concepts together in each lecture. For example, a computer - memory / processor - memory from cells (let me hold a memory plate, guess how many cells are here) - each cell is like a light bulb - there are two states - true / false - and / or - binary / decimal - 8bit = 1byte - byte = 256 options - Boolean data type per bit - Integers per byte - float on two bytes string on one byte - the largest number on 64 bits - a list and a tuple from the previous types. I make a reservation that in a real computer everything is somewhat different and a different amount of memory for these data types, but the main thing is that we ourselves create more complex data types from simpler ones in the process. Data types are perhaps the hardest thing to remember. Therefore, I start each lesson with a quick warm-up - one student names the data type, the next one gives two examples, and so on in a circle. As a result, I achieved that even the youngest kids cheerfully shout - float! boolean! seven, five! pizza, car! During the lecture, I constantly pull one or the other, otherwise they quickly begin to pick their noses and look at the ceiling. Yes, and the level of knowledge of each should be checked between times.

My students never cease to amaze me both with their stupidity and unexpected quick wits. Ingenuity, fortunately, more often.

I wanted to write more, but even so the sheet turned out. I will answer all questions with pleasure. I welcome any criticism in every possible way, only a request - to be more tolerant of each other in the comments. This is a good article.

Source: habr.com

Add a comment