Guruh talabasi Sulaymonov Sherzodbek Inomjon o‘g‘li


Download 90.52 Kb.
Sana18.06.2023
Hajmi90.52 Kb.
#1581473
Bog'liq
7-amaliyot OT


610-20 guruh talabasi Sulaymonov Sherzodbek Inomjon o‘g‘li
7-amaliyot.
Dastur kodi:
import time
import threading
def sonning_kvadrati(numbers):
print("Sonlarning kvadratini xisoblash:")
for i in numbers:
time.sleep(0.2)
print('Natija1:', i*i)

def sonning_kubi(numbers):


print("Sonlarning kubini xisoblash:")
for i in numbers:
time.sleep(0.2)
print("Natija2:", i*i*i)

arr = [2, 3, 4, 5]


t = time.time()


t1 = threading.Thread(target=sonning_kvadrati, args=(arr,))
t2 = threading.Thread(target=sonning_kubi, args=(arr,))

t1.start()


t2.start()

t1.join()


t2.join()
#sonning_kvadrati(arr) # dasturni ketma ket bajarilish xolati
#sonning_kubi(arr) # dasturni ketma ket bajarilish xolati

print("Quidagi vaqtda bajarildi:", time.time()-t)


Dastur natijasi:






Download 90.52 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling