-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmax number.py
115 lines (86 loc) · 2.35 KB
/
max number.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# import colorama
# from colorama import init
# init()
# from colorama import Fore, Back, Style
# import math
class Shortcuts:
def __init__(self):
pass
def sort(list):
for n in range(len(list) - 1, 0, -1):
for no in range(n):
if list[no] > list[no+1]:
temp = list[no]
list[no] = list[no+1]
list[no+1] = temp
return list
def max(list):
max = list[0]
for n in list:
if n > max:
max = n
return max
def min(list):
min = list[0]
for n in list:
if n < min:
min = n
return min
def even(list):
even_list = []
for n in list:
if n % 2 == 0:
even_list.append(n)
return even_list
def odd(list):
odd_list = []
for n in list:
if n % 2 != 0:
odd_list.append(n)
return odd_list
def add(list):
result = 0
for n in range(len(list)):
result = result+list[n]
return result
def half(list):
new_list = []
for n in list:
new_list.append(n / 2)
return new_list
def double(list):
new_list = []
for n in list:
new_list.append(n * 2)
return new_list
def mean(list):
total_value = Shortcuts.add(list)
mean = total_value / len(list)
return mean
def median(list):
new_list = Shortcuts.sort(list)
length = len(new_list)
index = int(length / 2)
if int(index % 2) == 1:
result = new_list[index]
else:
result = [new_list[index], new_list[index] - 1]
return result
def standard_deviation(list):
mean = Shortcuts.mean(list)
result = 0
for n in list:
semi_result = (n - mean) ** 2
result = result + semi_result
result = math.sqrt(result)
return result
def main():
numbers = [3, 2, 4, 5, 1]
sc = Shortcuts
result = sc.sort(numbers)
print(result)
if __name__ == "__main__":
# execute only if run as a script
import math
main()
# change