Last week, many of you wrote your first ever Python programs. I was impressed by how quickly most of you picked it up. I am going to try to make sure that there are plenty of ideas on here to keep you busy.
As you know, I made this blog especially for you and these lessons we have on a Monday. There is more stuff on Python, Linux and the Raspberry Pi over on Team Python.
Anyway … let’s start with something nice and simple.
I want you to get into good habits when you are writing programs. First, you should use comments. These make your code easier to understand and easier to fix, if something doesn’t work. You should also use some empty lines for the same reason. Another important thing is to use sensible variable names. For instance, I used “add”, “minus” etc for the results of those calculations – when you start writing longer programs you will save yourself a lot of hassle if you use variable names that mean something to you.
Snip: I’ve taken out the section on making a graphical game with pygame. I want to make some improvements, so I’ll repost it separately.
If you get that done, you might want to have a go at this. It’s quite simple, but fun. I won’t explain it much here – we’ll talk about it in class if you get this far.
Hopefully quite a lot of this is looking familiar. There are some new things in this, like random numbers and “sleep” which makes the game more fun!