Tuples, Indices, and Coordinates
A tuple is an ordered collection.
For example:
is not the same as:
The values are the same. The order is different. For a tuple, that matters.
Why Order Matters
The pair can mean:
2 units horizontally
5 units vertically
If we switch the order to , we get a different point.
This is why we need tuples before vectors. A vector is not merely a bag of numbers. The positions of the numbers carry meaning.
Enter 1 if and are different tuples.
Compute it first, then check your number.
HintCompare positions
Is the first coordinate the same in both tuples?
SolutionDifferent order
Enter 1. In , the first value is 2. In , the first
value is 5.
Indices
An index tells us which item we are talking about.
If
then we might write:
This is one-based mathematical indexing.
The subscript does not multiply. It names position. The symbol means "the second component of ", not " times 2."
If using mathematical indexing, what is ?
Compute it first, then check your number.
HintCount mathematically
In this notation, the first item is .
SolutionSecond component
The second item is 7, so . In this mathematical notation, the
first component is , so means the second component.
Python Indexing
In Python, indexing usually starts at zero:
x = [4, 7, 9]
print(x[0]) # 4
print(x[1]) # 7
print(x[2]) # 9
This is not a contradiction. It is a convention.
Mathematics often writes the first item as . Python writes the first item
as x[0].
In Python, if x = [4, 7, 9], what does x[1] return?
Compute it first, then check your number.
HintStart at zero
x[0] is 4, so x[1] is the next item.
SolutionPython position
Python uses zero-based indexing:
x[0] = 4
x[1] = 7
x[2] = 9
So x[1] returns 7. This differs from mathematical indexing because
Python starts counting positions at zero.
Coordinates
Coordinates are indexed values with a geometric meaning.
The tuple
can name a point in the plane:
move 2 units horizontally
move 5 units vertically
The same notation can become a vector in the next chapter.
For the point , what is the vertical coordinate?
Compute it first, then check your number.
HintUse the position
In , the second coordinate is usually the vertical coordinate.
SolutionSecond coordinate
The point is . The second coordinate is 5, so the vertical
coordinate is 5.
Common Trap
Do not mix mathematical indexing and Python indexing without checking.
If a formula writes , it probably means the first mathematical component.
If code writes x[1], it probably means the second Python list item.
Next, we compress repeated addition and multiplication with sums and products.