Check the following Python instructions. These are all you need to know to start creating your first Python scripts!
You can also check our more advanced Python Helpsheet:

Check the following Python instructions. These are all you need to know to start creating your first Python scripts!
You can also check our more advanced Python Helpsheet:

Number Sequence #1:
Number Sequence #2:
Number Sequence #3:
An Arithmetic Sequence is made by adding the same value each time. When creating an arithmetic number sequence you have to decide of a starting number (e.g. “2”) and an increment (e.g. “3”)

A Geometric Sequence is made by multiplying by the same value each time.
When creating a geometric number sequence you have to decide of a starting number (e.g. “2”) and a multiplier (e.g. “3”)




You can also adapt or even mix these techniques to create your own number sequences!
This challenge is inspired from Michael Rosen and Helen Oxenbury’s children book “We are going on a bear hunt”. In this story, a family skids down a grassy slope, swishes across a river, sludges through mud and finally sees a bear who chases them all the way back to their home.
This story is based on a repetitive verse where the same verse is repeated several times and each time only a few words are changed.
So let’s see how we could apply our programming skills to print the words or lyrics of a repetitive story or song.
You will also use string concatenation techniques to join two strings together.
Investigate the code below. See how we have defined a subroutine called printVerse() and used two parameters for this subroutine: obstacle and onomatopoeia (a word that represents a sound: e.g. splosh).
Four little speckled frogs
Sat on a speckled log
Eating some most delicious bugs – yum, yum
One jumped into the pool
Where it was nice and cool
Now there are three green speckled frogs – glub, glub.
Three little speckled frogs
Sat on a speckled log
Eating some most delicious bugs – yum, yum
One jumped into the pool
Where it was nice and cool
Now there are two green speckled frogs – glub, glub.
Two little speckled frogs
Sat on a speckled log
Eating some most delicious bugs – yum, yum
One jumped into the pool
Where it was nice and cool
Now there are one green speckled frogs- glub, glub.
One little speckled frogs
Sat on a speckled log
Eating some most delicious bugs – yum, yum
One jumped into the pool
Where it was nice and cool
Now there are no green speckled frogs – glub, glub.
Nine little ladybugs skipping on a gate,
along came a caterpillar – then there were…
Eight little ladybugs looking up at heaven,
along came a bird – then there were…
Seven little ladybugs resting on sticks,
along came a grasshopper – then there were…
Six little ladybugs flying near a hive,
along came a bumble bee – then there were…
Five little ladybugs sleeping by the shore,
along came a fish – then there were…
Four little ladybugs climbing up a tree,
along came a turtle – then there were…
Three little ladybugs drinking up dew,
along came a duck – then there were…
Two little ladybugs basking in the sun,
along came a frog – then there was…
One little ladybug sitting all alone,
along came a breeze – then she was HOME!
First you will need to learn the shapes/symbols used to draw the four main logic gates:
| Symbol | Logic Gate |
![]() |
|
![]() |
|
![]() |
|
![]() |
One way to check and troubleshoot your code is to perform a dry run using a trace table.
Trace tables are used by programmers to track the values of variables as they change throughout the program. This is useful when a program is not producing the desired result.
Number Sequence #1:
Number Sequence #2:
Number Sequence #3:
The primary teacher decided to create some Python script to help them create similar number sequences.
Here is the pseudo-code for her first script:
number = 3
PRINT number
FOR i from 1 to 3:
number = number + 5
PRINT number
PRINT "?"
To make sure her script is working she decided to complete a dry run test using a trace table. See animation below:

number = 5
PRINT number
FOR i from 1 to 3:
number = number + i
PRINT number
PRINT "?"
Step 2: Implement this code using a high level programming language (e.g. Python) and compare your trace table with your actual output of your program.
number1 = 2
number2 = 5
PRINT number1
PRINT number2
FOR i from 1 to 4:
number1 = number1 + number2
PRINT number1
number2 = number1
PRINT "?"
Step 2: Implement this code using a high level programming language (e.g. Python) and compare your trace table with your actual output of your program.

This top-down/modular approach to designing and structuring your applications will enable you to break down what may seem like a very complex project into smaller, achievable modules that you will complete progressively one at a time.
In order for your end-user to access to all the modules available you may be willing to offer a menu structure. This could use drop down menu bars, touch screen icons/menus or a text-based menu system used with a command prompt to interact with the end-user.
In this challenge we will focus on this latest approach: a text-based menu system with a command prompt to retrieve user inputs/choices. Note that the logic behind this would be similar with other types of menus based on a Graphical User Interface or touchscreen or even with a voice activated interface.
Let’s look at how this would look like once implemented using Python:
When using a modular approach to breaking down a large project we often spread the code accross multiple files. It makes troubleshooting a lot easier.
Your challenge is
to write a Python program that will read through the data from the US States.txt text file provided below in order to find out:
The given text file is a CSV file (Comma Separated Values) with the following fields:



To complete this challenge you will first find the exact longitude and latitude of both the postcodes entered by the end user. The following text file contains a list of all the UK outer codes (first part of a postcode) with their exact longitude and latitude.

Once your program will have retrieved the longitude and latitude of both locations (postcodes) it will use the Haversine formula to calculate the exact distance between these two locations.
This formula will enable us to calculate the shortest distance over the earth’s surface – giving an ‘as-the-crow-flies’ distance between the two locations (ignoring any hills they fly over, of course!).
You can read more about the haversine formula on this wikipedia page.
To complete this challenge you will also need to investigate the use of trigonometric functions from the math library.



Note that when completing this challenge, longitudes and latitudes are given in degrees, not radians.
Once completed you can check your distances online.


Your program should ask the number of teams the teacher needs (between 2 and 6), read the names of the pupils from the text file and assign pupil randomly to teams. However there should be roughly (or exactly when possible) the same number of pupils in each team.


Before attemtping to complete this challenge, make sure you read about file handling operations using Python.

Using the class.txt file, write a Python program to meet the teacher’s requirements.
