-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIn_python
36 lines (25 loc) · 818 Bytes
/
In_python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#we are going to see only one dimensional arrays
#In python to work with arrays we need to install numpy package to play with arrays
#Here i imported numpy as np for easy useage
import numpy as np
#here i created an array with help np.array
a=np.array([1,2,3,4,5])
#Toget the length of the array we can use len function
#length= last_index+1
print(len(a))
#remember index always starts with 0 only and always last index will be size-1
print(a[0])
print(a[4])
#In arrays we have find size
#we access the elements with the help of index values
print(a[2])
print(a[3])
#To change certian value we can use index to change it
a[0]=10
print(a[0])
#In arrays we can add elements with the help of append function
a=np.append(a,6)
print(a)
#To delete the element we use delete function
a=np.delete(a,4)
print(a)