Pushing ahead with Python

So this summer I’ve been coding in Python.

I’v decided to push this in my A Level classes more than learning VB.net, Javascript & PHP. Not because I don’t enjoy doing these languages, but that some students would struggle with switching between these. Perhaps code agnotism only comes with a maturity of having to learn different programming languages over the years?

The reasons I had traditionally taught the other languages was for the following reasons.

  1. Visual Basic.net has an easy to use drag n drop GUI interface builder in Visual Studio, plus it was more “formal” than Python, and the IDE was great for the intellisense predictions. However, running it our school was a pain as it could only be used on a development server so presented problems for students sharing their code with me
  2. Javascript – I love Javascript and it can be coded in a variety of online platforms (hello glitch.com) and can create engaging coloured interfaces. But students are often plagued with errors with semicolons and curly brackets. A steep learning curve then.
  3. PHP is a great way of coding server side languages (and one I used for many years) plus it dovetails nicely with teaching about databases and they can use phpmyadmin to investigate databases that they can integrate into their programs. However students who have used this for their projects again had a steep learning curve to get a decent working program.

So, I’ve decided to stick to Python for next year’s A Level students:

  1. For the GUI element I’m going to attempt to show them Tkinter. Yes I know there are other libraries out there that are simpler to use, but this one at least is baked into native Python. https://github.com/laura-james/TkinterExperiment

The program I’ve chosen to make not very complicated in what it does but it might give students a start into how to build a simple interface with styles. What I also want to show them is some of the basic programming features: functions, loops, global variables etc etc.

What I need to do next is to chop the frequently used parts into a Need to Know Powerpoint

(Useful link: https://tkdocs.com/tutorial/firstexample.html#walkthrough

Tkinter StringVar

2. For the Game element I’m going to show them PyGame. There is plenty of resources on the internet teaching you how to code in Pygame – almost too much – so it means a lot of investigating for me. I’ve enjoyed reading Al Sweigart’s books about Pygame (http://inventwithpython.com/inventwithpython_3rd.pdf and https://inventwithpython.com/pygame/chapter8.html) but he doesn’t seem to use Classes (unless I’ve missed that somewhere) and I’d like to use this to explain OOP (I would traditionally use VB.Net to build a space invaders game) So far I’ve built a simple tile based game – using a Tile class which could be extended to be more interesting – (my imagination ran out somewhat) I should get on with creating a Space Invaders Game perhaps


Screen shot of Tile game showing orange walls and coins

3. The first step this summer was to learn the Flask module in Python. This would be the way to get Python working in a browser. I had a go at using Replit.com for this as I thought this would be a good intro for the students as this is primarily what we use at GCSE. However, I soon found that Glitch.com supported Flask too and performed faster – and had perhaps a nicer interface and the fact that the url you were given was easiest to remember! I can now connect this to a sqlite3 database to make it a database driven web site which was ultimately my goal for the PHP Mysql apps I had suggested students create.

A few things I need to look at

a) how to create parameterised queries in sqlite?

b) Are there better ways of visulalising what is in the db file? That was a good thing about phpmyadmin. (UPDATE: This looks good https://sqlitebrowser.org/dl/)

Anyhoo – here are my two projects on replit.com and glitch.com: