Font size
WorksheetsComp Sci. Examination March 13th
Total questions: 50
Worksheet time: 25mins
What is the purpose of using a for loop in code?
To repeat something a fixed number of times
To do something if a condition is true
To do something while a condition is true
To make programs run faster
What is top down design?
Top down design is a way that you can create designs on a computer to put on a web page
Top down design is a way of designing your programs starting with the individual commands first
Top down design is a way to use loops and if statements to decompose the problem
Top down design is a way of designing your program by starting with the biggest problem and breaking it down into smaller and smaller pieces that are easier to solve.
Say you want to write a program to have Karel put down 300 tennis balls. Which control structure would you use?
If statement
While loop
Nested while loop
For loop
How can we teach Karel new commands?
For loop
While loop
The start function
Define a new function
Why does a programmer indent their code?
Helps show the structure of the code.
Easier for other people to understand.
A key part of good programming style!
All of the above
What condition should be used in this while loop to get Karel to pick up all the tennis balls on the current location?
**********************************************************************************************************************
while (________) {
takeBall();
}
noBallsPresent()
frontIsClear()
takeBall()
ballsPresent()
What does the mystery function do?
***********************************************************************************************************************
function mystery() {
while (noBallsPresent()) {
move();
}
}
Karel checks if there is no ball on the current spot and then moves once
Karel moves until it puts down a ball
Karel moves once if there is no ball present
Karel moves until it is on a ball
Which of the following is the correct way to define a turnRight function in Karel?
turnRight function() { turnLeft(); turnLeft(); turnLeft(); }
function turnRight { turnLeft(); turnLeft(); turnLeft(); }
function turnRight() { turnRight(); turnRight(); turnRight(); }
function turnRight() { turnLeft(); turnLeft(); turnLeft(); }
What does Binary mean?
Of 1 state
Of 3 states
Of 4 states
Of 2 states
Who is the type of algebra used to create logical statements named after?
Albert Einstein
Bill Gates
Steve Jobs
George Boole
What is the only condition that will cause an OR statement to register as false?
One part is true
Both parts are true
One part is false
Both parts are false
What is pseudocode?
A programming language used to create computer applications
A set of instructions written in a programming language
Natural language expressions that describe what you want a program to do
Why would you choose to use a "for" loop instead of a "conditional" loop?
When you want the code in the loop to repeat until a value of an input sensor changes.
When you want the code in the loop to repeat until a condition changes.
When you want the code in the loop to repeat until a button is pressed.
When you want the code in the loop to repeat a specific number of times.
A group of functions is called...
a system
a routine
a repository
a library
The part of the computer that would was called the Computer Generator. They were basically the first _____ ____.
type writer
dot matrix
display screen
graphics card
Early computers did not use pixels to display images on the a screen because they would take up to much ________.
Lines
Dots
Pixels
Memory
What were the 2 ways early computers could display images on a screen.
Line Scanning and
Pixel Scanning
Shape Scanning and
Dot Scanning
Vector Scanning and
Raster Scanning
What three coordinate directions make up 3D graphics?
a, b, c
w, x, y
h, i , j
x, y , z
Objects hidden behind other objects is called_______
conclusion
inclusion
re-shaping
occlusion
CPU’s aren’t designed for this, so they aren’t particularly fast. So, computer engineers created special processors just for graphics called ___________________
Circuit Board
Chips
Central Unit
Graphics Processing Unit
Which statement will correctly call a JavaScript function?
myFunction()
initiate myFunction()
call myFunction()
var myFunction()
Which JavaScript statement should you use to branch to one of two processes
depending on the result of a test condition?
if...else
break
for
do...while
Which JavaScript code is used to define a function?
define myFunc { return value; }
define myFunc() { }
abra kadabra () { }
function myFunc() { }
In JavaScript, which of the following items allows you to store user-entered or
developer-defined data and use it more than once?
Operator
Keyword
Concatenation
Variable
Which of the following is the correct Javascript format for a comment?
// "the text"
/"the text"/
*/"the text"/*
\\"the text
What will print to the console?
Time to buy!
Time to wait for a sale.
sale
Nothing, there is a syntax error on the fourth line
What will print to the console?
Time to buy!
Time to wait for a sale.
sale
Nothing, there is a syntax error on the fourth line
Which correctly matches the logical operator with its syntax?
and - !
or - | |
not - &&
and - &&
or - | |
not - !
and - | |
or - !
not - &&
and - &&
or - !
not - | |
For this conditional to be true....
day must be equal to Saturday and Sunday
day must be not equal to Saturday or Sunday
day must be equal to Saturday or Sunday
What is >= ?
Based on the code below what is answer equal to?
let x =20;
let y= 8;
let answer= x % y
4
2
12
28
What Javascript code matches this statement:
The score is not 0
if (score != 0)
if (score =! 0)
if (score not 0)
if (score !! 0)
Which line of code could be used to make this image.
rectangle(20, 20, 150, 100);
rect(20, 20, 20, 20)
rect(20, 20, 150, 100);
ellipse(20, 20, 150, 100);
Find the bug! Why is the rectangle not red?
The parameters in line 1 are incorrect.
The fill code should come first.
There is no background code.
There is no stroke code.
Look at the line of code. What does the number 173 represent?
the x coordinate of the circle
the width of the circle
the y coordinate of the circle
the height of the circle
Which command is used to print messages on the console in JavaScript.
print()
js.write()
console.log()
console.write()
Complete the code to type in your favorite weather:
(a) (b) = (c) ("What is your favorite type of weather?")
What is the value of x at the end of the code?
var i;
var x=0;
for(i =0; i<10; i++){
x++;
}
10
11
9
12
What type of variable is apple?
var apple = " Fuji "
string
Boolean
array
number
Which command is written incorrectly?
putBall();
putball();
turnLeft();
takeBall();
What is printed to the screen if the user enters ‘5’ when the following program is run?
var userNum = readInt("Enter your favorite number: ");
var calculatedNum = (userNum * userNum) + userNum;
println(calculatedNum);
5
25
30
50
Why do programmers use variables?
Because they are lazy and don’t want to write out equations every time
It allows the programmer to reuse multiple lines of code
They are a way to document functions
To store values to easily reuse later and make code easier to read and understand
Which code would correctly have Karel move to and pick up BOTH balls?
Which code correctly has Karel jump both Hurdles and reach the end of the 1st street to the right?
What would be the resulting world if the following code ran in the starting world shown?
You need to write a program that has Karel take all the tennis balls where Karel is standing.
Karel should end up with no tennis balls on that spot.
Which control structure do you need to use?
FOR loop
WHILE loop
IF statement
IF/ELSE statement
None of the above
