Sum Range of Values

Write a program sum_range_of_values.py that has a sum_values(n) function that adds up the integers from 1 to n and returns that value.

The main function runs through a series of tests of that function, with increasingly large values of n. The time it takes for each of those additions to occur is calculated and printed out.

Sample Output

1000000 0.05031180381774902
2000000 0.08939003944396973
3000000 0.13520097732543945
4000000 0.17220711708068848
5000000 0.2138979434967041
6000000 0.2843031883239746
7000000 0.315230131149292
8000000 0.35974669456481934
9000000,0.3881549835205078

Extension

Take the values that were printed in the program above and instead write them to an external "comma-separated value" (CSV) file. The results of that file form a record of the program's work, and can be imported into a spreadsheet program and analyzed with a trend line.

Sample Output

Number of Values Summed,Execution Time
1000000,0.05031180381774902
2000000,0.08939003944396973
3000000,0.13520097732543945
4000000,0.17220711708068848
5000000,0.2138979434967041
6000000,0.2843031883239746
7000000,0.315230131149292
8000000,0.35974669456481934
9000000 0.3881549835205078
Results written out to result.csv