forked from jwasham/practice-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.py
More file actions
30 lines (18 loc) · 508 Bytes
/
array.py
File metadata and controls
30 lines (18 loc) · 508 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
# Experiments using Python arrays and vectors
def array_test():
ar = [3, 2, 4, 5]
ar.pop()
ar.append(6)
print(ar)
print("Index of 4: ", ar.index(4)) # index of given value
ar.remove(4) # remove the first occurence of item with given value
print("Removed 4: ", ar)
ar.reverse()
print("reversed: ", ar)
print("sorted return: ", sorted(ar))
ar.sort()
print("sorted in place: ", ar)
def main():
array_test()
if __name__ == "__main__":
main()