-
Notifications
You must be signed in to change notification settings - Fork 5
/
Ex_Sheet_2_Num_2.py
48 lines (32 loc) · 891 Bytes
/
Ex_Sheet_2_Num_2.py
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
"""
Author: Gabriele Pompa
Identification Number: ABCXYZ [substitute with your Unisi Identification Number]
Date: 23-Mar-2020
File name: Ex_Sheet_2_Num_2.py
Description: This script computes prints indexes and values of an array.
"""
import numpy as np
def printArray(a):
"""
Function printArray(a) prints indexes and values of array a.
Parameters:
a (numpy.ndarray): input array.
Returns:
None
"""
for i, ai in enumerate(a):
print("Index i = {} - Value a[i] = {}".format(i, ai))
def main():
"""
Function main() defines a NumPy array and computes the product of its elements.
Parameters:
None
Returns:
None
"""
# test array
arr = np.array([17, 5, -10, 8, -2])
# print function
printArray(arr)
if __name__ == "__main__":
main()