nerdexam
Cisco

300-435 · Question #98

Refer to the exhibit. The Python script fails. Which change enables the script to complete successfully?

The correct answer is B. Store set_interfaces() return value in interfaces var.. For the Python script to successfully use the output of set_interfaces(), its return value must be explicitly stored in the interfaces variable for subsequent operations.

Network Automation Foundation

Question

Refer to the exhibit. The Python script fails. Which change enables the script to complete successfully?

Exhibit

300-435 question #98 exhibit

Options

  • AThe interface object must be defined in the set_interfaces function.
  • BStore set_interfaces() return value in interfaces var.
  • CAn iterable object type must be used for the interfaces object.
  • DThe interfaces object must be defined in the main function.

How the community answered

(39 responses)
  • A
    5% (2)
  • B
    90% (35)
  • C
    3% (1)
  • D
    3% (1)

Why each option

For the Python script to successfully use the output of `set_interfaces()`, its return value must be explicitly stored in the `interfaces` variable for subsequent operations.

AThe interface object must be defined in the set_interfaces function.

Defining the 'interface' object within 'set_interfaces' is the responsibility of that function, but the problem is likely about passing or receiving its output, not its internal definition.

BStore set_interfaces() return value in interfaces var.Correct

The script likely fails because the 'set_interfaces()' function, which presumably generates or retrieves the 'interfaces' data, returns a value that is not assigned to the 'interfaces' variable. Without this assignment (e.g., 'interfaces = set_interfaces()'), the 'interfaces' variable remains undefined or holds an incorrect value for further processing, leading to script failure.

CAn iterable object type must be used for the interfaces object.

While 'interfaces' might need to be iterable for some operations, the fundamental issue is getting the data into the 'interfaces' variable in the first place, regardless of its type.

DThe interfaces object must be defined in the main function.

The 'interfaces' object doesn't necessarily have to be defined in the main function; it could be passed as an argument or defined in a higher scope, but the immediate problem is usually the uncaptured return value.

Concept tested: Python function return values and variable assignment

Source: https://docs.python.org/3/tutorial/controlflow.html#defining-functions

Topics

#Python Functions#Return Values#Variable Assignment

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice