-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
105 lines (95 loc) · 3.08 KB
/
main.py
File metadata and controls
105 lines (95 loc) · 3.08 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
class PERT:
def __init__(self):
self.lol = []
self.r = 0
self.p = 0
self.o = 0
self.total_r = 0
self.total_p = 0
self.total_o = 0
self.total_mean = 0
self.total_std_dev = 0
self.weeks = []
def brain(self):
x = input("Press [enter] to make a calculation, 'y' to push calculation, or 'n' to exit ")
if x == 'n':
print(self.lol)
return "Exiting program..."
elif x == '':
ans = input("Enter durations [O R P]... ")
try:
fix = [int(i) for i in ans.split(' ')]
except ValueError:
fix = [float(i) for i in ans.split(' ')]
self.lol.append(fix)
self.brain()
elif x == 'y':
self.hours_to_weeks()
self.calculation()
return
else:
print("Invalid input, press [enter] or 'n'")
self.brain()
def hours_to_weeks(self):
week_o = 0
week_p = 0
week_r = 0
week_mean = 0
std_dev = 0
self.weeks = [[x / 8 for x in i] for i in self.lol]
for i in self.weeks:
mean = (i[0] + 4 * i[1] + i[2]) / 6
std_dev = (i[2] - i[0]) / 6
i.append(round(mean, 2))
i.append(round(std_dev, 4))
print("\n============================\n")
print("Duration Estimate (in weeks)")
print("\n-------\n")
print("data:")
for i in self.weeks:
print("\t", i)
week_o += i[0]
week_r += i[1]
week_p += i[2]
week_mean += i[3]
std_dev += i[4]
print("\n-------\n")
print(f"Mean: {week_mean}")
print(f"Standard deviation: {round(std_dev)}")
print(f"Total optimistic: {week_o}")
print(f"Total realistic: {week_r}")
print(f"Total pessimistic: {week_p}")
print("\n==============\n")
def calculation(self):
for i in self.lol:
self.o = i[0]
self.r = i[1]
self.p = i[2]
mean = (self.o + 4 * self.r + self.p) / 6
std_dev = (self.p - self.o) / 6
i.append(round(mean, 2))
i.append(round(std_dev, 4))
for i in self.lol:
self.total_mean += i[3]
self.total_std_dev += i[4]
self.total_o += i[0]
self.total_r += i[1]
self.total_p += i[2]
print("Cost Estimate (in units)")
print("\n-------\n")
print("data:")
for i in self.lol:
print("\t", i)
print("\n-------\n")
print(f"Total PERT estimate (mean): {round(self.total_mean, 2)}")
print(f"Total deviation: {self.total_std_dev}")
print(f"Total optimistic: {self.total_o}")
print(f"Total realistic: {self.total_r}")
print(f"Total pessimistic: {round(self.total_p)}")
print("\n============================\n")
print("we are done here...bye")
def main():
calc = PERT()
calc.brain()
if __name__ == '__main__':
main()