-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15DynamicArray.py
More file actions
30 lines (28 loc) · 775 Bytes
/
Copy path15DynamicArray.py
File metadata and controls
30 lines (28 loc) · 775 Bytes
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
import numpy as np
#Method1
print("METHOD1")
size=int(input("Enter the size of the array: "))
my_list = list(range(size))
print("Before",my_list)
for i in range(len(my_list)):
num= int(input("enter the element at {}: ".format(i)))
my_list[i]=num
print("After ", my_list)
#Method2
print("METHOD2")
my_list1=[]
print("Before",my_list1)
size=int(input("Enter the size of the array: "))
for i in range(size):
num = int(input("enter the element at {}: ".format(i)))
my_list1.append(num)
print("After ", my_list1)
#Method3
print("METHOD3")
a = np.array([])
print("Before",a)
size=int(input("Enter the size of the array: "))
for i in range(size):
num = int(input("enter the element at {}: ".format(i)))
a = np.append(a, np.array([num]))
print("After ", a)