-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumbers5.py
More file actions
73 lines (52 loc) · 1.9 KB
/
Numbers5.py
File metadata and controls
73 lines (52 loc) · 1.9 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
class Numbers:
def __init__(self):
self.Size = list()
self.Arr = list()
def Accept(self):
print("Enter how many elements you want: ")
self.Size = int(input())
print("Please enter the elements")
value = 0
for i in range(0,self.Size):
value = int(input())
self.Arr.append(value)
def Display(self):
print("Elements from list are: ")
for i in range(0,self.Size):
print(self.Arr[i])
def Summation(self):
Sum = 0
for i in range(0,self.Size):
Sum = Sum + self.Arr[i]
return Sum
def Average(self):
Sum = 0
for i in range(0,self.Size):
Sum = Sum + self.Arr[i]
return (Sum/self.Size)
def Maximum(self):
Max = self.Arr[0]
for i in range(0,self.Size):
if(self.Arr[i] > Max):
Max = self.Arr[i]
return Max
def Minimum(self):
Min = self.Arr[0]
for i in range(0,self.Size):
if(self.Arr[i] < Min):
Min = self.Arr[i]
return Min
def main():
obj = Numbers()
obj.Accept()
obj.Display()
Output = obj.Summation()
print("Summation of all elements is: ",Output)
Output = obj.Average()
print("Averageof all elements is: ",Output)
Output = obj.Maximum()
print("Largest elements is: ",Output)
Output = obj.Minimum()
print("Smallest elements is: ",Output)
if __name__ == "__main__":
main()