Below you’ll see some example python code that contains a shopping list
Ctrl + Enter to run the code.
This code starts by creating a list called
shopping which contains
It then adds
"pizza" to the end of the list and removes
Start by running the code.
'socks'to the shopping list
There’s two ways to do to this. You could either add it on line 3 so that it’s one of the original values in the list or you could copy and paste line 9 to append
"socks"to the end of the list.
'oranges'from the list
Again, there are two ways to do this. You could remove it from line 3 or use
- Add items to the list until there are exactly 10 items
You can find out how many items are in a list using
len(shopping)which calculates the length of the list called shopping. Just add more values until you’ve got 10 in total.
On the next page you’ll get some code with both syntax and logic errors
KPRIDE stands for Keywords, Predict, Run, Investigate, Debug and Extend and it’s a way of helping you explore and understand python code. Click on the image below for a set of KPRIDE activities for this python skill.
Page 1: Intro
Page 2: The theory: learn what you need to know as fast as possible.
Page 3: Try it: try out and adapt some working python code snippets.
Page 4: Debug it: Learn how to find and fix common mistakes.
Page 5: Extend it: Choose a project idea to use your newfound python skills.