350-401 practice question 26 of 35
A script contains the statement •white loop != 999 ’ Which value terminates the loop?
Full set: 358 questionsDomain Automation
A while loop continues to execute as long as its conditional expression evaluates to true. In this case, the condition is loop != 999, which translates to "the value of the variable loop is not equal to 999". The loop will only terminate when this condition becomes false. The condition loop != 999 evaluates to false only when the value of loop is exactly 999. Therefore, a value of 999 assigned to the loop variable will terminate the loop.
B. A value not equal to 999: Any value not equal to 999 will cause the condition loop != 999 to evaluate to true, making the loop continue, not terminate.
C. A value greater than or equal to 999: While the value 999 would terminate the loop, any value greater than 999 (e.g., 1000) would satisfy the condition 1000 != 999, causing the loop to continue.
D. A value less than or equal to 999: While the value 999 would terminate the loop, any value less than 999 (e.g., 0) would satisfy the condition 0 != 999, causing the loop to continue. ---
1. Python Software Foundation. (2024). The Python Tutorial
Section 4.2. while Statements. Python 3.12.3 Documentation. Retrieved from https://docs.python.org/3/tutorial/controlflow.html#while-statements.
Specific Citation: The documentation states
"The while statement is used for repeated execution as long as an expression is true." This confirms the loop's behavior is tied to the truthiness of the condition.
2. Python Software Foundation. (2024). The Python Language Reference
Section 6.10. Comparisons. Python 3.12.3 Documentation. Retrieved from https://docs.python.org/3/reference/expressions.html#comparisons.
Specific Citation: This section defines the != operator as "not equal to". The loop while loop != 999 thus continues as long as loop is not equal to 999
and stops when it is equal.
3. Guttag
J. V. (2016). Lecture 2: Branching
Conditionals
and Iteration. MIT OpenCourseWare
6.0001 Introduction to Computer Science and Programming in Python
Fall 2016.
Specific Citation: The lecture notes on iteration explain that a while loop's body is executed repeatedly as long as the evaluates to True. When the condition becomes False
the program proceeds to the first statement after the loop body.
4. Cisco DevNet. (n.d.). Python Fundamentals for Network Engineers
Module 2: Python Language Basics
Section: "While Loops".
Specific Citation: This learning module explains
"A while loop statement in Python programming language repeatedly executes a target statement as long as a given condition is true." This directly supports the logic that the loop terminates when the condition is false.
Keep practicing
Take the free 350-401 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 350-401 practice questions
- Question 2What is a characteristic of a virtual machine?
- Question 3Which consideration must be made when using BFD in a network design?
- Question 7Which design principle states that a user has no access by default to any resource, and u…
- Question 10Which protocol does Cisco SD-WAN uso to protect control plane communication?
- Question 12What is used by vManage to interact withCiscoSD-WAN devices in the fabric?
- Question 13Which tool functions in a push model, supports languages like Python or Ruby, and does no…
