Python Basicly Numpy Library

Serap Baysal
CNK Tech
Published in
2 min readMar 5, 2021

In this post, I will tell you about Python and basicly Numpy. Python is a programming language. It’s popular in nowadays, because simple and useful.

Numpy is a Python library. It’s have functions about math operations and vectors. Useful because speedy about math operations. Let’s look in Numpy functions a little more.

For using Numpy, we have to import it. Importing is simple, just write import numpy as np. np section is optional. Generally, it’s functions about arrays, vectors. So we will create an array and start.

Creating arrays are simple like always. We just define a variable and use .array function:

array = np.array([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])

Now, we have an array with 15 element. But elements are 1*15 size. It means our array is just have one row and fifteen colums. If we want to reshape this array, just must use .reshape function:

a = array.reshape(3,5)

a variable has a vector with 15 elements but it’s elements arrangment different from array variable, have 3 rows and 5 columns.

You seem the difference in this screenshot.

print(“shape: “,a.shape)

print(“dimension: “, a.ndim)

print(“data type: “, a.dtype.name

print(“size: “,a.size)

print(“type: “,type(a))

These codes are diffrent functions in numpy. For using, you’ll just write variable’s name and .function_name . (print function , as you know, will printing on screen.)

Let’s create an array with zeros. You can do it with writing zeros on an array. But there’s an easy way to do it. Like this:

zeros = np.zeros((3,4))

The same thing is with ones. Or if you want to creating an empty array, you’ll do same. But in emty array, if you print, seem random numbers:

If you write np.arange(10,50,5), you can see numbers in [10,50) increasing 5. Or writing np.linspace(10,50,20) , there are 20 numbers are in [10,50].

This is basicly Numpy. Of course if you want to learn AI, threre’s a long way to go. Thanks for reading!

--

--