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

Показать описание
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
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
Комментарии