Rob Cook

Home | Donate

Rock, paper, scissors, code! - part four



A retrospective is a term programmers use to mean looking back on the work they have just done. Typically a retrospective is held at the end of a piece of work. The aim is to see what went well, went went wrong, and what new things can be tried next time. We will use our retrospective to fill in a few blanks in our knowledge, and give some links to resources for further learning.

What exactly is Python?

Python is an interpreter that sits between us and the computer. The code we write is read one line at a time by Python and turned into instructions the computer can understand. Technically speaking then we do not program the computer, we program Python.

Because Python runs our code in this way, any errors will only be reported when Python tries to read a line it doesn't understand. The following program contains a bug that illustrates this behaviour.


secret_word = "cheeseburger"
guess = input("Guess >")
if guess == secret_word:

The first branch of the if statement contains a typo - prnt instead of print. So if we run this program Python will give us an error right? Maybe.

The line with the error will only run when the condition guess == secret_word is True. So if we run the program and type in something else for our guess, Python will never read the line with the error. It will look like our program is working correctly.

These kinds of bugs can be hard to find, especially when you have a lot of code. The best way to find them is to test each path of execution in your program. The program given above has two paths through it, one when the guess is cheeseburger and one when it is anything else. Running the program multiple times and giving input for both branches would uncover the error.

How much should I know?

The first function we saw was print() and we used it in multiple ways.

print("Hello world!")
print("Hello", name)
print("Rock vs", end=" ")

All of the above are valid ways of calling the print() function. Different functions expect different arguments. A significant part of learning a language is becoming familiar with its functions and how to call them with the correct arguments. (Reading the Python documentation can help with this.)

As we have seen already you can write complete programs knowing very few functions. Python's library is rather large, so don't get hung up trying to learn it all. Most professional programmers only know a small portion of it. It's about learning what you can do with the little you do know. Above all remember to have fun while learning!

Limitations of

The trinket website is a fantastic resource for learning Python. It requires no setup on your part and is free. The downside to that is it only has a small subset of the full Python library available. This is unlikely to cause you any issues when learning the basics. The people behind trinket have made the most useful modules of the library available. Just bear in mind that some more advanced Python programs may not work under trinket because of this limitation.

To see a list of the available modules, open up any trinket and click the hamburger menu (three stacked lines) on the left of the code pane. Click the Modules link to see the list.

At some point you will want to install Python on to your own machine (for free), and have the whole library available to use.

Further learning

If you want to take your understanding of Python further, now would be a good time to follow up with a more detailed tutorial.

If you prefer to work on specific project instead of following a tutorial, the Code Club website has several that are free to use.

Once you get a firm grasp of the basics, it helps to have some problems to try and solve. This is a list of some problem sets that can be fun to try and solve in Python:

Hopefully that will help you on your way to Python proficiency!