Code Labs: Data Structures

Put Arrays, Indexing, and 2D Matrices into practice.

Interactive Engine

Use the interactive terminal below to test Python Lists (1D Arrays).

> Waiting to compile...

The Crucible

Prove your knowledge of arrays and indexing.

Bronze (1D Indexing)

The Precise Extraction

You have an RPG inventory array: ["Sword", "Shield", "Potion", "Map"]. Remember that counting strictly starts at 0.

Task: Use square brackets [] to extract and print exactly the word "Potion".

> Output will appear here...
Silver (Modification)

Overwriting Data

Arrays are mutable (they can be changed). We need to fix a corrupted database score.

Task: Without deleting the array creation line, overwrite the very first score in the array so it equals 99 instead of 10.

> Output will appear here...
Gold (2D Arrays)

The Database Matrix

A 2D Array is just an array inside another array. To access it, you need TWO indexes: database[Row][Column].

Task: Look at the 2D array below (it represents a database table of usernames and passwords). Use 2D indexing to print the username "Admin".

> Output will appear here...