Python NumPy Tutorial for Absolute Beginners - #2 NumPy Array (fast pace)

Published: 01 March 2021
on channel: Raza Zaidi
1,031
18

Learn programming in NumPy, a Python Library, 100 seconds at a time in this video for beginners. This is video number 2: NumPy Array

I know im going fast in this video, please use timestamps below to navigate the video.
Timestamps:
00:00 - the array function
00:12 - create array from list
00:23 - 2 dimensional array
00:36 - zeros function
00:51 - ones function
01:01 - arange function
01:31 - linspace function

—————————————————————
NumPy Array
—————————————————————
Import numpy as np to make use of the numpy library

Use the array function to create a numpy array
This is a so called 1darray or one dimensional array

A numpy array can be created from a python list
First create a python list.
On the second line apply the np.array function
Now the python list is converted to a numpy array

In order to create a two dimensional array or matrix, write two lists within a list
Which is also called writing a nested list, like this
Use the np.array function again and Here you can see this creates a matrix

To create an array filled with multiple zero values, use the zeros function.
In this function you can also specify the type of data.
Specify first how many zeros you want and then the type of data.
Here we will use integers

Another function is ‘ones’ which create an array filled with multiple values equal to 1.
Here the data type is float, which is a number with a decimal

The arange function is like the range function for python lists.
With the arange function, an array with a specified range of numbers is created.
Besides the start and stop value, we can enter the step.
By entering a 2, an array of numbers is compiled from 0 to 8, first printing zero, then adding 2 to the value for the next step and then printing the value 2.
For the next step 2 is added again and the value 4 is printed and so forth.


With the linspace function an array is created with 10 values evenly spaced between 0 and 1 with the upper value included
————
 
————————————————————————



🦁 Who are you?
My name is Raza. I am 30. I am an IT - manager right now, but I’ve been an accountant for the majority of my career.
I’m in love with #Python :)

You can find me here:
📷 Instagram:   / razacodes  
📈 Twitter:   / razacodes  
—————————————————————————————

Goals for 2021
Training Python hours: 45/1000
Python/Django Projects: 1/30
Subscribers: 1677/10,000

—————————————————————————————-
#100SecondsOfCode
#pythonforbeginners #programming