Skip to content

Commit ac5ba6e

Browse files
author
Ishaq Khan
committed
completed the debugging module
1 parent 8f5e4f1 commit ac5ba6e

File tree

5 files changed

+49
-8
lines changed

5 files changed

+49
-8
lines changed

Diff for: factorial.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import logging #logging module
2-
logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s - %(levelname)s - %(message)s')
2+
logging.disable(logging.CRITICAL) #diables the logging
3+
logging.basicConfig(level=logging.DEBUG, force=True, format='%(asctime)s - %(levelname)s - %(message)s')
34
logging.debug('Start of debugger')
45

56
def factorial(n):
7+
logging.debug('this is the start of te function %s' % (n))
68
total = 1
79
for i in range(1, n+ 1):
810
total *= i
9-
return total
11+
#logging.debug('the total %s and the value of n %s'% (total, n))
12+
return total
1013
factorial(10)
1114

12-
print('hello')
15+
16+
print('hello')
17+
18+
19+

Diff for: headsCoin.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import random
2+
3+
heads = 0
4+
for i in range(1, 1001):
5+
if random.randint(0,1) == 1:
6+
heads = heads + 1
7+
if i == 500:
8+
print('hello')
9+
10+
11+
print('heads came up' + str(heads))

Diff for: logThis.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import logging #logging module
2+
3+
logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s - %(levelname)s - %(message)s')
4+
5+
6+
#logging levels
7+
logging.debug()
8+
loging.info()
9+
logging.warning()
10+
logging.error()
11+
logging.critical() #highest level
12+
13+
#write to a text file
14+
logging.basicConfig(filename='logThiserror.txt', level=logging.DEBUG, format = '%(asctime)s - %(levelname)s - %(message)s')
15+
#added filename parameter
16+

Diff for: logging.py

-5
This file was deleted.

Diff for: testingOutDebugger.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
print('first')
3+
hello = 3000
4+
first = input()
5+
print('second')
6+
second = input()
7+
print('third')
8+
third = input()
9+
10+
total = (int(first) + int(second) + int(third))
11+
print(total)
12+

0 commit comments

Comments
 (0)