While loops and for loops, both of which are commonly used in programming. They're a little different, so I'll tell you slowly.
The while loop goes like this: it first checks whether the condition is true, then executes the ** inside, and then checks the condition again, and so on until the condition becomes false.
As for loops, it usually consists of three parts: the settings at the beginning, the judgment conditions, and the changes after each loop. Before each start, it will set it first, then see if the condition is true, if it is true, execute **, then change it, and then check the condition, and so on until the condition becomes false.
So when are they used? For loops are often used when you know how many times you want to loop, such as traversing an array or list. The while loop, on the other hand, is more flexible and is often used when you are not sure how many times you want to loop, but you know what the conditions of the loop are, such as whether to continue the loop based on a certain condition.
Overall, both while and for loops can be used to execute ** repeatedly, but they are a bit different in terms of syntax and usage. When programming, it is necessary to choose which cycle structure to use according to the specific needs and the certainty of the number of cycles.