-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayop.py
More file actions
88 lines (63 loc) · 1.36 KB
/
arrayop.py
File metadata and controls
88 lines (63 loc) · 1.36 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 17 11:04:45 2019
@author: Patil
"""
import array as t
a=t.array('i',[])
n=int(input('Enter Size : '))
for i in range(n):
b=int(input('Enter Elements : '))
a.append(b)
def count():
ct=int(input('Enter Number to be count : '))
print(a.count(ct))
def length():
print(len(a))
def index():
i=int(input('Enter Element : '))
print(a.index(i))
def insert():
loc=int(input('Enter Loc : '))
ele = int(input('Enter Element : '))
a.insert(loc,ele)
print(a)
def pop():
p=int(input('Enter Location To be Popped : '))
a.pop(p)
print(a)
def remove():
de=int(input('Enter Element to be removed : '))
a.remove(de)
print(a)
def insert():
inp=int(input('Enter Element to be inserted : '))
loc=int(input('Enter Loc : '))
a.insert(loc,inp)
print(a)
count()
length()
index()
pop()
remove()
insert()
'''
Enter Size : 5
Enter Elements : 5
Enter Elements : 4
Enter Elements : 3
Enter Elements : 2
Enter Elements : 1
Enter Number to be count : 4
1
5
Enter Element : 3
2
Enter Location To be Popped : 2
array('i', [5, 4, 2, 1])
Enter Element to be removed : 2
array('i', [5, 4, 1])
Enter Element to be inserted : 3
Enter Loc : 2
array('i', [5, 4, 3, 1])
'''