DP-100 · Question #301
You have a Jupyter Notebook that contains Python code that is used to train a model. You must create a Python script for the production deployment. The solution must minimize code maintenance. Which t
The correct answer is A. Refactor the Jupyter Notebook code into functions C. Define a main() function in the Python script. The two correct actions are (A) Refactor the Jupyter Notebook code into functions and (C) Define a main() function in the Python script. Refactoring into functions organizes the logic into reusable, testable units and removes the cell-by-cell execution model of notebooks. Definin
Question
Options
- ARefactor the Jupyter Notebook code into functions
- BSave each function to a separate Python file
- CDefine a main() function in the Python script
- DRemove all comments and functions from the Python script
How the community answered
(45 responses)- A82% (37)
- B7% (3)
- D11% (5)
Explanation
The two correct actions are (A) Refactor the Jupyter Notebook code into functions and (C) Define a main() function in the Python script. Refactoring into functions organizes the logic into reusable, testable units and removes the cell-by-cell execution model of notebooks. Defining a main() function and guarding it with 'if name == "main":' is standard Python script structure, enabling the script to be run directly or imported as a module. Saving each function to a separate file (B) would fragment the code unnecessarily and increase maintenance. Removing all comments and functions (D) would produce unreadable, unmaintainable code.
Topics
Community Discussion
No community discussion yet for this question.