More on BBC Basic

Since my previous post about BBC Basic I’ve been prompted into looking into the topic further, and it appears the language might have something going for it after all – it’s very similar to the pseudocode used by OCR, and OCR seems to be supporting it, as they have provided training materials using BBC Basic to illustrate solutions.

One problem the language does seem to have is a lack of materials available, so I decided to have a go at remedying that, and have produced a KS3 workbook, similar to my Python workbook, which provides guidance into the first few steps of programming – input, output, variables, IF statements and loops – using BBC Basic, including simple exercises. My intention is that the booklet provides enough information for the more able students to progress by themselves, while others will benefit from extra guidance from their teacher.

I myself missed out on BBC Basic, as by the time it was introduced in schools I was at the top end and about to leave, but I did start off with Sinclair Basic, which was very similar. I do miss the old days of line numbering, but I have to admit that these days it’s far easier! If there is a generation of teachers out there who need to learn how to teach computing in a hurry and they’re already familiar with – or even just have a passing acquaintance with – BBC Basic, then capitalising on that would seem to be a viable way forward.

I intend to look further still into BBC Basic and pseudocode, as students are expected to understand pseudocode anyway for OCR GCSE Computing, and being able to write programs in pseudocode that translate directly into executable code would be useful, but I do feel that there needs to be some sort of introduction to another language as well. Watch this space for more news on training materials.

I remember reading once (a long time ago, admittedly!) that universities don’t want students who have already learned a programming language because they get confused when learning a second, but on the other hand those who already have experience in two find it far easier to learn a third. I myself have found that it’s the thinking and planning skills that are vital – once you understand exactly what you are trying to do, finding the exact syntax in the language of your choice becomes the easy bit. It’s like learning to drive a car: when you first learn, you’re bothered by every small difference in another car – the side the indicator is on, the biting point of the clutch – but once you gain more experience you’re aware of the differences and can work better with the similarities. In the end it doesn’t matter what sort of car you learn to drive in, as long as your skills and knowledge can be easily transferred to any car.

Advertisements

Hopscotch – programming on iPad

Hopscotch's interface with code blocks on the left and coding area on the right

Hopscotch looks similar to Scratch in many ways

I’m always on the look-out for interesting ways to introduce children to programming, and recently I came across Hopscotch, a free iPad app.

At first glance, Hopscotch looks very much like Scratch, but it is much simpler, while making full use of the interface possibilities of an iPad.

Blocks available to use are limited to

  • motion: move, rotate, set heading, change x by, change y by, set speed
  • lines: leave a trail… end, set line color, set line width, clear
  • controls: repeat… end, wait
  • looks: scale by, set opacity, change costume
  • operators: random

Each script starts with an event trigger:

  • When play button pressed
  • when I shake the iPad
  • When I tap the stage
  • when I tilt the ipad down/left/right/up
  • when I tap the object
  • when I hear a loud noise
  • when [this object] collides with……
The program can produce simple graphics

The program can produce simple graphics

One sample program that came with the app produces this output, by using several sprites to each draw a section of the image:

Part of the code for the Sydney Opera House program

Part of the code for the Sydney Opera House program

My first reaction was that not having the full functionality of Scratch is a real disadvantage – there is no possibility of embedded maths, for example, because the only operator offered is one that generates a random number.

However, on reflection, this could also be a strength, as limiting the code that can be used forces attention on those that can be used, so the coder can really explore the possibilities without getting too bogged down in complicated code blocks.

It’s my impression that the app is constantly under review and development, as since I first investigated it the collision function was added, so it’s very possible that within a few months Hopscotch turns out to be a fully developed, child-friendly graphical app design tool.

top of the code area showing sprites on different tabs and a graph showing the x and y position of the sprite

Tabs show different sprites in the program, while a simple diagram helps with placement on screen

In the meantime, it does offer basic functionality that enables creators to create interactive animations and activities involving basic logic. Its Event -> Action format would also serve as a good introduction to Gamemaker or other similar products, and of course the drag and drop graphics make it very easy for even young children.

I suspect that older children would find this rather limiting after a while, but I would certainly recommend it at key stage 2 for exploring possibilities in programming, and even as a cross-curricular maths tool, exploring distances and angles, for example giving a drawing to copy and seeing if children can describe the sequence needed to draw it.  Results could of course be recorded by screenshot and drawings to copy can be as simple or complex as needed, leading to natural differentiation by task.

There is a limited selection of cartoon-like graphics that can be added to projects, plus a text object. This limits what can be done rather, but again I suspect that this could well be developed in the near future, including hopefully the ability to import your own graphics.

There is a limited selection of objects available, plus a text object

There is a limited selection of objects available, plus a text object

In summary, a basic tool that provides a good introduction to programming for younger children and has strong possibilities, but which at the moment is likely to be rapidly outgrown by anyone who has already experienced Scratch, as the interactivity offered by the iPad is negated by the limited instruction set.

If you have a class set of iPads, then this is would be useful. If you haven’t, then you’re not missing very much.

 

Python at key stage 3

a simple programI recently had the pleasure of introducing some year 8 and year 9 pupils to Python. They had previously dabbled in Scratch, but the idea of writing formal text-based programs was new to them, so we took it slow and steady.

The first lesson was mostly taken up with getting to know Python – we started by typing commands directly into the shell, and then they learned how to open up a new window, type a simple program into it and run the program. By the end of the first lesson they could type up print statements and simple maths statements into a program listing, save it correctly and run it.

Lesson 2 introduced the idea of variables and input. I reminded students at the beginning of the session how to start up a new window and create a program rather than type into the shell, and how to save their program with .py on the end to conserve the colour coding. They were also starting to discover the pleasures of debugging, and learning to look carefully at their code to spot errors. They helped each other out with this, and I showed them how to check not only the area of code that Python highlighted as a concern, but to check just before it as well, as often the error was missing speech marks or closing brackets.

Lesson 3 was where the real fun began, as we looked at if statements. Combining these with input meant that we could create a question and answer program, and combining that with a variable called score gave them the option of creating their very own quiz. Reactions varied, as some struggled to get their program running and grew frustrated while others started to really fly, creating inventive listings that checked for a user name and password before allowing access to the quiz. Generally, they seemed to enjoy the sessions, and my favourite reaction was that of frustration expressed as the code refused to work, followed by that surge of satisfaction and achievement as the error was spotted and fixed.

Our work developed by way of writing programs to solve problems, and for this I used my flash resources. This had the advantage of offering different levels of challenge and support, so that those who were able could work at a higher level while I could help those who were really struggling. By the end of the sessions all students understood a little more about how programs are made and they had learned that little details like capitals and spelling really matter. Most were starting to see how their program worked and how to fix errors and develop the functionality, while a small number really enjoyed the unit and were starting to come up with their own ideas and solutions.

This was only a very brief introductory look at programming, but it was enjoyable and worthwhile as a taster of computing rather than ICT, especially for those going into options, and encouraged students to think carefully and increase the accuracy of their written work. I saw expressions of satisfaction from both ends of the ability level, as those who struggled finally got something working while those who experimented showed off what they had managed to work out for themselves. Students whose first reaction as “This is stupid” moved over to “Oh, I see what the problem is”, as they learnt that the computer would do exactly what was it was told to do, and discovered for themselves the harsh realities of Garbage In Garbage Out. Even if they never see another Python statement, I believe they’ve taken away the understanding of how carefully you need to express yourself in order to be properly understood and how accuracy leads to better results.

As a result of my experiences I’ve developed a workbook and some flash resources, which you can find on my website here.

 

A Flash resource for Python

As I introduce Key Stage 3 groups to Python, I’m finding that some of them really “get it” and have started trying to develop and experiment with code, while others really struggle to make any sense of it at all.

In order to help them work more independently at all levels, to free me up to give more targeted help where needed, I wanted a resource I could use that would offer support at all levels.

I had an idea for an interactive Flash resource, to offer different levels of challenge, with support available if needed. I keep looking at Flash, telling myself that it’s not worth going into, and then reconsidering, so it was an ideal opportunity to see if I could make good use of it after all.

developing a resource in flash

Developing a resource in Flash

I came up with a simple idea for a coding project – working out the costs of something with a fixed element and a sliding element – that was within their mathematical understanding as well as programming experience but complex enough to require some thinking. Once the basic idea was there, I found ways to develop it, from a simple changing of the fixed and sliding costs to adding a discount which would require an if statement, and started to build my resource.

This was my first time creating an interactive flash resource for a specific purpose, but having tried out various tutorials I had at least a vague idea of how it worked, and as I progressed I found that all that theory started to make sense and I got a much clearer idea of how to proceed.

The end result was a resource that posed a problem, provided listings for students to copy if they needed, and then provided three levels of challenge, each of which could be tackled independently, again with code to copy if needed.

I tried it out with students of various abilities, all of whom are very new to Python, and all completed the basic program, the majority tried at least one challenge and the bravest went straight to the highest level of challenge.

Easy challenge

Easy challenge

While I wouldn’t recommend copying code indefinitely, students at the early end of learning to program definitely benefit from having something to work from, as checking capitals and spelling can be enough of a challenge to start with! They are starting to look more carefully at what they do, and to see how to adapt their code, and some are starting to show the buzz of excitement at getting a program running that shows they are getting a real sense of achievement at coding rather than just being an end user of software.

I’ve since adapted my resource to a second project, and while the first took a couple of evenings to complete the second one took only a couple of hours, and felt much easier to do, proving that Flash is a viable tool for creating interactive resources.

Both resources are available on my website.

 

codea – coding on ipad for ipad

While browsing code.org last night I came across a link to an ipad game that promised to help teach sequencing and control – a game called cargo-bot. There was mention of the app that was used to create it as well, so I went off to investigate.

a screen of cargo bot, showing a puzzle

cargo-bot, showing all tools available. Match the pattern at the top to complete.

Cargo-bot itself is free, and provides exactly what was promised – a way to practise sequencing instructions. If you’ve ever played with light-bot, it’s very similar, but also offers conditional instructions. The aim is to move the coloured crates and stack them in the right place in the right order, using only commands like left, right and down, plus the facility to create subroutines and loops.

The really interesting part comes when you start looking into how Cargo-Bot was created. An app called Codea, which costs £6.99 ($9.99 in the US, I believe), provides a way to code directly onto the ipad using Lua. The coding for several examples is included, and this includes the complete listing and graphics bundle for cargo-bot.

codea's front page

codea’s front page, showing example projects and link to wiki and tutorials

While learning yet another language isn’t necessarily the best idea, I couldn’t resist, and so bought and installed the app and started playing.

my game in action

my game in action

Within about an hour I’d produced my own program that drew a character on screen who responded both to gravity (tipping the pad) and touch.

The longest aspect of this coding was having to switch constantly from the app itself to the wiki with its tutorials, find the right place in the tutorial and then swap back again and try to remember. I did try to borrow another ipad so I could use both at once, but ended up reverting to the tried and tested method of paper and pen!

codea's editor adds extra buttons to help type in code

editor, showing the quick buttons on the top row

The editor seems to provide a lot of help, for example a button to provide brackets, another to provide speech marks, both leaving the cursor in the middle for typing, and a quick += button. Pop-ups provide help with coding, and I did eventually find a comprehensive in-app help system.

built in reference guide

built in reference guide

There are a couple of graphics bundles provided, plus a program that lets you design your own sprites pixel by pixel. You can also link it to your dropbox account and use graphics you’ve placed in there.

I haven’t looked into how you export the game from codea to become a stand-alone app, but cargo-bot is living proof that it can be done and the game can then become part of the app store.

Even without this, the app provides a fascinating way to write your own code not only for ipad but on the ipad itself.  While I wouldn’t rush out and buy a class set of ipads just for this, given the opportunity to try it out I think it would be an excellent way to encourage interest in those who want to try coding. There’s a wiki that’s easily available from within the app, which includes tutorials, and while typing on an ipad can be fiddly, the editor provides enough help to take away a lot of the pain.

code listing

my complete code listing

My program has the sprite moving across the screen to respond to gravity (tilt the pad and it moves) and to touch (it jumps to the touch point).

Code is colour coded and clear to read, with parameter help and code hints. Auto completion options help to make ipad coding a straightforward affair.

One thing that I’m reminded of when looking at this is that while once upon a time it just felt like there was hardware and there was software, nowadays there are the hardware providers, the end product coders and a whole variety of people in the middle, who are providing things like game engines, physics engines and so on – the steps in the middle seem to be growing fast, each level building on the last to produce an end product that is the result of many hours of work by many people.

Teaching game

teach logo

working title for game

I have an irrepressible habit of turning everything I can into a game, so when searching round for a game idea I could create for myself, my job seemed an obvious inspiration. One game I’ve enjoyed playing is Diner Dash, and I fancied the idea of creating a similar sort of game about balancing the needs of a class of students and reaching the goal of good exam marks.

It also seems to be the ideal type of game for object oriented programming, with classes of students extended into sub-classes of different types of student, all of whom have slightly different needs. One-to-one teaching is straightforward, but the wider the variety of students in the class the tougher it will be to achieve success. The possibilities are endless!

Having mapped out the original idea, I need to start with a single student and work out the balances between the different variables to achieve reasonable gameplay.

I decided to stick to Python for now, although other options are Flash, Greenfoot or Scratch. Each of these offer easier access to graphics, but if we are to be using Python in school I need to have as much experience in it as possible. Flash also has the drawback of not being available on devices using iOS, which suggests to me that its days are limited, and Scratch, while great for first experiments, feels too self-contained to have wider use, while Python and Java/Greenfoot are more widespread and will run on a wider variety of machines and situations.

Next issue was the choice of editor. I started writing my code in Geany, as this is more compatible with pygame and other GUI modules, but then remembered that for the earliest versions it’s easier to test as I go along and for that I need IDLE, which allows me to type in commands directly. Having written out a first example of my code in Geany, I ran it in IDLE, tested some of it, and then amended the code and tried it again. Here I hit the first problem: I suspect that IDLE and Geany handle the indenting slightly differently, and so the code written in the two different editors threw spacing/tabbing errors. Having forgotten my earlier learning and not kept a log or changed file version, it took a bit of fiddling before I was off again, but this time I kept a log open to keep track of progress.

Adding in complexity to make the variables more interdependent proved successful on one level, but I need to know exactly what effect each variable is having, so at this point I’m moving to a spreadsheet so that I can explore the impact of different variables and weightings on the overall game more easily. I also need to draw up a proper flowchart so I can see what is happening.

I’m beginning to realise that this game will take lots of skill in lots of different areas: a spreadsheet model to explore the effects of the variables, maths skills to play around with the weightings, an understanding of game mechanics to achieve a playable game, graphics design to create the graphics needed, writing skills to write game instructions and even music skills to create music for it. And that’s before I even get to the coding skills!

At this point also I’m beginning to understand more of what my students will need to do when writing up their coursework, and appreciating the need to keep careful records of design ideas and progress. And thinking of the fun I’ll have playing with the settings to make sure that I don’t hit problems with transferring back to Geany as my editor!

 

codeword success

codeword gui version 1

first idea for a GUI

It only took a screenshot of my project in action to put myself back on the right path, and a very pleasant afternoon was spent adding the last piece of functionality to it – as a reminder, it’s a program that allows me to enter the settings for a codeword grid, which is a puzzle that looks like a crossword but with number standing for letters. The user tries out a letter in place of a number and eventually solves the whole puzzle, with each number representing a different letter. My program does not create or provide puzzles, but instead you can use it as a tool to help solve commercially available puzzles, to save scrubbing out incorrect guesses.

I had got it to the point where it would display the grid in the console and accept changes via direct entry in the console, so what was left to do was to provide a list of what letters had been used already and to not allow the same letter to be used for two different numbers.

Writing code for the list proved to be straightforward – rather than delving into different data types and debating which was best, I opted for a simple list, with the first entry at index 0 set to “*” and the rest of the entries set to ” ” (space). Adding a letter for a specific number then involved setting the list at that index to the letter, and resetting involved setting the entry back to a space.

I could then call these list functions as part of the setting and resetting a letter, and check whether a letter had been used already before allowing it to be entered into the grid.

My code at the moment has very little help for the user (hence part of my problems yesterday!) and it has very little error checking for input, but neither of these is a real issue as the intention is to put a GUI on the front of the code, to handle display and entries.

And here I hit the next issues: issue one is how to create a GUI in python and issue two is which editor to use to create it.

The book I’ve been working from suggests pythoncard, but I have not been able to install this successfully. I’ve managed to establish that Tkinter is already available as part of the python standard library, but it carries a warning that it will not run with the basic python IDLE, as that does not handle events properly, so that then leaves me looking around for an editor that will do the job.

I enjoy working with the IDLE, as it’s incredibly straightforward, and I object to using more time figuring out how to use an editor than I spend actually coding. I’ve got Eclipse that I’ve used for Java, and I’m currently looking into using that with a pydev plugin, but I’m starting to get frustrated by all these different options, which all seem designed to provide high levels of support with very complex projects and make life very complicated for the casual user who just wants to create a simple project.

The other IDE that I’m trying out is Geany, which I recognise as the software that originally came on my raspberry pi, and so I have used already for python. I’ve got it running with my codeword software, but when it gets to the end of the program, which goes as far as creating the grid, the program then seems to terminate without allowing me to enter further commands via the console. If I can put a GUI onto the program, then the console won’t be needed anyway, but it’s just another frustrating step.

I think with fondness of the days when I learnt programming, when we used C++ with an IDE that allowed us to design a GUI and attach code to it really easily. Even the Java editor we used back in those days seemed far more straightforward, even though I never did really get the hang of the different containers that you could use for java layouts.

Surely these things should be getting easier, not more complex?

Incidentally I’m now running a log of my project, with notes for each version change on what I’m attempting to do. Each feature is being developed piece by piece, with constant resaves as different versions – all versions ending in 4X are the basic version, while 5X added in the list and 6X used the list to check whether the letter was available before using it. I’ve also included screenshots of the project in action and a first sketch of what the interface might look like.

Hopefully if I end up leaving the project again for an extended period (for example while I build up my GUI skills) this log will make it much easier next time to pick it up and catch up with progress. I can’t say I understand every line of the code I’ve written or could duplicate it easily, but at least I know enough to know what it does and how to use it, and which functions are available.