The use of the three basic programming constructs used to control the flow of a program: Sequence; Selection; Iteration (count- and condition-controlled loops).
Track each student's skills and progress in your Mastery dashboards
Give this quiz to my class
Q 1/35
Score 0
What is the primary purpose of a while loop in programming?
30
To create a permanent loop without condition
To execute code only once
To execute a block of code as long as a specified condition is true
To execute code in reverse order
Q 2/35
Score 0
In a while loop, what will happen if the condition is initially false?
30
The loop will run indefinitely
An error will occur immediately
The code will execute once
The code inside the loop will not execute at all
35 questions
Q.
What is the primary purpose of a while loop in programming?
1
30 sec
Q.
In a while loop, what will happen if the condition is initially false?
2
30 sec
Q.
What is a common way to prevent an infinite loop in a while loop?
3
30 sec
Q.
Which of the following best describes a scenario where a while loop would be appropriate to use?
4
30 sec
Q.
What happens if the condition in a while loop is never updated inside the loop?
5
30 sec
Q.
What must be included in a while loop to ensure it eventually stops executing?
6
30 sec
Q.
What will happen if you forget to include the closing brace '}' in a while loop?
7
30 sec
Q.
What is the purpose of a while loop in Python?
8
30 sec
Q.
What will happen if the condition in a while loop is always true?
9
30 sec
Q.
Which of the following correctly demonstrates the use of a while loop in Python?
10
30 sec
Q.
What is a common way to prevent an infinite loop when using a while loop?
11
30 sec
Q.
Which statement correctly describes the use of the 'break' keyword in a while loop?
12
30 sec
Q.
In the context of a while loop, what does 'iteration' refer to?
13
30 sec
Q.
What is the output of the following code? x = 0; while x < 3: print(x); x += 1
14
30 sec
Q.
How can you stop a while loop based on user input in Python?
15
30 sec
Q.
What will be the result of the following code? count = 0; while count < 5: print(count); count += 2
16
30 sec
Q.
What is the purpose of using a flag variable in a while loop?
17
30 sec
Q.
Consider the following pseudocode. What will be the value of 'total' after executing this code? total = 0; for i from 1 to 5 do total = total + i; end for. Fill in the trace table to find the final value of 'total'.
18
30 sec
2.1.2e
Q.
Given the following pseudocode, what will be the final value of the variable 'count'? count = 0; for i from 1 to 4 do if i mod 2 == 0 then count = count + 1; end if; end for.
19
30 sec
2.1.2e
Q.
In the following pseudocode, what is the value of the variable 'output' after execution? output = 1; for x from 2 to 4 do output = output * x; end for.
20
30 sec
2.1.2e
Q.
Examine the following pseudocode. What will be the value of 'sum' at the end of execution? sum = 0; for n from 3 to 6 do if n mod 2 != 0 then sum = sum + n; end if; end for.
21
30 sec
2.1.2e
Q.
Consider this pseudocode. What will be the final value of the variable 'difference'? difference = 10; for y from 1 to 3 do difference = difference - y; end for.
22
30 sec
2.1.2e
Q.
Look at the following pseudocode. What is the final value of the variable 'result'? result = 1; for k from 1 to 3 do result = result + k * 2; end for.
23
30 sec
2.1.2e
Q.
Examine this pseudocode. What will be the value of 'product' at the end of execution? product = 1; for i from 1 to 4 do product = product * (i + 1); end for.
24
30 sec
2.1.2e
Q.
Analyze the pseudocode given below. What value does the variable 'counter' hold at the conclusion of the loop? counter = 0; for j from 1 to 5 do if j mod 2 == 1 then counter = counter + j; end if; end for.
25
30 sec
2.1.2e
Q.
Given the pseudocode below, what will be the final value of the variable 'accumulator'? accumulator = 0; for m from 1 to 5 do accumulator = accumulator + m * m; end for.
26
30 sec
2.1.2e
Q.
Consider this pseudocode: sum = 0; for x from 1 to 4 do if x mod 2 == 0 then sum = sum + x ^ 2; end if; end for. What will be the final value of 'sum' after executing the pseudocode?
27
30 sec
2.1.2e
Q.
What is the purpose of iteration in programming?
28
30 sec
2.2.1b
Q.
Which of the following describes the use of selection in programming?
29
30 sec
2.2.1b
Q.
In programming, what is the main purpose of using a 'for loop'?
30
30 sec
2.2.1b
Q.
What does the term 'sequence' refer to in programming?
31
30 sec
2.2.1b
Q.
What does a 'while loop' do in programming?
32
30 sec
2.2.1b
Q.
Which statement best describes condition-controlled iteration?
33
30 sec
2.2.1b
Q.
What is a common use of an 'if statement' in programming?
34
30 sec
2.2.1b
Q.
What type of loop would you use if you need to repeat actions until a specific condition changes?