arrays and plotting often use similar approach to create an arraybut since an array has fixed length and no append-methodwe must first create an array of the right size and then loop over it with an index to fill in the values this operation is very commonso remembering the existence of numpy' zeros function is important as we have seen in lists in python are extremely flexibleand can contain any python object arrays are much more staticand we will typically use them for numbers ( type float or intthey can also be of other typessuch as boolean arrays (true/false)but single array always contains single object type we have also seen that arrays are of fixed length and do not have the convenient append-method sowhy do we use arrays at allone reasonwhich was mentioned aboveis that arrays are more efficient to store in memory and use in computations the other reason is that arrays can shortn our code and make it more readablesince we can perform operations on an entire array at once instead of using loops sayfor instancethat we want to compute the cosine of all the elements in list or array we know how to do this using for loop import numpy as np from math import cos np linspace( , , for in range(len( )) [icos( [ ]but if is an arrayy can be computed by np cos(xxarrayyarray in addition to being shorter and quicker to writethis code will run much faster than the code with the loop such computations are usually referred to as vectorized computationssince they work on the entire array (or vectorat once most of the standard functions we find in math have corresponding function in numpy that will work for arrays under the hood these numpy functions still contain for loopsince they need to traverse all the elements of the arraybut this loop is written in very efficient code and is therefore much faster than python loops we write ourselves function (xthat was written to work for single number will often work well for an array as well if the function uses only basic mathematical operators (+-*etc )we can pass it either number or an array as the argumentand it will work just fine with no modifications if the function uses more advanced operations that we need to importwe have to make sure to for the small array considered herecontaining just numbersthe efficiency gain does not matter at all it will be difficult to detect difference between the two versions even if we measure the run time of our program howevercertain numerical programs can use nested arrays containing tens of millions of numbersand in such cases the difference between loops and vectorized code becomes very noticeable