Teaching Beginners Python at CoderDojoGirls@DCU

👉 Related to event: Coding Grace at CoderDojoGirls@DCU

It was a wet, or so the Irish would say, a soft morning. Mick and I (Vicky) arrived at DCU and found the venue. Everyone was setting up. It might be 10AM but there's a buzz in the air.

Here are the two videos of Grace Hopper I mentioned during the introduction about Coding Grace:

Once we settled down, and was introduced by Niambh, we got started setting folks machines up, it was mostly Windows and we do have a few Macs.

One of the few things we had to do was make sure everyone had Python on their laptops, Sublime Text Editor installed and the workshop content copied over and unzipped.

See if Python works

Mac OSX and Linux

For Mac and Linux users, Python is on by default. To check if it works


For those on Windows, this is what we did to set the environment settings, this makes life a lot easier when we start using CMD:

To find out if it's set up properly, we need to open Command Prompt.

A couple of things to do after installing Sublime Text editor.

Sublime Text Editor settings for Python before using it

Before we start using Sublime Text Editor, make sure you have the following set so Python-related code gets highlighted (easy to look at at, and makes it nice to use), and that we have the indentation set properly. The latter is important as part of the best programming practices in Python (see PEP8).

On with the show...

There were 3 command line commands that was useful to know when navigating in the CMD (Windows)/Terminal (MacOSX/Linux).


If you want to learn more about CLI (Command Line Interface), see Coding Grace's CLI workshop slides

NOTE: One thing I didn't mention why command line is useful to learn, when you run a Python script, if there are any errors, you can see it right away in the CMD/Terminal. On Windows, if you run by double-clicking on the Python script, if there's an error, it will just close without a way for you to see what went wrong.


This shows where Python starts executing the code, in this case, on line 5 as if encounters if __name__ == '__main__'. Otherwise it will execute everything from line 1 onwards.

This script also contains a function, starts with def followed by the name of your function followed by :.

On the next line, it's 4 spaces (tab but make sure your editor has set "Indent to 4 spaces"), and your code.

To run this script via command line:


Here, I am introducing some interactiveness and the beginnings of a game. It will ask for your name and it will print it out.

Grand so far, now for some editing of game_02.py.


print(raw_input("What's your name? > "))


player_name = raw_input("What's your name? >")

Now we have a variable (a way for the computer to store information like strings and numbers).

player_name is a variable and when you type your name and hit ⏎, whatever you types will be stored in player_name.

If you run the game_02.py, it seems that nothing is happening, but it has stored your name after you entered it, but that's all it's doing. To see what player_name stored, we will print it out.

On the next line in game_02.py, type:

print("Your name is {}".format(player_name.upper()))

This looks funny, but what it is doing is telling Python that when it sees anything between and opening and closing ", it is a string.

And in that string, if it sees {}, then it is replaced with something such as a string from a variable called player_name in this case.

For those on Python 2.6.x, we encountered an error when running game_02.py.

ValueError: zero length field name in format.

If you come across errors:

Regarding the zero length field name error, we realised it was the version of Python encountering {} in string formatting. In 2.7 (onwards), using {} is fine. If using Python 2.6.x, substitute {} with {0} and it should work now.

But sadly time flew fast and the workshop has to come to an end. It was a wonderful morning, so much enthusiasm and fun.

Big thanks to Niambh and CoderDojoGirls@DCU for inviting Mick and myself as Coding Grace.


If you have any questions, you can email me at <a href"mailto:vicky@codinggrace.com">vicky@codinggrace.com. You can also leave a comment below. :-)

Our website for more information of upcoming events is codinggrace.com.

Other places to find us: Mailing list | @CodingGrace | FaceBook


About Author

Vicky Twomey-Lee

Pythonista, but normally found organising various tech events, and now heavily involved in diversity initiatives like Coding Grace, PyLadies Dublin, and Women in Technology and Science (WITS Ireland).
👉 http://about.me/whykay

💖 Our Sponsor/Partner(s)

A huge thanks to following sponsor(s). If you like to support us, get in touch with us.

Get involved

Interested? Talk to us.

Dublin City  Council PPN