WorksheetsAlgorithms
Total questions: 10
Worksheet time: 8mins
What is an algorithm?
A set of steps to accomplish something.
A set of variables.
A set of known data.
A set of anti virus code.
What is Pseudocode?
Sketch out the logical steps of a process before using a programming language.
Python sublanguage.
C++ sublanguage.
Sketch out the logical steps of a process before compiling a code.
Get egg carton from the fridge.
______________
Break egg into bowl.
Get flour bag from pantry.
Take flour out of bag.
Pour flour into bowl.
What is missing from this pseudocode?
Take egg out of carton.
Put egg in flour bag.
Put flour back in pantry.
Put egg carton back in fridge.
Describes a test condition.
List some instructions that should run if the test succeeds.
conditional instructions
unconditional instructions
variable instructions
input instructions
Which is a conditional instruction?
if it is dark outside:
turn on the lights
x= x - 1
x= x + 1
input("What is your favorite color")
A “while” instruction continues running until its test ______.
fails
repeats
Decrements to zero.
Increments by the value of i.
Removing which statement will make this an infinite loop?
set countdown to countdown - 1
print a black and white page
while countdown > 0:
set countdown to 3
If there are 4 people in the room, how many times does line 3 execute?
Let N=0
For each pair of people in the room
Set N= N+2
0
1
2
4
If there are 13 people in the room, how many times does line 5 execute?
Let N=0
For each pair of people in the room
Set N= N+2
If 1 person remains then
Set N= N+1
0
1
13
6
If there are 50 people in the room, which line never executes? Why?
Let N=0
For each pair of people in the room
Set N= N+2
If 1 person remains then
Set N= N+1
