Cyber Class 9 Python Programming

Asked by GIANSH GUPTA KHUNDKER · BIRLA BRAINIACS

To safely execute operating system commands from within a Python script without opening a vulnerable system shell, which module and practice should be used?

Answer as guest — Start Free Practice Test to earn Practice PointsHow to earn pointsAsk a question+3Answer a question+1Someone answers yours+1Your Q gets upvoted+1Pioneer bonus (first 5)+51 point = ₹1 discount on purchases, ask questions & climb the leaderboard!
Show answer and explanation

Answer: B. subprocess module with shell=False and arguments passed as a list.

Answer: B) subprocess module with shell=False and arguments passed as a list.
Explanation: The subprocess module is the modern standard for executing external processes. By setting shell=False and passing commands as an explicit list (e.g., ["ping", "-c", "1", ip]), Python interacts directly with the operating system API. This ensures user input is strictly treated as a literal argument, never as executable code.

Answering after opening this box earns no Practice Points.

70%