-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathassignment11_threads.py
More file actions
47 lines (38 loc) · 916 Bytes
/
assignment11_threads.py
File metadata and controls
47 lines (38 loc) · 916 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
41
42
43
44
45
46
47
import threading
from threading import Thread
import time
print("question no 01")
def display():
time.sleep(5)
print("hello !")
t=Thread(target=display)
t.start()
print("question no 02")
def table():
for x in range (1,11):
t.join() #only for purpose display the result in sequence
print(x)
time.sleep(1)
t1=Thread(target=table)
t1.start()
print("question no 03")
def list_element_print():
m=2
for x in l:
t1.join() #only for purpose display the result in sequence
print(x)
time.sleep(m)
m=m+2
l=[5,8,9,0,3]
t2=Thread(target=list_element_print)
t2.start()
print("question no 04")
def factorial():
t2.join() #only for purpose display the result in sequence
x=int(input("enter any no to find factorial:"))
fact=1
for a in range(1,x+1):
fact=fact*a
print(fact)
t3=Thread(target=factorial)
t3.start()