#29 Python Tutorial for Beginners | Ways of Creating Arrays in Numpy

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing about:

-- Ways of creating arrays in numpy:
we have 6 way of creating arrays in numpy
a)array()
b)linspace()
c)arange()
d)logspace()
e)zeros()
f)ones()

from numpy import *
arr =array([1,2,3,4,5])
print(arr)

arr =array([1,2,3,4,5.0])
-- automatically it will convert the data type to float

arr =array([1,2,3,4,5],float)
-- we can also specify the data type of array

b) linspace()
-- it is used to create an array with equal interval between the elements
-- syntax: linspace(start,stop,num=50,endpoint=True,retstep=False,dtype=None)
arr=linspace(0,15,16) # here it break the range into 16 equal parts
-- by default it will take 50 parts

arr =linspace(0,15)
print(arr)

c) arange()
-- it is used to create an array with equal interval between the elements
-- syntax: arange(start,stop,step,dtype=None)
arr =arange(1,15,2)
print(arr)
-- it will create an array with start value 1 and end value 15 with step size 2
arr=arange(1,15,2.5)

d) logspace()
-- it is used to create an array with equal interval between the elements in log scale
-- syntax: logspace(start,stop,num=50,endpoint=True,base=10.0,dtype=None)
arr=logspace(1,40,5)
print(arr)

e) zeros()
-- it is used to create an array with all zeros
-- syntax: zeros(shape,dtype=float,order='C')
arr= zeros(5)
print(arr)

f) ones()
-- it is used to create an array with all ones
-- syntax: ones(shape,dtype=float,order='C')
arr=ones(5)
print(arr)

# if i want work with int
arr=ones(4,int)
print(arr)

Subscribe to our other channel:
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
Рекомендации по теме
Комментарии
Автор

I started learning programming through this Python playlist. It's the BEST!

service_to_krishna
Автор

Simple way to learn python, thanks for creating such excellent videos and keeping it free for everyone to learn .

minatisahoo
Автор

Hehe I am a total and complete n00b, you lost me at round lesson #21 to be honest, I am still going along to try and grasp the terminology etc. I think things will start coming together when I start doing practical examples. The material is incredible and I am loving it !

ob
Автор

thank fun learning with you....being cs student i was always afraid of coding...but the way you are teaching really creates interest and enjoy so much sir

rashmis
Автор

Sir, can u clearly explain what exactly is logspace(). What is meant that the values are divided on the basis of a logscale

chaitanyabingumalla
Автор

You increase my knowledge about python array to a higher level....You are really a genius

SammarpanDasguptaOfficial
Автор

Sir please explain clearly logspace once again so many has doubts on that

gunasagarchinnu
Автор

sir please explain the logspace() clearly, that is about how will the elements be divided any specific formula

mahendrakumarraichur
Автор

Hi Sir,

You are doing a great job.
I would like to give a feedback for this video. While importing module Numpy(or any other module) try to avoid using *, because it may have lots of functions with different names. In future, if we create a variable or method name with same name used in Numpy it may get conflict.
Import numpy as np
arr = np.array([1, 2])
It could be the better way.

venkateswarans
Автор

sir please start a project so we can implement all things

RAVINDERKUMAR-unhy
Автор

Hello Sir, i have a question, in Automation testing which scripting language i should choose java or python for getting job quickly and getting more calls.

harishsingh
Автор

Ur teaching is paranormal to others teaching sir I would like to appreciate ur videos sir tq....

b.sasikumar
Автор

Difference beween linspace() and logspace():

Suppose you have a cake, and you ask linspace to cut it into 5 parts, linspace will cut it in five EQUAL parts, But if you ask logspace to cut the cake into 5 parts, it will cut the cake in five UNEQUAL parts. Everyone will get different sizes, just that it will cut in five parts that's it.

SohailKhan-fbgb
Автор

Can you give us the PDF which will consist of all the concepts, methods to study and a better way to remember and study later
Pls consider my question sir pls

omsaipotti
Автор

add two arrays using for loop:


from numpy import *
arr=array([1, 2, 3, 4], int)
arr1=array([1, 1, 1, 1], int)
for a in arr+arr1:

print(a)

siddharthrangnani
Автор

Thank you very much. You are a genius.

vakhariyajay
Автор

sir, but what is the use of this zeros and ones function in array...& when it can be use

swapnilkshirsagar
Автор

Those who want Clarity on logspace()

The values that are given as input are log(base10) values
so if input is 2 the actual value is 10^2=100(^ means power)

logspace() follows Geometric Progression

It uses log(base 10) values. In simple Terms

Eg : logspace(2, 5, 3)

here 2 means 10 raised 2 times which is 100 (Prior Knowledge on log is required here)

and 5 means 10 raised 5 times which is

In Geometric Progression nth term is a*r^(n-1) (^ means power

here a value is 100
n is 3
last term (nth term)=



r^2=1000



so the 3 numbers are
,



So The 3 numbers are


Like If You Got Clarity

maheshvangala
Автор

nice one Mr == right sir. can't stop learning and running this

danielkamau
Автор

addition of array is
from numpy import *
arr1=array([1, 2, 3, 4, 5])
arr2=array([6, 7, 18, 9, 2])
for i in range(5):
arr3 = arr1+arr2
print(arr3)

vivekkumar-jnwh
join shbcf.ru