Robotics & Artificial Intelligence
State one similarity and one difference between while and for loops.
Python Control Flow
2 Likes
Answer
Similarity: Both for loop and while loop are used to repeat the execution of a block of statements until a particular condition is satisfied.
Difference: The for loop is a fixed iterative loop in which the number of iterations is known in advance, whereas the while loop is an unfixed iterative loop in which the user may not be aware of the exact number of iterations that will take place during execution.
Answered By
3 Likes