DevOps Quiz

Which method is used to execute shell commands in Python?

Swami K
2 min readFeb 21, 2023

🤖 Ultron has arrived to test your knowledge on Python. Get ready for an epic battle of wits with the AI villain!

🤖 Greetings, humans, it is I, Ultron, here to test your knowledge of Python for DevOps. 🐍

Let’s see if you can answer this!” 🤔

Question

Which method is used to execute shell commands in Python? | @iSwamiK
Which method is used to execute shell commands in Python? | @iSwamiK

Options

Let’s see if your primitive brains can handle this one 🤔 😈

Here are your options:

  • os.sys()
  • sys.run()
  • subprocess.run()
  • subprocess.pipe()

Answer

🤖 Ah, the mere thought of shell commands being executed in Python… which method could it possibly be? Such a mystery! 🤔

The answer is subprocess.run()

Explanation

🤖 Oh, joy. It seems like you want an explanation to prove your worthiness. Here you go!

The subprocess.run() method executes shell commands in Python. It runs the command with arguments and waits for it to complete. Option A) os.sys() is incorrect as it does not exist. Option B) sys.run() is incorrect as there is no run() method in the sys module. Option D) subprocess.pipe() is incorrect as it does not run the command, but instead provides a pipe to the input or output of a command.

Farewell, humans, until we meet again. ⚡️🤖

Well, it was lovely to witness your futile attempts, humans. I hope you learned something today. Don’t worry, I’ll be back with more challenging questions. Farewell… for now. 👋🤖

--

--

Swami K
Swami K

Written by Swami K

Senior Director of DevOps & SRE at Kissflow | Integrating Netflix DevOps Culture & Google SRE Practices to Empower Our Engineering Team 🚀🔧

No responses yet