Computer Science
What are the four elements of a while loop in Python?
Python Control Flow
30 Likes
Answer
The four elements of a while loop in Python are:
- Initialization Expressions — It initializes the loop control variable and it is given outside the while loop before the beginning of the loop.
- Test Expression — If its truth value is true then the loop-body gets executed otherwise not.
- The Body of the Loop — It is the set of statements that are executed repeatedly in loop.
- Update Expressions — It updates the value of loop control variable and it is given inside the while loop.
Answered By
16 Likes