If you haven’t already, read the Overview page here before starting:
Learning Objectives
Python Fundamentals
By the end of this Level, a learner should be able to:
PY01: Run a Python program in the terminal PY01.1: Successfully navigate to a Python file in the terminal PY01.2: Install Python via the terminal PY01.3: Run a program using Python3 PY02: Write code that interacts with all of the built-in Python types PY02.1: Write code that creates and manipulates collections of data in arrays PY02.1.1: Create and initialise an empty list PY02.1.2: Declare a list and fill it with data PY02.1.3: Retrieve an element from an array using an indices PY02.1.4: Add an element to an array using append PY02.1.5: Remove an element from an array using pop PY02.2: Write code that uses a Boolean type PY02.2.1: Define the two states that a Boolean type can be in - True or False PY02.3.2: Manipulate numbers stored in variables using arithmetic operators PY02.4.1: Create and initialise a string in a variable PY02.4.1: Manipulate strings using string methods PY02.4.2: To access characters in a string using [] notation PY02.6: Use type to find the type of a variable’s value PY02.6.1: To predict the type of a variable given its value PY03: Write code that can create and manipulate variables PY03.1: Define what a constant variable is and when they should be used PY04: Write code that iterates PY04.1: Use a for loop to iterate a fixed number of times PY04.1.1: Define the correct syntax for a for loop in Python PY04.1.1: Use the range function to create an iterator PY04.2: Use a while loop to iterate until a condition is met PY04.2.1: Define the correct syntax for a while loop in Python PY04.3: Iterate over a list using a loop PY04.3.1: Use the elements of a list to iterate through an array PY07.1.1: Define what a parameter is and why it is useful PY07.2: Write code to call a function and expect a return value PY07.2.2: Write code that returns a value PY07.2.2.1: Define when a return can or cannot be used PY07.3: Write code that calls a function and stores the returned data in a variable Debugging
D03.1: Use console.logs to print the value of variables Productivity
P01.1: Know when to ask for support with technical problems P02: Know how long to spend working through a problem before asking for help P03.1: Knows how to ask for help from a coach Setup
For these challenges, you will be using an online editor - we use . This makes it easy for us to see your project code in an easy to run environment. To use Replit:
To create a new project (please use one for each task), use the “Create” button and create a new “Python” repl. Once you open the project, in the code editor, under main.py , enter some lines of code. Once you’re done writing code, press “Run” at the top of the screen. It might take a few seconds to run, but your output should be in the console on the left. To create a project submission link:
Press the “Invite” button in the top right corner. At the bottom of the pop up there should be a “Generate Join Link”, click this. Copy the link and add it to your pre-work submission. Getting stuck
We do not expect you to run through these tasks without difficulty. It can be difficult learning how to code and it requires patience and skills that will build as you progress with your learning.
Debugging
Learning Objectives: P01.1, P02, P03.1
It is very likely you will run into code that will not work and it can be overwhelming when you aren’t sure of where the problem is. We recommend going back to the drawing board - step away from the technical syntax and make sure you fully understand what it is you want the code to do.
Write out what your inputs should be - what sort of parameters or variables are you going to be working with? Write out what your outputs should be - what should your code return? Write a test case - for example, if you are writing a function called squareInput then a test case might look like the below. This is so you can see when your code is working as intended. test_case = square(5)
4. Write a list of steps that you think your code needs to take to reach the output. Following the above example would look like:
1. Take an input from the user
2. Pass the input into a function called square()
3. The function should take the input and multiply it by itself
4. Storing it into a variable called squared_value
5. Return squared_value
6. Print the squared_value
5. Compare your steps to what your code is currently doing, line by line. Follow the ‘order of execution’, where you can trace the test case input line by line to see how it changes in the code you have written. This is a great way of seeing if your code is actually running how it is intended to.
print(f'The correct answer is 25. The function returns {test_case')
Limit your time
If you have been working on a problem for longer than half an hour of being stuck and not making any progress, either ask for help or move on to a different part of the task. It helps to be away from a problem and come back with a fresh perspective.
Ask for help
When stuck or confused when learning it is incredibly important to communicate - please email us with a brief description of the problem, any relevant code and any assumptions you have made. We will reply as quickly as we can - in the mean time, work on a different part of the Challenge or Level.