Lesson 1 of 18

Vectors

Vectors in Python

A vector is an ordered list of numbers. In Python, we represent vectors as plain lists.

v = [3, 1, 4, 1, 5]
print(v)        # [3, 1, 4, 1, 5]
print(len(v))   # 5  — number of elements
print(v[0])     # 3  — zero-indexed

Why Lists?

Python lists are flexible and sufficient for learning linear algebra concepts. For high-performance numerical work, libraries like NumPy provide array types with vectorized operations.

Indexing

Python uses 0-based indexing. v[0] is the first element, v[-1] is the last.

Length

len(v) returns the number of elements. For a vector in Rn\mathbb{R}^n, this is nn.

Your Task

Implement make_vector(values) that takes a Python list and returns it as a vector (list).

Pyodide loading...
Loading...
Click "Run" to execute your code.