Welcome to GPN!
Perth Term 1 2026
Connect to UWA WiFI
1. Select UnifiGuest wireless network�2. Enter the username and password
Username: perthgpn
Password: Gt88.mk?
3. Accept the Terms of Use.�4. Click the "Log in" button.
Connect to UWA WiFi
Welcome to GPN
Thank you to our Sponsors!
Platinum Sponsor:
Gold Sponsor:
Who are the tutors?
Log on
Log on and jump on the GPN website
girlsprogramming.network/workshop
Click on your node location
Click on your room.
From this page you can see:
Tell us you’re here!
Click on the
Start of Day Survey
and fill it in now!
Today’s project!
Markov Chains!
What is a Markov Chain?
A Markov chain is a simple Artificial Intelligence!
Let’s play a game with some cups to help explain it
Let’s play the cups game!
Let’s generate some text in the style of
Green Eggs & Ham by Dr Seuss
Do you like green eggs and ham?
I do not like them, Sam-I-am.
I do not like green eggs and ham.
Would you like them here or there?
I would not like them here or there.
I would not like them anywhere.
Let’s play the cups game!
We’re going to write some text by randomly choosing a next word based on the word before it
Let’s play the cups game!
Read the outside of your cup!
If someone shouts the word on the outside of your cup:
A tutor will write the words called out on the board
Today we’ll be making Markov Chains!
Markov chains are exactly what we just did with the cups!
Today we’ll make the computer do it to make some crazy stories!! �
Here’s one we made from some Shakespeare!�
Imagine if you used one of these to do your homework!!
doth stay! All days when I compare thee to unseeing eyes be blessed made By chance, or eyes can see, For all the top of happy show thee in dark directed. Then thou, whose shadow shadows doth stay! All days when I compare thee in your self in inward worth nor outward fair, Can make bright, How would thy shade Through heavy sleep on the eye of life repair, Which this, Time's pencil, or my pupil pen, Neither in the living day, When in eternal lines of that fair from fair thou grow'st, So should the lines to a summer's day?
Introduction to Edstem
Log on
Click on your Workbook link to take you into EdStem
Signing up to Edstem
Log in if you already have a an “Edstem” account from a past GPN
If you haven’t got an account, let’s make one:
Click Join Course
The name of your course will be at the top :
If you don’t have access to your email account, ask a tutor for a GPN Edstem login
Getting to the lessons
Inside a Chapter
Inside a Chapter there are two main types of pages:
Each chapter has a checkpoint to complete to move to the next chapter. Make sure you scroll down to see all the questions in a checkpoint.
There may also be Bonus Lessons to try if you want to or if you are waiting for the next lecture
How to do the work
In each Lesson there is:
You will need to copy your code from the last lesson, then follow the instructions to change your code
There are also Hints and Code Blocks to help you
Hints
Sometimes in a lesson, there’s some code we want you to do that might be a bit tricky, to help you out we’ve added some hints. They look like this:
If you press the blue run button it will show you what that code does, you can even change the code to see if/how it changes.
These are just hints make sure you’re not copying the hint into your code as it will likely end up breaking. They are just to show you the kinds of things you can do.
Running your code…
Click in the bottom right hand corner
Your code will run and any output will display in the Console
Don’t worry if you forget. Tutors
will help!
Some shortcuts…
There are a couple things you can do to make copying your code from one page to another easier.
Pressing these keys together will select all the text on a page
Pressing these keys together will copy anything that’s selected
Pressing these keys together will paste anything you’ve copied
On Macs use Command (⌘) instead of Ctrl
Project time!
You now know all about the EdStem!
You should now sign up and join our EdStem class.
Remember the tutors will be around to help!
Intro to Programming
What is programming?
It’s giving computers a set of instructions!
Programming is not a bunch of crazy numbers!
A Special Language
A language to talk to dogs!
Programming is a language to talk to computers
People are smart! Computers are dumb!
Programming is like a recipe!
Computers do EXACTLY what you say, every time.�
Which is great if you give them a good recipe!
People are smart! Computers are dumb!
But if you get it out of order….��A computer wouldn’t know this recipe was wrong!��
People are smart! Computers are dumb!
Computers are bad at filling in the gaps!��A computer wouldn’t know something was missing, it would just freak out!
Everyone/thing has strengths!
Intro to Python
Let’s get coding!
Let’s make a mistake!
Click on Chapter 1 ‘Welcome message’
The first lesson ‘1.1 Print a message’ will open. It looks like this
Let’s make a mistake!
Type by button mashing the keyboard here - type anything you want
Click Run here to run your code!
Did you get a big ugly error message?
Mistakes are great!
Good work you made an error!
AttributeError: 'NoneType' object has no attribute 'foo'
TypeError: Can't convert 'int' object to str implicitly
ImportError: No module named humour
KeyError: ‘Hairy Potter’
SyntaxError: Invalid Syntax
We can learn from our mistakes!
Error messages help us fix our mistakes!
We read error messages from bottom to top
Traceback (most recent call last):
File "C:/Users/Madeleine/Desktop/tmp.py", line 9, in <module>
print("I have " + 5 + " apples")
TypeError: can only concatenate str (not "int") to str
We can learn from our mistakes!
Error messages help us fix our mistakes!
We read error messages from bottom to top
Traceback (most recent call last):
File "C:/Users/Madeleine/Desktop/tmp.py", line 9, in <module>
print("I have " + 5 + " apples")
TypeError: can only concatenate str (not "int") to str
1. What went wrong
We can learn from our mistakes!
Error messages help us fix our mistakes!
We read error messages from bottom to top
Traceback (most recent call last):
File "C:/Users/Madeleine/Desktop/tmp.py", line 9, in <module>
print("I have " + 5 + " apples")
TypeError: can only concatenate str (not "int") to str
1. What went wrong
2. What code didn’t work
We can learn from our mistakes!
Error messages help us fix our mistakes!
We read error messages from bottom to top
Traceback (most recent call last):
File "C:/Users/Madeleine/Desktop/tmp.py", line 9, in <module>
print("I have " + 5 + " apples")
TypeError: can only concatenate str (not "int") to str
1. What went wrong
3. Where that code is
2. What code didn’t work
Write some code!!
This is the first bit of code we will do. What do you think it does?��print('hello world')
�
Write some code!!
This is the first bit of code we will do. What do you think it does?��print('hello world')
�
It prints the words “hello world” onto the screen!
�
Write some code!!
print(“hello world”)
�Did it print the text:
hello world
???
Tell me more!
We can print things in lots of different ways in python!
>>> print("Hello world!")
Hello world!
>>> print("Hello", "world!")
Hello world!
>>> print("Hello", "world", end="!")
Hello world!
Note that this last one will not have a new line after it!
Tell me more!
We can print things in lots of different ways in python!
>>> print("Hello world!")
Hello world!
>>> print("Hello", "world!")
Hello world!
>>> print("Hello", "world", end="!")
Hello world!
Note that this last one will not have a new line after it!
Tell me more!
We can print things in lots of different ways in python!
>>> print("Hello world!")
Hello world!
>>> print("Hello", "world!")
Hello world!
>>> print("Hello", "world", end="!")
Hello world!
Using a comma (,) puts a space between the words
Tell me more!
We can print things in lots of different ways in python!
>>> print("Hello world!")
Hello world!
>>> print("Hello", "world!")
Hello world!
>>> print("Hello", "world", end="!")
Hello world!
Note that this last one will not have a new line after it!
Variables
Variables are useful for storing things that change
(i.e. things that "vary" - hence the word "variable")
You can think of it like putting information in a box and giving it a label
friend
Variables
When coding, we can make a variable called friend and set it to a value like this
friend = “Alex”
friend
Alex
Variables
Instead of writing the word “Alex”, we can write friend (the variable’s name).
The computer will substitute the current value of friend.
It’s like we’re getting the value out of the box!
print(friend)
friend
Alex
Variables
Instead of writing the word “Alex”, we can write friend (the variable’s name).
The computer will substitute the current value of friend.
It’s like we’re getting the value out of the box!
print(friend)
friend
Alex
Alex
Reusing variables
We can replace values in variables:
animal = "dog"
print("My favourite animal is a " + animal)
animal = "cat"
print("My favourite animal is a " + animal)
animal = animal + "dog"
print("My favourite animal is a " + animal)
What will this output?
Reusing variables
We can replace values in variables:
animal = "dog"
print("My favourite animal is a " + animal)
animal = "cat"
print("My favourite animal is a " + animal)
animal = animal + "dog"
print("My favourite animal is a " + animal)
My favourite animal is a dog
My favourite animal is a cat
My favourite animal is a catdog
What will this output?
Asking a question!
It’s more fun when we get to interact with the computer! ��Let’s get the computer to ask us a question!
my_name = input('What is your name? ')
print('Hello ' + my_name)
This is what happens …
What is your name? Maddie
Hello Maddie
Breaking it down
my_name = input('What is your name? ')
print('Hello ' + my_name)
What do you think happens?
What is your name? Maddie
Hello Maddie
Store the answer in the variable my_name
Breaking it down
my_name = input('What is your name? ')
print('Hello ' + my_name)
What do you think happens?
What is your name? Maddie
Hello Maddie
Store the answer in the variable my_name
Writing input tells the computer to wait for a response
Breaking it down
my_name = input('What is your name? ')
print('Hello ' + my_name)
What do you think happens?
What is your name? Maddie
Hello Maddie
Store the answer in the variable my_name
Writing input tells the computer to wait for a response
This is the question you want printed to the screen
Breaking it down
my_name = input('What is your name? ')
print('Hello ' + my_name)
What do you think happens?
What is your name? Maddie
Hello Maddie
Store the answer in the variable my_name
Writing input tells the computer to wait for a response
This is the question you want printed to the screen
We can use the answer the user wrote that we then stored later!
Breaking it down
my_name = input('What is your name? ')
print('Hello ' + my_name)
SPACE 🙂
What is your name? Maddie
Hello Maddie
Big Tip : Put a space at the end of the question so it won’t be squished together with your answer - it looks nicer!
NO SPACE 🙁
What is your name?Maddie
Hello Maddie
Adding a comment!
Sometimes we want to write things in code that the computer doesn’t look at! We use comments for that! ��Use comments to write a note or explanation of our code
Comments make code easier for humans to understand
We can make code into a comment if we don’t want it to run (but don’t want to delete it!)
# This code was written by Sheree
# print(“Goodbye world!”)
Project time!
You now know all about printing, variables and input!�
Let’s put what we learnt into our project
Try to do Lessons 1 & 2
Don't forget to copy your code when you move to a new Lesson!
The tutors will be around to help!
If Statements and Lists
Conditions!
Conditions let us make decisions.
First we test if the condition is met!
Then maybe we’ll do the thing
If it’s raining take an umbrella
Yep it’s raining
…... take an umbrella
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
True
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
True
True
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
True
True
False
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
True
True
False
False
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
True
True
False
False
True
Booleans (True and False)
Computers store whether a condition is met in the form of �True and False
To figure out if something is True or False we do a comparison
"Dog" == "dog"
"D" in "Dog"
"Q" not in "Cat"
5 < 10
3 + 2 == 5
5 != 5
True
True
False
False
True
True
Conditions
So to know whether to do something, they find out if it’s True!
fave_num = 5
if fave_num < 10:
print("that’s a small number")
Conditions
So to know whether to do something, they find out if it’s True!
fave_num = 5
if fave_num < 10:
print("that’s a small number")
That's the condition!
Conditions
So to know whether to do something, they find out if it’s True!
fave_num = 5
if fave_num < 10:
print("that’s a small number")
Is it True that fave_num is less than 10?
That's the condition!
Conditions
So to know whether to do something, they find out if it’s True!
fave_num = 5
if fave_num < 10:
print("that’s a small number")
True
Is it True that fave_num is less than 10?
Put in the answer to the question
Conditions
So to know whether to do something, they find out if it’s True!
fave_num = 5
if fave_num < 10:
print("that’s a small number")
True
What do you think happens?�>>>
Conditions
So to know whether to do something, they find out if it’s True!
fave_num = 5
if fave_num < 10:
print("that’s a small number")
True
What do you think happens?�>>> that’s a small number
Conditions
How about a different number???
fave_num = 9000
if fave_num < 10:
print("that’s a small number")
Conditions
Find out if it’s True!
fave_num = 9000
if fave_num < 10:
print("that’s a small number")
What should this say?
Conditions
Find out if it’s True!
fave_num = 9000
if fave_num < 10:
print("that’s a small number")
Is it True that fave_num is less than 10?
What should this say?
Conditions
Find out if it’s True!
fave_num = 9000
if fave_num < 10:
print("that’s a small number")
Is it True that fave_num is less than 10?
What should this say?
False
Conditions
Find out if it’s True!
fave_num = 9000
if fave_num < 10:
print("that’s a small number")
False
What do you think happens?�>>>
Conditions
Find out if it’s True!
fave_num = 9000
if fave_num < 10:
print("that’s a small number")
False
What do you think happens?�>>>
Nothing!
If statements
fave_num = 5
if fave_num < 10:
print("that’s a small number")
This line …
… controls this line
If statements
fave_num = 5
if fave_num < 10:
print("that’s a small number")
print("and I like that")
print("A LOT!!")
This line …
… controls anything below it that is indented like this!
Actually …..
If statements
fave_num = 5
if fave_num < 10:
print("that’s a small number")
print("and I like that")
print("A LOT!!")
What do you think happens?�>>>
If statements
fave_num = 5
if fave_num < 10:
print("that’s a small number")
print("and I like that")
print("A LOT!!")
>>> that’s a small number�>>> and I like that�>>> A LOT!!
If statements
word = "GPN"
if word == "GPN":
print("GPN is awesome!")
What happens?
If statements
word = "GPN"
if word == "GPN":
print("GPN is awesome!")
What happens?
>>> GPN is awesome!
:
At end of each if line to say you have finished writing your condition
==
When testing for equals in your condition
Remember …
Lists
But we don’t store it on lots of little pieces of paper!
We put it in one big shopping list!
��
Bread
Ice Cream
Chocolate
Pizza
When we go shopping, we write down what we want to buy!
Lists
It would be annoying to store it separately when we code too
>>> shopping_item1 = "Bread"
>>> shopping_item2 = "Chocolate"
>>> shopping_item3 = "Ice Cream"
>>> shopping_item4 = "Pizza"
So much repetition!�
Instead we use a python list!
shopping_list = ["Bread", "Chocolate", "Ice Cream", "Pizza"]
List anatomy
shopping_list = ["Bread", "Chocolate", "Ice Cream", "Pizza"]
Stored in the variable shopping_list
List anatomy
shopping_list = ["Bread", "Chocolate", "Ice Cream", "Pizza"]
Made up of different items (these are strings)
Stored in the variable shopping_list
List anatomy
shopping_list = ["Bread", "Chocolate", "Ice Cream", "Pizza"]
Made up of different items (these are strings)
Stored in the variable shopping_list
The items are separated by commas
List anatomy
shopping_list = ["Bread", "Chocolate", "Ice Cream", "Pizza"]
Has square brackets either side
Made up of different items (these are strings)
Stored in the variable shopping_list
The items are separated by commas
Lists
You can print a list
shopping_list = ["Bread", "Chocolate", "Ice Cream", "Pizza"]
print(shopping_list)
>>> ["Bread", "Chocolate", "Ice Cream", "Pizza"]
Project Time!
You now know all about if and lists!
�See if you can do Lesson 3
The tutors will be around to help!
Random!
That’s so random!
There’s lots of things in life that are up to chance or random!�
Python lets us import common bits of code people use! We’re going to use the random module!
We want the computer to be random sometimes! �
Using the random module
Let’s choose something randomly from a list!
This is like drawing something out of a hat in a raffle!
Try this!
>>> import random
>>> shopping_list = ["eggs", "bread", "apples", "milk"]
>>> random.choice(shopping_list)
Using the random module
You can also assign your random choice to a variable
>>> import random
>>> shopping_list = ["eggs", "bread", "apples", "milk"]
>>> random_food = random.choice(shopping_list)
>>> print(random_food)
Using the random module
Let’s choose something randomly from a list!
This is like drawing something out of a hat in a raffle!
We use random.choice to randomly select something from a list
Each time we run this we would probably get a different answer
eggs OR bread OR apples OR milk
import random
shopping_list = ["eggs", "bread", "apples", "milk"]
random.choice(shopping_list)
Project Time!
Raaaaaaaaaandom! Can you handle that?
Let’s try use it in our project!
Try to do Lesson 4�� The tutors will be around to help!
Using the random module
You can also assign your random choice to a variable and then use that variable in your code
import random
shopping_list = ["eggs", "bread", "apples", "milk"]
random_food = random.choice(shopping_list)
print(random_food)
The variable random_food contains the random choice that was made from the list
How did you go?
Click on the
End of Day Survey
and fill it in now!
girlsprogramming.network/workshop
Click on your node location