You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
8. Add the synchronization code in the program below, in order to ensure the thread is ready before execution continues in "main" (hint: add a "wait_ready" method to the A class and call it in "main").
importthreadingimporttimeclassA(threading.Thread):
def__init__(self, sleep_time):
super().__init__()
self.sleep_time=sleep_timedefrun(self):
print("Not ready yet")
time.sleep(0.1)
print("I am ready !")
time.sleep(self.sleep_time)
defmain():
a_thread=A(3)
a_thread.start()
print("Add the code, for this line to be always printed *after* 'I am ready !'")
a_thread.join()
main()
9. Write the Python code for a simulation Shutter class. A Shutter is a device that can open (beam passes through) or close (beam is stopped). Do not forget about the state.
10. In Object-Oriented Programming, what are the concepts of inheritance and composition ?
11. Given an array a = [[1,2,3],[3,4,5],[23,45,1]] ; using NumPy, find the sum of every row in array a.
12. Read the following file into a NumPy array (replace absent values with 0):
1, 2, 3, 4, 5
6, , , 7, 8
, , 9, 10,11
13. Explain what "serialization" means, and what it is used for ?