Lab

Dec 6th, 2021 (edited)
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import matplotlib.pyplot as plt
2.
3.
4. c1 = 90
5. c2 = 12
6.
7. arr = [0.02, 0.09, 0.15, 0.25, 0.30, 0.32, 0.36, 0.45, 0.50, 0.54, 0.58, 0.60]
8. sum_pt = [0]
9.
10. for i in range(len(arr)):
11.     sum_pt.append(sum_pt[-1] + arr[i])
12. print(sum_pt)
13.
14. carr = []
15.
16. # "{:.2f}".format(a_float)
17. for i in range(len(arr)):
18.     value = (sum_pt[i] * c1 + c2) * 100. / (i + 1.)
19.     carr.append(value)
20. for i in range(len(arr)):
21.     sum_i_pt = "{:5.2f}".format(sum_pt[i])
22.     arr_i = "{:5.2f}".format(arr[i])
23.     carr_i_fmt = "{:5.2f}".format(carr[i])
24.     index = "{:2d}".format(i + 1)
25.
26.     print(f"T = {index}, P(t) = {arr_i}, Sum(P(t)) = {sum_i_pt}, C(T) = {carr_i_fmt}")
27.
28. index_arr = []
29. for i in range(len(arr)):
30.     index_arr.append(i + 1)
31.
32. plt.plot(index_arr, carr)
33.
34. plt.xlabel("Months")
35. plt.ylabel("Costs")
36.
37. plt.show()
RAW Paste Data