nerdexam
Cisco

350-901 · Question #24

Refer to the exhibit. Python threading allows a developer to have different parts of a program run concurrently and simplify a design. Drag and drop the code snippets from the left onto the item…

This question tests knowledge of Python's threading module syntax, specifically the correct sequence and code snippets required to instantiate and run a thread object using the threading.Thread class.

Software Development and Design

Question

Refer to the exhibit. Python threading allows a developer to have different parts of a program run concurrently and simplify a design. Drag and drop the code snippets from the left onto the item numbers on the right that match the missing sections in the exhibit to create a thread instance.

Explanation

This question tests knowledge of Python's threading module syntax, specifically the correct sequence and code snippets required to instantiate and run a thread object using the threading.Thread class.

Approach. To create a thread instance in Python, you must: (1) import the threading module with 'import threading', (2) define the callable target function that the thread will execute, (3) instantiate the thread with 't = threading.Thread(target=function_name, args=(...))', and (4) start execution with 't.start()' and optionally block until completion with 't.join()'. The Thread constructor's 'target' parameter accepts a callable, and 'args' or 'kwargs' pass arguments to it. Each numbered blank in the exhibit maps to one of these sequential steps - the drag-and-drop task is matching the correct snippet (e.g., 'threading.Thread(target=...)' vs 't.start()') to the correct position in the code skeleton.

Concept tested. Python threading module - correct syntax for creating, configuring, and launching a Thread instance using threading.Thread(target=...), .start(), and .join()

Reference. Python 3 docs: threading.Thread class - https://docs.python.org/3/library/threading.html#threading.Thread

Topics

#Python threading#Concurrency#Software development#Python programming

Community Discussion

No community discussion yet for this question.

Full 350-901 Practice