Short Quiz 6 – Loops part 2 Welcome to your Short Quiz 6 – Loops part 2 1. What is the purpose of a while loop in Python? To define a function To perform mathematical operations To iterate over a sequence of elements To repeatedly execute a block of code as long as a condition is true 2. How does the condition in a while loop differ from that in an if statement? They are identical The while loop condition must include an else statement The while loop condition must evaluate to a boolean value The while loop condition is evaluated repeatedly 3. What does the following Python code snippet do? count = 0while count < 5: print(count, end=" ") count += 1 Prints numbers from 0 to 4 Prints numbers from 0 to 5 Creates an infinite loop Prints nothing 4. How can you use the break statement in a while loop? To skip the current iteration and continue with the next one To terminate the loop prematurely To create conditional branches within the loop To skip a specific number of iterations 5. What will be the output of the following Python code snippet? x = 0while x < 3: print(x, end=" ") x += 1else: print("Done") 0 1 2 Done Done 0 1 2 3 Done 6. What does the while True expression represent in a while loop? A loop that runs indefinitely A loop that runs for a fixed number of iterations A loop that runs until a specific condition is met A loop that does not run at all 7. What will be the value of result after executing the following Python code snippet? result = 0while result < 10: result += 2 0 8 10 12 8. How many times the following code will run i = 1while i < 10 print(i, end = ' ') i = i - 1 10 11 9 infinite 9. What will be the output of the following Python code snippet? n = 1while True: if n % 3 == 0 : print(n, end = ' ') if n % 9 == 0 : break n += 1 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 3 6 9 3 6 10. What will be the output of the following Python code snippet? n = 1while True: n += 1 if n % 3 == 0 : continue if n % 8 == 0 : break print(n, end = ' ') 1 2 3 4 5 6 7 8 2 4 5 7 2 3 4 5 6 7 2 4 5 7 8 1 out of 10