-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalcProd.py
More file actions
41 lines (24 loc) · 831 Bytes
/
calcProd.py
File metadata and controls
41 lines (24 loc) · 831 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import logging, time
#calcProd.py Calculating Time
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')
logging.debug('Start of program')
def calcProd():
# Calculate the product of the first 100,000 numbers.
product = 1
for i in range(1, 100000):
product = product * i
return product
def callCalcProd():
startTime = time.time()
logging.debug('The start time is ' + str(startTime))
prod = calcProd()
endTime = time.time()
logging.debug('The end time is ' + str(endTime))
print('The result is %s digits long.' % (len(str(prod))))
print('Took %s seconds to calculate.' % (endTime - startTime))
def main():
callCalcProd()
logging.debug('End of program')
if __name__ == '__main__':
main()