← Quiz: Threads and Context Switching: all 10 questions
Quiz: Threads and Context Switching · Question 8 of 10
What does this print? (code)
What does this print?
import threading
data = []
t = threading.Thread(target=lambda: data.append(1))
t.start()
t.join()
print(len(data))
- A.0
- B.1
- C.2
- D.Error
Answer & explanation
Correct answer: 1
The thread appended to the same list that the main thread then printed.
Can you get the rest right without peeking?
Take the timed Quiz: Threads and Context Switching quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →