August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 5 | Send It to the Printer |
| 1: | from threading import Thread |
| - | from time import sleep |
| - | |
| - | |
| 5: | def printer(): |
| - | for i in range(3): |
| - | print(i, end=' ') |
| - | sleep(0.1) |
| - | |
| 10: | |
| - | thr = Thread(target=printer, daemon=True) |
| - | thr.start() |
| - | print() # Add newline |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: 0
Output | |
|---|---|
|
Due to the unpredictable nature of threads, ... | |
Read now
Unlock full access