Archive for January, 2012

Simple Hangman Game


We aren’t having a meeting this week. We are going to move the sessions to Thursday afternoons so as not to clash with Science Club. But this Thursday is options afternoon.

I hope you’ve all managed to get Python installed on your machines at home. Please speak to me or email me if you have any problems.

I am planning to get on to some slightly more “attractive” programs very soon (ones which use a GUI or draw a picture!). But it is important to learn the basics and run some programs in the command shell.

This is a little program I wrote which plays a very simple version of hangman. Try entering it and running it. Can you improve on it? A visual output of the letters guessed and the “blanks” would be nice. And maybe a way to stop the user wasting their guesses by choosing the same letter twice.

The program makes use of some important programming features. Firstly, it creates a “tuple”, which is basically a kind of list. Then it checks for letters using the very simple “if … in” conditional. Have a look and see what you think.

Happy Coding!