[Tutor] (no subject)
C
clarabuyss at gmail.com
Tue Sep 19 10:11:12 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
For now I only filled up the first row and first columns.
We were told to use the for loops as well as numpy for this. However, I
cannot quite figure out how I can use loops to do this. Please help!
Thank you in advance!
More information about the Tutor
mailing list