WorksheetsFor and While Loops
Total questions: 28
Worksheet time: 2hrs 20mins
Repeating a task multiple times in programming is known as ?
Iterators
Scope
Looping
When there is an error in the logic of the loop because the stopping condition is never reached.
Arrays
Infinite Loop
Looping
for loops allow us to repeat a block of code a known amount of times.
True
False
Each item inside of an array is at a numbered position, starting at ?
1
0
_____ loops let us loop a block of code a known amount of times.
while
for
As long as the condition evaluates to _____, the block of code will loops.
true
false
_____ loops let us loop a block of code an unknown amount of times.
for
while
what is a for loop?
loops through a number of block of code one time
loops through a block of code a number of times
loops through a block of code one time
many loops through a block of code a number of times
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
which is the correct code?
for (i = 0; i < 5 i++)
FOR (i = 0; i < 5; i++)
for (i = 0; i < 4; i++)
for (i = 0; i < 5; i++)
what is a while loop?
loops through a block of code as long as a specified condition is false
loops through a block of code as long as a specified condition is true or false
loops through a block of code as long as a specified condition is true
loops through a number block of code as long as a specified condition is true
What is the final sum after this loop executes
sum = 5
sum = 10
sum = 15
Which of these is a loop?
if(x<10)
for( var x=0; x<10; x++)
var x=10;
loop(x,10;10)
What is the symbol used for the INCREMENT operator in JS?
+
++
=
==
What is ++ ?
Repeat something 10 times
repeat 10
for (var i=0; i<10; i++)
repeat { } until 10;
while (i = 10)
Loops use these to eventually exit the loop
Numbers and letters
conditions with logic and comparison
class or ID
input from the keyboard
This loop starts counting from 10
for(var i=10; i>0; i--)
var i = 10;
count=10;
for(var i=0; i>0; i--)
adds one to variable x in a loop
increment (x)
x++;
x=x;
y+1;
Repeat code a fixed number of times.
While Loop
Loop
If Statement
For Loop
Why are the curly braces needed for loops?
To tell the program where the loop begins and ends
To tell the program when to stop looping
To declare a new variable
Why are the curly braces needed for loops?
To tell the program where the loop begins and ends
To tell the program when to stop looping
To declare a new variable
what is the __ missing in this loop
for ( ____ ; x<10; x++);
set a start value for x
exit the loop when x is 11
start x at zero
the loop is not missing code
Repeat something 10 times
repeat 10
for (var i=0; i<10; i++)
repeat { } until 10;
while (i = 10)
The proper way to code a loop condition
Starts TRUE and later changes to FALSE
Loop
Starts FALSE and stays FALSE
Starts FALSE and turns TRUE to exit the loop
Which of the following statements is/are correct?
Statement 1 is executed (one time) before the execution of the code block.
Statement 2 defines the condition for executing the code block.
Statement 3 is executed (every time) after the code block has been executed.
In order to create a loop that runs from 0 to 9, what would you have to fill into the empty box?
(a)
