Does anyone have an idea about implementing two dimensional arrays in Python??

I want to write two programs:
(1) a program for matrix multiplication
(2) a program for displaying Pascal's triangle.

Both these programs require two dimensional array..? Or is there any other way to solve this..
Thanks in anticipation..

Regards,
A Kadri

Re: How to implement multi-dimensional arrays in Python?? 80 80

You can define matrix using list:

matrix = [[1,2,3],[4,5,6],[7,8,9]]

print matrix[0][1]

As for multiplication program and Pascal's triangle, you'll need to show some effort. Matrix is not needed for displaying Pascal's triangle

Re: How to implement multi-dimensional arrays in Python?? 80 80

There are modules like numpy, that do high speed array and matrix manipulations. Google for numpy, its free.

Re: How to implement multi-dimensional arrays in Python?? 80 80

Pascal's triangle is most easily done using recursion, IMO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.