Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 1.75 KB

DRAFT 07 Moving along with Python.md

File metadata and controls

48 lines (32 loc) · 1.75 KB
Title Teaching Exercises Question Objectives Activity Keypoints
Moving along with Python
30
1
How do we create an array?
Understand what an array is and how it might be helpful
Create your own array
Using arrays helps create solutions which allow to apply an operation to an entire set of values at once. Efficiency FTW!

Paddling with Python

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:

https://youtu.be/aeoGGabJhAQ

QUICK CHECK

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.

Now let's create an array

  • 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]

Mini-activity

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?