
Answer-first summary for fast verification
Answer: Refactor the Jupyter Notebook code into functions, Define a main() function in the Python script
The question requires converting Jupyter Notebook code to a production Python script while minimizing code maintenance. Option A (Refactor the Jupyter Notebook code into functions) is correct because it modularizes the code, making it reusable, testable, and easier to maintain. Option C (Define a main() function in the Python script) is correct as it provides a clear entry point for execution, ensuring the script runs predictably in production environments. Option B (Save each function to a separate Python file) is excessive for minimizing maintenance and could complicate deployment. Option D (Remove all comments and functions) is counterproductive, as it reduces code readability and maintainability. The community consensus (100% for AC) and Microsoft's official guidance support this approach for converting ML experiments to production.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You have a Jupyter Notebook containing Python code for model training. You need to create a production deployment script while minimizing code maintenance.
Which two actions should you perform? Each correct answer presents part of the solution. NOTE: Each correct selection is worth one point.
A
Refactor the Jupyter Notebook code into functions
B
Save each function to a separate Python file
C
Define a main() function in the Python script
D
Remove all comments and functions from the Python script
No comments yet.