Créer une activité
Jouer Froggy Jumps
1. What is the purpose of the while loop in Python?
A
To repeatedly execute a block of code as long as a certain condition is true
B
To skip the execution of a block of code
C
To execute a block of code a specific number of times
2. Which keyword is used to define a while loop in Python?
A
for
B
while
C
do
3. What happens if the condition of a while loop is initially false?
A
The code inside the loop is executed once
B
The code inside the loop is never executed
C
The code inside the loop is executed indefinitely
4. How can you exit a while loop before its condition becomes false?
A
By using the break statement
B
By using the continue statement
C
By using the pass statement
5. What is the purpose of the continue statement in a while loop?
A
To skip the rest of the code inside the loop and start the next iteration
B
To exit the loop immediately
C
To repeat the code inside the loop indefinitely
6. What is an infinite loop?
A
A loop that executes a specific number of times
B
A loop that keeps executing without ever terminating
C
A loop that executes a block of code only once
7. What is the purpose of the else statement in a while loop?
A
To specify a block of code to be executed when the loop condition is true
B
To specify a block of code to be executed when the loop condition becomes false
C
To specify a block of code to be executed before each iteration
8. What is the difference between a while loop and a for loop?
A
A while loop can only iterate over a sequence, while a for loop can iterate over any iterable object
B
A while loop can only execute a block of code once, while a for loop can execute it multiple times
C
A while loop can continue indefinitely, while a for loop has a predetermined number of iterations
9. What is the purpose of the pass statement in a while loop?
A
To exit the loop immediately
B
To skip the rest of the code inside the loop and start the next iteration
C
To do nothing and act as a placeholder
10. What is the output of the following code? i = 0 while i < 5: print(i) i += 1
A
0 1 2 3 4
B
0
C
1 2 3 4 5