One record, one row
A register is a school's list of its students. Every student in it is one row. A section is a class group, such as 9-A. The due is the fee money a student still owes, in rupees. Positions count from 0, so rows[2] is the third row.
- Five rows, one heading row above them.
- In this register, position 0 is the admission number.
- In this register, position 3 is the due.
rows[2][3]reads Chandni's due: 1450.
The rule
A record is one row of values that belong together. The heading row names the columns. One field takes two positions: first the row, then the column.
The full register has twelve rows, not five:
| admission | name | section | due |
|---|---|---|---|
| A-101 | Aarti Kulkarni | 9-A | 3200 |
| A-102 | Bharat Iyer | 9-A | 0 |
| A-103 | Chandni Shah | 9-B | 1450 |
| A-104 | Dev Patil | 9-A | 800 |
| A-105 | Esha Rao | 9-B | 3200 |
| A-106 | Farid Khan | 9-A | 1450 |
| A-107 | Gauri Menon | 9-B | 0 |
| A-108 | Ananya Suresh | 9-A | 1450 |
| A-109 | Hari Verma | 9-B | 2050 |
| A-110 | Ananya Suresh | 9-A | 2050 |
| A-111 | Ishita Bose | 9-B | 1450 |
| A-112 | Rhea Mehta | 9-A | 900 |
Every record here is invented. If a name sounds familiar, that is a coincidence.
The lab asks for a position past a row's end, on purpose. A row has four values, positions 0 to 3. The runner is the tool that runs your code. In this course's runner, asking for position 4 stops the run. It says: You asked for position 4, but the list has 4 items.
To fetch a field is to read that one value. The walk is open below. Predict each fetched field, then reveal it.
Loading lab…
Every field a program reads takes two positions.