Skip to content

Commit 445449a

Browse files
author
learnp
committed
added module directory
1 parent ffae1b9 commit 445449a

File tree

7 files changed

+78
-3
lines changed

7 files changed

+78
-3
lines changed

Debugging/conditional_breakpoint.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
expense_list = [1230 , 2240 , 1500, 1678, 2020, 1580, 2240, 1500, 1245, 2300, 1246, 3400, 1580, 2240, 1500, 3240, 2240, 1500, 1245, 2300, 1246, 3400, 1580, 2240, 2467, 1245, 2300, 1246, 3400, 1580, 2240, 1500, 3240, 2240, 1500, 1245, 2300, 1246, 3400, 1580, 2240]
1+
expense_list = [1230, 2240, 1500, 1678, 2020, 1580, 2240, 1500, 1245, 2300, 1246, 3400, 1580, 2240, 1500, 3240, 2240, 1500, 1245, 2300, 1246, 3400, 1580, 2240, 2467, 1245, 2300, 1246, 3400, 1580, 2240, 1500, 3240, 2240, 1500, 1245, 2300, 1246, 3400, 1580, 2240]
22
total_expense = 0
33
for expense in expense_list:
44
total_expense += expense
55

66
print("total expense is: ", total_expense)
7-
7+

Debugging/watches_callstack.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def foo():
2+
bar()
3+
4+
def bar():
5+
pass
6+
7+
foo()
8+
9+
10+
File renamed without changes.

Modules/urllib_demo.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from urllib.request import urlopen
2+
with urlopen('http://www.agilemanifesto.org/') as response:
3+
for line in response:
4+
line = line.decode('utf-8') # Decoding the binary data to text.
5+
print(line)

Multiprocessing/mult_threading.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import time
2+
import threading
3+
4+
def calc_square(numbers):
5+
print("calculate square numbers")
6+
for n in numbers:
7+
time.sleep(20)
8+
print('square:',n*n)
9+
10+
def calc_cube(numbers):
11+
print("calculate cube of numbers")
12+
for n in numbers:
13+
time.sleep(20)
14+
print('cube:',n*n*n)
15+
16+
arr = [2,3,8,9]
17+
18+
t = time.time()
19+
20+
t1= threading.Thread(target=calc_square, args=(arr,))
21+
t2= threading.Thread(target=calc_cube, args=(arr,))
22+
23+
t1.start()
24+
t2.start()
25+
26+
t1.join()
27+
t2.join()
28+
29+
print("done in : ",time.time()-t)
30+
print("Hah... I am done with all my work now!")

Multiprocessing/multi_proc.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import time
2+
import multiprocessing
3+
4+
def calc_square(numbers):
5+
print("calculate square numbers")
6+
for n in numbers:
7+
time.sleep(20)
8+
print('square:',n*n)
9+
10+
def calc_cube(numbers):
11+
print("calculate cube of numbers")
12+
for n in numbers:
13+
time.sleep(20)
14+
print('cube:',n*n*n)
15+
16+
if __name__ == "__main__":
17+
arr = [2,3,8,9]
18+
19+
t = time.time()
20+
21+
p1= multiprocessing.Process(target=calc_square, args=(arr,))
22+
# p2= multiprocessing.Process(target=calc_cube, args=(arr,))
23+
24+
p1.start()
25+
# p2.start()
26+
27+
p1.join()
28+
# p2.join()
29+
30+
print("done in : ",time.time()-t)
31+
print("Hah... I am done with all my work now!")

test.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ def sum(a,b):
22
return a+b
33

44
n1=input('enter first number: ')
5-
n1=int(n1)
65
n2=input('enter first number: ')
76
print('sum is: ',sum(n1,n2))

0 commit comments

Comments
 (0)