Q. What is an array and how is it different from a list? What is the name of the built-in array class in NumPy?


Answer:-

List can have elements of different data types for example, [1, 3.4, ‘hello’, ‘a@’]    all elements of an array are of same data type for example, an array of floats may be: [1.2, 5.4, 2.7]
Elements of a list are not stored contiguously in memory Array elements are stored in contiguous memory locations. This makes operations on arrays faster than lists.
Lists do not support element wise operations, for example, addition, multiplication, etc. because elements may not be of same type Arrays support element wise operations. For example, if A1 is an array, it is possible to say A1/3 to divide each element of the array by 3.

The built-in array class in NumPy is called ndarray.

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post