Category: Python

Byte Insight


Python is a highly readable language that is easy to use and learn hence it is gaining popularity as an education language.  However, this should not lead anyone to consider it a child’s language for it is not.  It is very powerful, flexible and platform independent.  It supports many styles of programming from scripting and web design to  GUI/Game development.

Python – Strings

A string is a list of characters and, in Python, they are easy to declare using speech marks.

myquote = “Talk is cheap. Show me the code.”

RPi Twitter Led

This program follows on from the standard Python Twitter experiments.

The original inspiration for this whole experiment came from a @Rob Bishop (OCR) Raspberry Pi Recipe Card.  The objective of the program is to light an LED every time a tweet containing a particular word is sent to a certain person.


The original inspiration for this whole experiment came from a @Rob Bishop (OCR) Raspberry Pi Recipe Card  (ocr-recipe-card-twitter-led.pdf). The objective is to interact with Twitter using Python.

TKinter Drawing

TKinter is the easiest way to get drawing in Python.

Tkinter Events

Tkinter employs a type of programming called Event-Driven which means that the program runs in a endless loop waiting for things (events) to happen.  In order for the program to respond to these events it needs to know what to listen for.  


It is not uncommon to use time (or dates) or programs in some way or another.   If you are writing games you might want to record how long something takes or give the player a restricted amount of time.  Thankfully Python has some pretty good libraries (datetime, time) to help you.


Python Turtle is based on the Logo Programming Language that has been used as a popular way of teaching children programming for many years.  

Tkinter Buttons

You can create buttons such as a quit button

quit_button = Button(root, text = "Quit", command = root.quit, anchor = 'w', width = 10, activebackground = "#33B5E5")
quit_button_window = canvas.create_window(10, 10, anchor='nw', window=quit_button)

You can make images into buttons although this does not provide an entirely satisfactory solution so I would opt for images telling the player which button to press.

playImage = PhotoImage(file="./images/play.gif")
playButton = Button(root, command = startGame, width=108, height=35, image=playImage)
playButtonWindow = canvas.create_window(canvas_width/2,canvas_height/2, window=playButton)


In Python there are many ways to loop some code. Python is quite flexible in its ability to loop however it doesn’t always follow the normal rules.  All the following examples print out the numbers 0 to 9