Title | Teaching | Exercises | Question | Objectives | Activity | Keypoints | ||||
---|---|---|---|---|---|---|---|---|---|---|
Moving along with Python |
30 |
1 |
|
|
|
|
In this section we are working with variables and we are going to create an array. An array is a data structure consisting of a collection of elements (called values or variables), with each identified by at least one key (or array index).
This video clearly explains these terms and a few others we've come across so far - let's have a look:
How are you going with these terms? Is there anyone who would like to try to explain what a variable is? What an array is? Keep a note of any terms you are unfamiliar with, and try to assign them a meaning that makes sense to you.
-
In your 'code' cell, write the following series of commands:
- arr = ["Jack", "Queen", "King"]
- print(arr[0])
- print(arr[1])
- print(arr[2])
-
Click on 'Run' or use the shortcut Shift+Enter to execute the cell.
[SCREENSHOT HERE]
- You have now printed an array. What you can see is that you have assigned each word a number (or a key, or array index).
- Now let's see what happens if we change something:
[NEED SOMETHING HERE TO SHOW THE POINT OF AN ARRAY I THINK]
Take a few minutes to create your own array, with 10 or more variables. Apply some changes to the code to see how you can interact with it. How could this be useful to you and or others in your area?