Week 11: Lists and arrays

Python code typing course. 20 wpm, 93% accuracy.

A list holds several values in one place. In Python, a list is written between square brackets, and its items are separated by commas. You can read an item by its position number. Positions start at 0, so the first item is at position 0 and the second at position 1. This week you practice writing lists, placing commas correctly, and matching every pair of brackets.

What you will learn

On the US English layout, the three symbols are typed like this:

  • [ is the [ key, pressed with the right pinky.
  • ] is the ] key, pressed with the right pinky.
  • , is the comma key, pressed with the right middle finger.

Here is a list and a line that reads its first item:

fruits = ["apple", "pear"]
print(fruits[0])

The first line creates a list of two text items, separated by a comma. The second line prints the item at position 0, which is apple. Because counting starts at 0, the first item always sits at 0.

Technique tips

  • Type the opening square bracket, then immediately the closing one. Fill in the items afterwards.
  • Keep your right pinky steady for the [ and ] keys, since both use it.
  • Put a space after each comma. The space helps you see where each item starts and ends.
  • When you read an item by position, check that the number inside the brackets is the one you intended. Remember that counting starts at 0.
  • Text items need quotation marks. Keep the quotation marks and commas in mind as you type each item.

Lessons

  1. Lesson 1 (10 to 15 minutes): Learn. Watch the keyboard demo for the square brackets and the comma. Then type fruits = ["apple", "pear"] slowly.
  2. Lesson 2 (10 to 15 minutes): Practice. Repeat print(fruits[0]) and similar lines. Check that the brackets and commas match in every list.
  3. Lesson 3 (10 to 15 minutes): Review. Take the 2-minute test built from this week’s lists. Note the lines where a bracket or comma went missing and repeat them next session.

This week’s goal

The goal is 20 wpm with 93% accuracy. The first star comes when you finish the lessons. The second star comes at 93% accuracy, and the third when you also reach 20 wpm. A missing bracket or comma stops the list from working, so get the pairs right first.

Symbols this week

The colored keys are the ones you learn this week. The color shows which finger presses the key.

` ~ 1 ! 2 @ 3 # 4 $ 5 % 6 ^ 7 & 8 * 9 ( 0 ) - _ = + Backspace Tab Q W E R T Y U I O P [ { ] } \ | Caps A S D F G H J K L ; : ' " Enter Shift Z X C V B N M , < . > / ? Shift Ctrl Win Alt Alt Gr Win Menu Ctrl

This week’s lessons

Do the lessons in order. Each one ends with a test, and your best result is saved.

  1. Lesson 1: Learn

    New symbols: [ ] ,

    12 minutes

    Start
  2. Lesson 2: Practice

    Practice

    12 minutes

    Start
  3. Lesson 3: Review and test

    Review and test

    12 minutes

    Start

All weeks