nerdexam
Cisco

200-901 · Question #298

Refer to the exhibit. A developer just finished testing a Python script and wants to save the list of packages and versions installed on the current machine. The developer must make sure that it…

The correct answer is B. pip freeze > requirements.txt. The correct command is pip freeze > requirements.txt. The pip freeze command outputs all installed packages and their exact versions to stdout. The > operator is the standard shell redirect that sends stdout to a file, creating or overwriting requirements.txt. Option A uses 2>…

Application Deployment and Security

Question

Refer to the exhibit. A developer just finished testing a Python script and wants to save the list of packages and versions installed on the current machine. The developer must make sure that it will not cause any issues if tested on another device due to different library versions. Which line of code needs to be placed on the snippet where the code is missing?

Exhibit

200-901 question #298 exhibit

Options

  • Apip freeze 2> requirements.txt
  • Bpip freeze > requirements.txt
  • Cpip freeze => requirements.txt
  • Dpip freeze | requirements.txt

How the community answered

(28 responses)
  • B
    93% (26)
  • C
    4% (1)
  • D
    4% (1)

Explanation

The correct command is pip freeze > requirements.txt. The pip freeze command outputs all installed packages and their exact versions to stdout. The > operator is the standard shell redirect that sends stdout to a file, creating or overwriting requirements.txt. Option A uses 2>, which redirects stderr (error output), not stdout, so the file would be empty. Option C (=>) is not a valid shell operator. Option D uses | (pipe), which passes output to another command - not to a file. Saving to requirements.txt ensures other developers can recreate the exact environment using pip install -r requirements.txt, preventing version mismatch issues.

Topics

#pip#Python dependency management#requirements.txt#Shell redirection

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice