Coding Grace at Women Tech Makers - Python Workshop

👉 Related to event: Learn Python by making a text-based adventure game @ GDG Dublin

This is a write-up for the Python workshop. :-)

Big thanks to the organisers of GDG Dublin and Women Tech Makers for inviting Coding Grace to run AngularJS (Serena) and Python (Vicky) workshops. A shout out and hugs to the mentors for helping out in both workshops and to everyone who came along and participated in the workshops. By the way, feel free to comment below with questions, feedback, anything I missed out in the post.

After a delayed start to the workshop and introduction...

We got stuck in making sure people's laptops are set up. For those using Windows, there's a small configuration needed to get python working via command line.

Details of this can be found in a previous blog post: http://www.codinggrace.com/news/teaching-beginners-python-coderdojogirlsdcu-2014-11-8/

By the time we had people set up, it was already break time at 19:30 for the scramble for food and some networking. We were back at 20:15(ish) and got right into the code.

You can find the source (without the special.py for the raffle) at our bitbucket repository, you can also download the zip from here.

Re-usable modules

Never made it to re-usable modules which was meant to cover before I ran the raffle for the fitbit.

Remember to check out the files ending with _comments.py, I've extra information and links to docs.

And while we are on the subject of documentation, check out Python's official docs at https://docs.python.org/2/.

During the workshop, we encountered if "__name__" == "__main__": very early on, this makes the Python script (or module) re-usable. This is pretty handy if you want to use the same function in multiple places in different files.

You can also do this via your terminal/cmd. So launch into your Python interpretor by typing python and you will see >>>. Now type the following:

>>> from game_01 import say_hello >>> say_hello()

You can do the same thing via the Python interpretor, which is pretty cool.

The special.py script

This is used to pick a random winner.

Here it is:

import csv import random

def main(): # Get list of attendees and create a list of names # with first name followed by surname with open("attendees.csv", "r") as f: reader = csv.reader(f)

# skip the first line in the csv file reader.next()

name_list = [] for row in reader: name_list.append("{} {}".format(row[0], row[1]))

# Pick someone at random from the list winner = name_list[random.randint(1, len(name_list))] print("\nThe winner of FitBit thanks to GDG Dublin is \n\n\t\t{}\n".format(winner.upper()))

if name == 'main': main()

You need another file called attendees.csv:

First Name,Last Name Naya,The First Heather,Meowsalot Jackie,Mewadith Bob,Mewsli

Make sure they are in the same directory, and in your terminal/cmd, type python special.py.

Here's what happens:

Congratulations to winner of fitbit

Congrats to Rachel for winning the fitbit from the random draw of registered workshop attendees, this was after a few goes. :-) Winner of fitbit thanks to GDG Dublin and Google Women Tech Maker

Best programming practices

We never got a chance to cover best programming practices, we did say one though:

More information on best programming practices for Python is called PEP-8. Do make sure your editors are set to this. Most programming editors support this.

Since it's easter... here's something to try...

This is what being Pythonic is all about. :-)

More info on Python.org.

Tweets from the evening

A couple of nice tweets from the evening in general for both workshops:

And it was super nice of them to put us up on the screens:

Newsletter out soon

I'll be sending out the monthly newsletter for April soon on what workshops are in the works, what's upcoming and also events of interest around Ireland. So subscribe via codinggrace.com. If you want me to include something, email me at vicky@codinggrace.com with its details.

Upcoming workshop

Dive into Javascipt @ Zendesk

Python-related events

Python Ireland April Meeting @ CHQ

PyLadies Dublin @ Wayra

PyCon Ireland 2015

Diversity-related Event

weAREhere unconferece @ Guinness Enterprise Centre

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.

fourTheorem
Get involved

Interested? Talk to us.

Dublin City  Council PPN

Partner