[Tutor] Require help for a script

D.V.N.Sarma డి.వి.ఎన్.శర్మ dvnsarma at gmail.com
Tue Sep 19 10:06:56 EDT 2017


First fill the first row and first column of the matrix with seperate loops.
Then the rest of the elements of the matrix can be filled with nested loops.
regards,
Sarma.


On Tue, Sep 19, 2017 at 1:18 PM, Clara Chua <clarabuyss at gmail.com> wrote:
> 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!
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list