-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiThreading2.py
More file actions
40 lines (28 loc) · 1023 Bytes
/
Copy pathMultiThreading2.py
File metadata and controls
40 lines (28 loc) · 1023 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
# A python application which creates two thread named as evenfactor and oddFactor
# Evenfactor thread will display Addition of even factor of given number and
# Oddfactor thread will display Addition of Odd factor of given number
import threading
def EvenFactor(No):
Sum = 0
for i in range(2,No,2):
if(No % i == 0):
Sum = Sum + i
print("Addition of Even factors is :",Sum)
def OddFactor(No):
Sum = 0
for i in range(1,No,2):
if(No % i == 0):
Sum = Sum + i
print("Addition of Odd factors is :",Sum)
def main():
print("Enter a number to find its sum of Even and Odd factor")
Number = int(input())
EvenT = threading.Thread(target= EvenFactor, args=(Number,))
OddT = threading.Thread(target= OddFactor, args=(Number,))
EvenT.start()
OddT.start()
EvenT.join()
OddT.join()
print("End of main")
if __name__ == "__main__":
main()