1 2 3 4 5 6 7 8 9 10 11 12 13
import time def calcProd(): product = 1 for i in range(1, 100000): product = product + 1 return product startTime = time.time() prod = calcProd() endTime = time.time() print('The result is %s digits long.' % (len(str(prod)))) print('Took %s seconds to calculate.' % (endTime - startTime))