-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsp500.py
28 lines (20 loc) · 811 Bytes
/
sp500.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
file = open('SP500.txt','r')
lines = file.readlines()
#initialize eventual lists (mutable and iterable)
SP_500 = []
interest = []
#isolate desired date range (lines 6:18)
for line in lines[6:18]:
rows = line.strip().split(',')
SP_500.append(rows[1])
interest.append(rows[5])
# make a list called 'float values' which translates all numbers in the SP_500 list to a float
float_values = [float(value) for value in SP_500]
SP_sum = sum(float_values)
SP_count = len(float_values)
mean_SP = SP_sum / SP_count
print('The average SP 500 for the date range is: ', mean_SP)
# translate interest to a new list of floats
interest_values = [float(v) for v in interest]
max_interest = max(interest_values)
print('The max interest value for the date range is: ', max_interest)