October 2025
Intermediate to advanced
485 pages
13h 2m
English
Let’s get to the fun stuff. While it seems that we’ve merely had a leisurely tour through some of our computer’s hardware, these concepts can directly impact the way we should write code.
Following is some code that computes the sum of integers contained within a two-dimensional array. For simplicity, let’s assume that the array is square, meaning that the rows and columns have equal lengths. I’m going to present two versions. Here’s Version One:
| | def compute_sum(array): |
| | size = len(array) |
| | sum = 0 |
| | |
| | for row_index in range(size): |
| | for column_index in range(size): |
| | sum += array[row_index][column_index] |
| | |
| | return sum |
It’s pretty straightforward. We iterate over each row, and within each row, we ...
Read now
Unlock full access