First, make a list containing numbers from 1 to 10000
second, add all of them
The Sample of Output:
The sum of numbers from 1 to 10000000:
50000005000000
The total running time: 0.7548158168792725
>>>
The code:
import time
def main():
start_time = time.time()
print('The sum of numbers from 1 to 10000000: ')
numbers = [value for value in range(1,10000001)]
print(sum(numbers))
end_time = time.time()
total_time = end_time - start_time
print ('The total running time:',total_time )
main()