Last week, I gave my girls an introductory lecture on how to code python and honestly, it was a really fascinating afternoon. I got to hear their first impressions of how and why we code, and I got to see a command line and a computer through fresh, young eyes. And, for a moment, time fell away and it felt like the world of computing was brand new and I experienced it again for the very first time. Amazing.
So! I got them to install Anaconda on their laptops (I looked at my last tutorial here) which only took a couple of minutes, and then we started at the very beginning using the command line, which we referred to as the baby console for clarity (I know!), as in Spyder, the command line console is on the bottom right hand corner and is approximately one quarter of the size of the whole screen.
I started simply by talking about numbers, known as literals in computer speak, and words, strings, and how we tell the computer to differentiate between literals and strings using quotation marks like this ‘quotation marks’.
If you type in 7, it is a number 7, if you type in 7 in quotation marks like this ‘7’, the computer treats it like a string, so we played with this idea in the baby console.
Next we played with the print command:
In : print (7+2) Out: 9
Which seems like a pointless exercise until you create variables like this:
In : x= 7+2 In : print(x) Out: 9
And then we did this:
In : print(y) Traceback (most recent call last): File "", line 1, in print(y) NameError: name 'y' is not defined
This demonstrates that because we hadn’t told the computer what ‘y’ was, the computer didn’t know what to do with it, which was interesting. We have to tell the computer everything otherwise it doesn’t know anything.
This made me laugh a little bit as the girls were totally shocked that you have to explain every last thing!
Then we went through operators: +, -,*, /, add, subtract, multiply and divide, respectively, so that we could use these operators on our literals.
After that, we played with ‘<‘, ‘>’, and, ‘==’, so we could see the computer return TRUE or FALSE. We did this by storing 3 as x just ‘cos we could:
In : x=3 In : 5==x Out: False In : 5>x Out: True In : 5<x Out: False
My eldest (12) understood ‘==’, but my youngest (10) hasn’t done this yet at school, so we didn’t go any further with Boolean logic or truth tables, but had a chat about the binary nature of reasoning in a computer.
I began by explaining that the way a computer is constructed means, that at it’s most basic level it can only reason with 1 and 0 which is known as binary code. I was expecting it to be long and complicated to explain all of this but the girls nodded wisely and said that they knew binary code because of Teen Titans Go, so we watched their catchy song here. Then, we found a website and translated our names into binary, here’s mine:
01110010 01110101 01110100 01101000
Honestly, Teen Titans Go, is very educational, my girls know about negative equity, and all manner of things which is so worth a blog in itself.
Then my eldest complained that the notes I was writing on the whiteboard were a bit faint and got me another pen. I thought I was being amazingly observant by noting that it wasn’t a sharpie whilst not asking at all and not doing that micro managing parent thing. Instead, I was super nice and cool and just thanked her for her input and jotted down more examples, and then we took turns to write on the whiteboard and recap what we had learnt so far.
The board got quite full quickly. However, when I went to wipe off my notes to write more things, it wouldn’t come off, and I had indeed been given me a permanent marker. After a brief interlude in which I chased my girls around, I’ll give you permanent marker, our lecture resumed and we moved onto storing strings in variables and using a flipchart. This is known as the Valentine’s flipchart because I bought my husband it for Valentines years ago, which apparently is not a romantic gift. Who knew? My husband quite liked it.
With strings on our minds, this is where coding got really interesting.
Up until this point it had been quite easy for the girls to construct a mental model of what the computer was doing as typing sums into the command line is rather like using a calculator. Added to that we had the simple, but easy to understand, storing literals as variables idea, and how the computer couldn’t tell you about a variable if you hadn’t defined it.
Next, we began by playing with print(), strings, and quotation marks like so:
In : print('Hello, Ruth') Hello, Ruth In : print(Ruth) Traceback (most recent call last): File "", line 1, in print(Ruth) NameError: name 'Ruth' is not defined In : name='Ruth' In : print(name) Ruth
In this way, we could see that if we are just printing something and not calculating, the output is put to the screen but not counted in the command line as a corresponding output [no] and we also understood that, rather like declaring our literals sometimes as numbers and sometimes as strings, and using variables to keep them in, we have to be quite precise on how we instruct the computer.
We recapped, AGAIN! And, then got ready to move onto BIG THINKING about strings, but first we had a tea/snack break. Coding at such a young age, after all, is not for the faint of heart nor is it for those without snacks.
Refreshed, we decided to declare the largest continent, like this:
In : largest_continent = 'Asia'
We used the print command and then some Boolean logic to see whether Asia was or was not the largest_continent in the same way that we had tested our variable x.
Even, so my girls were a bit surprised that the computer didn’t already know what the largest continent was, and then were really surprised that they were allowed to tell it anything e.g.,
In : largest_continent = 'England'
And, how wrong the above statement is on so many levels, i.e., England is not a continent, it is a country and so on. And, that there is no way of modelling THE TRUTH in a computer, even if it knows truth tables which are nothing to do with THE TRUTH. The computer doesn’t know THE TRUTH at all. You can tell it anything, and indeed you have to tell it everything before it can do anything when it comes to facts. And, indeed what is truth anyway? According to my girls, the truth won’t be found in that very long blog I’ve just linked to back there, but who’s in charge here?
Truth, and what is truth, and telling the truth, and defining truth was a super mind blowing concept so we talked about that, and the girls said that the computer wasn’t very helpful.
Then we typed this in:
In : print(largest_continant) Traceback (most recent call last): File "", line 1, in print(largest_continant) NameError: name 'largest_continant' is not defined
The computer had no idea what we were talking about because we had spelt continent with an ‘a’, so it was like declaring a new variable, or in this case, not declaring it and the computer not knowing what we were talking about.
We saw that yet again the computer doesn’t know a spelling mistake, or any facts about the world. This computer was getting less useful by the minute.
However, we pressed on and practised some more with this:
In : print('largest_continant') largest_continant
To see that the computer won’t correct our typos or tidy up our strings, that is all up to us.
At this point, my eldest said 50,000 hours had gone by and so it was time to stop.
I wanted to press on to cover the big baby console (left hand side of Spyder) where we can write our instructions and save them and run them. And, then I wanted to use the input command so we could create some interaction with our user, and talk about dialogue, but apparently that was a step too far, as my youngest reminded me that she is just a child.
But I am just getting warmed up, I said. So she proceeded to give me some useful feedback as it was my first time lecturing kids. The take home points were: don’t go on, forever, just introduce one thing, don’t gabble everything you know at the end, and don’t shout: Oh God, when the kids want to do another recap. Good feedback, which I will definitely try to take on board for our next lecture, but I can’t promise anything.
After that, I think perhaps we did have another recap, whilst I refrained from shouting: Oh God, or I may have just passed out, it’s all a bit of a blur, now. Or, perhaps we went off to play Sims 4, either way I got this great certificate from the feedback sheets, along with suggestions for further courses: web design, touch typing, and ways to get better at maths sweet, sweet skills using python. I guess this is in part because one of the Sims – Simetta – has gone to university to learn robotics – life imitating art:
All in all, it was a great afternoon, and now I can ask the girls to read this for revision purposes before the next lecture, which is a great idea because, as I said to them, if you don’t reread something that you have learnt within 24 hours you lose 50% of it and so on each day. I don’t think they were listening at that point, but typing this up I got to relive the lecture all over again and remember the way they viewed the computer, through fresh eyes, which was so lovely. Although, my eldest came over when I was typing this up and asked me to tag it with mykidsarethebest and since it’s a blog about her, I couldn’t say no, and she is quite a tenacious student (look at that ambitious vocabulary going on here) so she will check up on me.
So, since I can’t wait to do it all again, the next lecture is coming soon, tentatively named: Python, the sequel, best said in a dramatic voice, of course, everything is better in a dramatic voice, or a robot one.
Stayed tuned. Python, the sequel, here we come!