Data Structures


15 min.   |   Beginner  

list

A list is a ordered, mutable (can change data) collection of data.

tuple

A tuple is a ordered, immutable (can not change data) collection of data.

set

A set is a unordered collection of unique elements.

dict

A dictionary dict is a unordered collection of key-value pairs.

Data Structures: Exercises

Tip Data Structures: Exercise 1

Compute the mean of the data list.

Tip Data Structures: Exercise 2

Create a 3 \times 3 identity matrix I as a list of lists.

Tip Data Structures: Exercise 3

A student has a dictionary of short notes for three courses. Compute the total number of characters across all notes using the formula:

\text{Total Characters} = \sum (\text{length of each string})

Tip Data Structures: Exercise 4

Two points are represented as tuples u and v. Compute the Euclidean distance between the points using the formula:

\| \mathbf{u} - \mathbf{v} \|_2 = \sqrt{ \sum_{i=1}^n (u_i - v_i)^2 }

Tip Data Structures: Exercise 5

Compute the range of the data list.