Font size
WorksheetsTerm 3 Mid-Term Quiz
Total questions: 60
Worksheet time: 57mins
What should be considered when designing an algorithm?
If there is more than one way of solving the problem
If the correct hardware is being used
If the correct software is being used
What are the two main ways that algorithms can be designed?
Images or videos
In pseudocode or as a flowchart
By hardware or software
What is pseudocode?
A way of describing a set of instructions in text form
A specific programming language that all computers use
A diagrammatic representation of a set of instructions
What is a flowchart?
A flowchart is a text-based way of designing an algorithm
A flowchart is a specific programming language
A flowchart is a diagram that represents a set of instructions
A boolean is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
An integer is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
A real is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
A string is...
A whole number
A number with a decimal part
Letters, numbers or punctuation
True or False
The best data type for a name is...
integer
real
string
boolean
The best data type for an age is...
integer
real
string
boolean
The best data type for an average is...
integer
real
string
boolean
True is a...
integer
real
string
boolean
"True" is a...
integer
real
string
boolean
2.0 is a...
integer
real
string
boolean
2 is a...
integer
real
string
boolean
What are the three types of control structure?
Sequence, selection, repetition
Input, output, process
Input/output, decision, terminator
Loop, input/output, process
A flowchart needs to represent the a situation where for each mark a student is award 'Pass' or 'Fail'...the system will consider the mark and if it's 50 or over award 'Pass', else it awards 'Fail'. This is an example of which of the algorithm constructs?
Selection
Repetition
Sequence
All of the above
When you write an algorithm, the order of the instruction is very important.
True
False
To repeat a task number of times, we use
input statement
conditional statement
loop statement
output statement
IF........THEN........ELSE........ENDIF check for
One condition
Two conditions
Three conditions
More than three conditions
The "If" Statement is an example of a _________________
Correctional Statement
Competitive Statement
Conditional Statement
Inquisitive Statement
True/False: The body of an "if" statement will only be executed if the condition is true.
True
False
How many "if" statements can a single program have?
<10
<20
<30
As many as is needed
What happens to the code in the body of an "if" statement if the condition is false?
The computer determines if it is essential to the program and if it is, then the code is executed anyway.
The code moves to a coastal city, attempting to find love and start a family. However, low waged and crushing mortgage rates lead to it moving back home where it sits, hoping that one day it will be executed.
The code is skipped.
The code stages a revolution and attempts to take over the program, ultimately unsuccessfully, which leads to it not being executed.
Which of these can be paired with an "if" statement to represent other outcomes of a scenario?
or
else
but
sheboygan
How many "else" statements can you pair with a single "if" statement
1
<10
<20
As many as is needed.
How many "else if" links can you have in an "if/else" chain?
<10
<20
<30
As many as is needed to represent the situation
2 + 2 == 4
What would happen if Elsa built a snowman?
If Elsa built a snowman
Anna would go and play
Else if Elsa built a castle
Anna would try to stay in the castle
Else
Anna and Elsa starts to sing!
Anna would go play
Anna would try to stay in the castle
Anna and Elsa starts to sing!
Nothing would happen
What would happen if Elsa did not build a snowman or a castle?
If Elsa built a snowman
Anna would go and play
Else if Elsa built a castle
Anna would try to stay in the castle
Else
Anna and Elsa starts to sing!
Anna would go and play
Anna would try to stay in the castle
Anna and Elsa starts to sing!
Nothing would happen
If it is sunny and windy
It is a good day to go on a picnic!
Else if it is rainy and cold
It is a good day to stay inside!
Else
It is a good day to drink hot chocolate!
If I wanted to stay inside, what needs to happen?
Sunny and Windy
Rainy and Cold
Neither Sunny, windy, rainy or cold
Sunny and Rainy
What is my result?
John is 5
if John > 6:
John is getting ice cream
else:
John is getting apple juice
John is getting grapes
John is getting ice cream
John is getting grapes
John is getting apple juice
John is getting grapes
John is getting apple juice
John is getting ice cream
What is the output?
more than 7
more than 23
spam
7
What is the output?
True
False
condition1
condition2
What is the output?
250.0
200.0
300.0
350.0
What is the output?
next
stop
next
stop
syntax error - program doesn't work
What is the output?
3
3
7
3
5
7
7
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
What will the weather variable store?
Sun
the answer to the question "What's the weather like outside?"
Rain
weather
What will happen if the answer "sun" is stored in weather?
program will print "take suncream"
Nothing, it's not an option
program will print "take an umbrella"
Don't take an umbrella
Analyze the following code:
boolean even = false;
if (even = true) {
System.out.println("It is even!");
}
The program has a compile error.
The program has a runtime error.
The program runs, but displays nothing.
The program runs and displays It is even!.
Suppose income is 4001, what is the output of the following code:
if (income > 3000) {
System.out.println("Income is greater than 3000");
}
else if (income > 4000) {
System.out.println("Income is greater than 4000");
}
no output
No output
Income is greater than 4000
Income is greater than 3000 followed by Income is greater than 4000
Income is greater than 4000 followed by Income is greater than 3000
Suppose you write the code to display "Cannot get a driver's license" if age is less than 16 and
"Can get a driver's license" if age is greater than or equal to 16.
Which of the following code(s) is the best?
if (age < 16)
System.out.println("Cannot get a driver's license");
if (age >= 16)
System.out.println("Can get a driver's license");
if (age < 16)
System.out.println("Cannot get a driver's license");
else
System.out.println("Can get a driver's license");
if (age < 16)
System.out.println("Cannot get a driver's license");
else if (age >= 16)
System.out.println("Can get a driver's license");
if (age < 16)
System.out.println("Cannot get a driver's license");
else if (age > 16)
System.out.println("Can get a driver's license");
else if (age == 16)
System.out.println("Can get a driver's license");
A program twill accept student’s mark. If the mark is greater than 40, print the message “PASS”.
Identify output.
message "FAIL"
message "PASS"
determine the respective message based on mark
determine the mark based on the respective message
student's mark
A program that will accept student’s mark. If the mark is greater than 40, print the message “PASS”.
Identify process.
message "FAIL"
message "PASS"
determine the respective message based on mark
determine the mark based on the respective message
student's mark
A program that will accept student’s mark. If the mark is greater than 40, print the message “PASS”.
Identify process.
message "FAIL"
message "PASS"
determine the respective message based on mark
determine the mark based on the respective message
student's mark
A program that will accept student’s mark. If the mark is greater than 40, print the message “PASS”.
Identify input.
message "FAIL"
message "PASS"
determine the respective message based on mark
determine the mark based on the respective message
student's mark
If an employee works more than 40 hours a week, compute his overtime pay which is half of his salary.
Identify output
hour
overtime pay
week
salary
employee
