From 75a42ec54dbf721caa659ddf02c1f46fc2cb4bef Mon Sep 17 00:00:00 2001 From: mlot Date: Fri, 6 Jun 2025 13:40:57 -0400 Subject: initial commit for archiving --- misc/factoralLog.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 misc/factoralLog.py (limited to 'misc/factoralLog.py') diff --git a/misc/factoralLog.py b/misc/factoralLog.py new file mode 100644 index 0000000..c082423 --- /dev/null +++ b/misc/factoralLog.py @@ -0,0 +1,19 @@ +#!python3 + +# Chapter 10 Factoral Log + +import logging +logging.basicConfig(filename='errorLog.txt', level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s') +logging.debug('Start of Program') + +def factorial(n): + logging.debug('Start of Factorial(%s%%)' % (n)) + total = 1 + for i in range(1, n + 1): + total *= i + logging.debug('i is ' + str(i) + ', total is ' + str(total)) + logging.debug('End of Factorial(%s%%)' % (n)) + return total + +print(factorial(5)) +logging.debug('End of Program') -- cgit