Advertisement
mengyuxin

meng.factorialLog.py

Jan 3rd, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #! python3
  2. # factorialLog.py
  3. import logging
  4. logging.basicConfig(level=logging.DEBUG, format = ' %(asctime)s - %(levelname)s - %(message)s')
  5. logging.debug('Start of program')
  6.  
  7. def factorial(n):
  8.     logging.debug('Start of factorial(%s)' % (n))
  9.     total = 1
  10.     for i in range(1, n + 1):
  11.         total *= i
  12.         logging.debug('i is ' + str(i) + ', total is ' + str(total))
  13.     logging.debug('End of factorial(%s)' % (n))
  14.     return total
  15.    
  16. print(factorial(5))
  17. logging.debug('End of program')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement