[Tutor] Require help for a script

Clara Chua clarabuyss at gmail.com
Tue Sep 19 03:48:40 EDT 2017


Hi Python tutor, I require help for a script that asks user for number of
rows, r and number of columns c, and generates a r x c matrix with the
following values:

- The value of each element in the first row is the number of the column
- The value of each element in the first column is the number of the row
- The rest of the elements each has a value equal to the sum of the element
above it and the element to the left.

Example of such matrix if a user inputs r=4 and c=5

1    2     3     4     5
2    4     7    11   16
3    7    14   25   41
4   11    25   50   91

We were told to use the for loops as well as numpy for this.
Thank you in advance!


More information about the Tutor mailing list