Computer Science
What is the significance of updating loop control variable in while statements?
Python Control Flow
2 Likes
Answer
Updating the loop control variable in while statements is essential to prevent infinite loops. If the loop control variable is not updated within the loop body, the condition may always evaluate to true, causing the loop to run indefinitely.
Answered By
3 Likes
Related Questions
What are jump statements?
What is nested loop? Explain with example.
Construct a logical expression to represent each of the following conditions:
(a) Mark is greater than or equal to 100 but less than 70.
(b) Num is between 0 and 5 but not equal to 2.
(c) Answer is either 'N' OR 'n'.
(d) Age is greater than or equal to 18 and gender is male.
(e) City is either 'Kolkata' or 'Mumbai'.
Find error in the following code (if any) and correct it by rewriting the code and underline the corrections:
code=input ("Enter season code : ") if code=w: print "winter season" elif code==r: PRINT "rainy season" else: Print "summer season"