nerdexam
Cisco

350-901 · Question #22

Refer to the exhibit. Drag and drop the code snippets from the left onto the item numbers on the right that match the missing sections in the exhibit to complete the script to implement control…

The task requires completing the Python control flow statement (if/elif/else) by dragging and dropping the correct code snippets into <missing 1> and <missing 2>. The standard Python syntax for this structure would be if ...: elif ...: else:. Therefore, <missing 1> should be…

Software Development and Design

Question

Refer to the exhibit. Drag and drop the code snippets from the left onto the item numbers on the right that match the missing sections in the exhibit to complete the script to implement control flow. Code context (from original source):
# ... previous code for Meraki API interaction ...
for route in routes:
 print("Adding static: " + str(route['subnet']))
 response = requests.post(posturl, json=route, headers=headers)

 if response == 201:
 print("Done!")
 <missing 1> response == 601:
 print("Failed to add static: " + str(route['subnet']) + "\n" + response.text)
 <missing 2>:
 print("Failed to add static: " + str(route['subnet']) + "\n" + response.text)
Available code snippets for drag and drop:
  • if response == 601
  • else:
  • when
  • if response == 201
  • elif

Exhibit

350-901 question #22 exhibit

Explanation

The task requires completing the Python control flow statement (if/elif/else) by dragging and dropping the correct code snippets into <missing 1> and <missing 2>. The standard Python syntax for this structure would be if ...: elif ...: else:. Therefore, <missing 1> should be 'elif' and <missing 2> should be 'else:'. The other options (if response == 601, when, if response == 201) are distractors or parts of the condition itself. The complete solution would look like:

    if response == 201:
        print("Done!")
    elif response == 601:
        print("Failed to add static: " + str(route['subnet']) + "\n" + response.text)
    else:
        print("Failed to add static: " + str(route['subnet']) + "\n" + response.text)

Topics

#Python#Control Flow#Conditional Logic#API Responses

Community Discussion

No community discussion yet for this question.

Full 350-901 Practice