Font size
WorksheetsJS- Animation Basics - Intro to Programming - KhanAcademy
Total questions: 100
Worksheet time: 54mins
The set of rules that must be followed when writing program instructions for a specific programming language is called:
executing
machine language.
binary.
syntax
To a computer: main and Main are exactly the same thing
TRUE
FALSE
A syntax error
is when the program is coded correctly, but an error occurs because of a problem while the program is being executed (not because of a mistake in the code)
is when incorrect words or punctuation is used, or when correct words and punctuation are used in the wrong order
is when the stars don't line up properly and a cosmic ray changes a true value to a false value
is when the program is coded incorrectly to produce an incorrect result, but with correct statements. The only way to know there was an error is to notice that the result is wrong
A logic error
is when the program is coded correctly, but an error occurs because of a problem while the program is being executed (not because of a mistake in the code)
is when incorrect words or punctuation is used, or when correct words and punctuation are used in the wrong order
is when the stars don't line up properly and a cosmic ray changes a true value to a false value
is when the program is coded incorrectly to produce an incorrect result, but with correct statements. The only way to know there was an error is to notice that the result is wrong
A named location in memory where a value can be stored is called
an operator
a variable
a keyword
a process
What type of data would either True or False be?
String
Character
Real
Boolean
Which of the following is NOT a mathematical operator?
+
=
/
&
Which of the following is a relational operator?
+
-
/
>
Which of the following is a logical operator?
IF
THEN
AND
ELSE
Which of the following is NOT a logical operator?
AND
OR
NOT
IF
In this algorithm, which of the following is a variable?
password
loop
output
while
TRUE or FALSE:
Variables cannot be changed.
True
False
TRUE or FALSE:
Variable names can include spaces.
False
True
Which of the following statements can be used to extend selection from a single IF statement?
ELSE
DO
CHOICE
FOR
Which of the following is NOT a selection statement?
FOR
IF
ELSE
ELSE IF
Which of the following is a count-controlled loop?
FOR
IF
WHILE
DEF
The variable 'x' starts at 0. It is incremented by 1, each loop.
Which of the following will run the loop exactly 10 times?
WHILE x < 10
WHILE x < 9
WHILE x < 11
WHILE x > 1
Which of these is a loop?
if(x<10)
while(x<10)
var x=10;
text(x,10;10)
Which of these will increase the value of the variable X?
increment (x)
x++;
x=x;
x+1;
Which of the following will decrease the value of x?
x--;
x-1;
x=x;
x=-x;
His name is Fred and he is less than 16 years old
if (name = "fred" && age < 16 )
if (name === "fred" && age < 16 )
if (name = "fred" || age < 16 )
if (name === "fred" || age < 16 )
Repeat something 10 times
repeat 10
for (var i=0; i<10; i++)
repeat { } until 10;
while (i = 10)
When we are done with a line what do we put at the end?
a colon :
a semi-colon ;
a period .
a quotation mark "
A short form writing the word variable is
rav
VAR
var
varia
Which message will the user see?
"Hello user"
No message
"Goodbye user"
"message + user"
How do I declare a new variable?
var newVariable = 5
Variable int = new Variable()
var 5 = myVariable
int var = 5
What surrounds an if/else statement?
Quotations " "
Curly Brackets { }
Parenthesis ( )
Square Brackets [ ]
Which one of the following is the symbol for implementing the OR operator?
**
&&
||
!
Which one of the following is the symbol for implementing the AND operator?
Lequel des symboles suivants est utilisé pour implémenter l’opérateur AND?
&&
**
||
++
Why do we use if/else statements in JavaScript?
To repeat something for a fixed number of times
To either do something if a condition is true or do something else
To break out of some block of code
To repeat something while a condition is true
What's the value of the ageCalc variable?
"19.27"
26.2
"25.7"
19.27
In JavaScript, which of the following operator symbols means not equal to?
<>
==
!=
##
A loop that executes for a pre-defined number of times
(a)
A loop that executes until a condition is met is called
(a)
Which of the below are types of loops
if then else
while loop
for loop
Nested loops are
Multiple independent loops
Conditions in a loop
Loop in a Loop
Loop in a condition
for ( var i = 0; i < 50; i++ )
How many times will this loop execute
51 times
49 times
50 times
0 times
Which of the iterations runs 25 times
for ( var i = 2; i < 26; i ++ )
for ( var i = 0; i < 25; i ++ )
for ( var i = -1 ; i > 25 ; i -- )
for ( var i = 0; i <= 25; i --)
One of the below functions lets you climb 1000 feet
for ( var count = 0; count > 999; count --)
moveUpOneFoot();
}
for ( var count = 2; count <= 1001; count ++)
moveUpOneFoot();
}
for ( var count = 1000; count < 1; count --)
moveUpOneFoot();
}
for ( var count = 0; count < 1000; count ++)
moveUpOneFoot();
}
How do you define a function in JavaScript
function = climbUp();
fun = "climbUp";
function climbUp();
fun = (climbUp());
Loops in programming start counting from ?
0
1
Any number
What symbol represents the or operator in JavaScript?
OR
or
||
|
What is ++ ?
Names that refer to commands, functions, variables and keyword should be written correctly, variable “A” and “a” are two different variables.
Comments
Case Sensitivity
Data Types
Statements
Which of the following is the correct Javascript format for a comment?
// "the text"
/"the text"/
*/"the text"/*
\\"the text
Is this Function written correctly?
True
False
What is the name of this function?
function
spin()
3 turnLeft();
spin();
Changes the flow of the code.
Indentation
Condition
Control Structure
Parentheses
Repeat code as long as something is true.
While Loop
Loop
If Statement
For Loop
Repeat code a fixed number of times.
While Loop
Loop
If Statement
For Loop
Which of these will decrease the value of the variable X?
decrement (x)
x--;
x-x;
x-1;
In JavaScript, which of the following operator symbols means equal to?
<>
==
=
##
What's different about the coordinate system that we use when drawing on the screen of a digital device?
We draw in the 4th quadrant of the coordinate plane when drawing on the monitor.
The y-axis is inverted
The x-axis is inverted
We draw in the 2nd quadrant of the coordinate plane when drawing on the monitor.
_________ is written text or illustration that accompanies computer software or is embedded in the source code. The documentation either explains how the software operates or how to use it, and may mean different things to people in different roles.
Software Documentation
Python
Javascript
Multi line comments
The expression score = score +10 can be written as
score += 10;
score ++= 10;
score =+ 10;
score + 10 = 10;
One of the answers is not correct as increment by one:
a++
a =+1
a= a+1
a += 1
Which of these code snippets is the most readable, according to the JavaScript coding style conventions that we recommend here?
Which of these code snippets is the most readable, according to the JavaScript coding style conventions that we recommend here?
What is first index value of an array?
-1
0
1
undefine
What is the length of this array?
Which definition below best describe an array?
An array is a function identifier that can hold more than one parameter.
An array is a beam of light.
An array is a special variable, which can hold more than one value at a time.
An array is a special function, which can hold more than one value at a time.
What is proper syntax for declaring a array in JavaScript?
var arrayName =[ ];
var arrayName[ ] ={ };
array arrayName ={ };
obj var arrayName =[ ];
Which of the variables below is an array?
var names="array"
var names = array;
var names = [];
var names[];
What is the highest position in this array?
HINT: Remember arrays start at position 0!
How would you access the second element in an array?
nums.2
nums[2]
nums_1
nums[1]
What will be the output to the console for the following code:
var colors =["Red", "Green", "Yellow", "Orange", "Blue"];
colors.splice(0,3, "Purple");
console.log(colors);
["Purple", "Green", "Yellow"]
["Purple", "Green", "Yellow", "Orange", "Blue"]
["Red", "Green", "Yellow", "Orange", "Blue"]
["Purple", "Orange", "Blue"]
The push() method adds a new element to the end of an array
true
false
His name is Fred and he is less than 16 years old
if (name = "fred" && age < 16 )
if (name === "fred" && age < 16 )
if (name = "fred" || age < 16 )
if (name === "fred" || age < 16 )
What is Concatentation
The process of joining strings and variables
The process of inputting data into a variable
The way we find errors in a program
The way selection is used
Which is of the following not correct rule for writting variables names.
These need to be in the lowercase or camel case
spaces are allowed while naming these.
These could be mix of letters, Numbers, _ or $
you cannot start with a number
One of the follwing statements is correct
var myVariable = "Hello"
var myVariable = /Hello/
var myVariable = "Hello'
var myVariable = Hello
You will always find these in pairs if you have an opening one you will find a closing one as well. Even if it is after many multiple lines.
{ Braces}
[ Brackets ]
( Parentheses )
All
which the camel case variable name is correct
var my _code_date = "c"
var myCodeDate = "c"
var MycodeDate = "c"
var MyCodeDate = "c"
Which of the following is TRUE about lists.
They can't change size
They can only hold numbers
The order of items is not kept
Lists can be stored in a variable
In a list each item is assigned a number in that list. That number is called the ________?
location
index
identifier
list code
given the list
var names = ["Ann", "Bob", "Chuck", "Dana"];
which name is at names[2]?
Ann
Bob
Chuck
Dana
given
var nums = [3, 4, 6, 2, 9, 1];
what is
nums[1] + nums[3]
4
5
6
9
given the list
var names = ["Ann", "Bob", "Chuck", "Dana"];
how would I replace "Bob" with "Bill"?
names["Bob"] = "Bill";
list[1] = "Bill";
names[1] = "Bill";
names[2] = "Bill";
What would be the output of the following code?
var myList = ["A", "B", "C"];
console.log(myList.length);
2
3
4
If I had a list in my program called todo. While running lots of items are added to the end of the list. How can I get the last item in the list.
todo[last]
todo[todo.length]
todo.length - 1
todo[todo.length - 1]
what is in myNumbers after the following code runs.
var myNumbers = [10,20,25];
myNumbers[0] = 5;
myNumbers[2] = 30;
[10,20,25]
[5,20,25]
[5,20,30]
[5,10,20,25,30]
var myStuff = [20, “hat”, “pow”, 5];
myStuff[1] = “cat”;
myStuff[2] = myStuff[1];
myStuff[0] = myStuff[3] + 10;
myStuff[3] = myStuff[0] + myStuff[0];
["cat10", “hat”, “cat10cat10”, 5]
[15, “cat”, “hat”, 40]
[15, “cat”, “cat”, 30]
[15, “hat”, “pow”, 30]
var i = 1;
var nums = [3,2,1,5];
var x = (nums[ i + 1]) + (nums[i] + 1);
What is the value of x?
(a)
draw = function(){
......
}
___ is used for assigning values to a variable, ___ is used for comparing two variables
=, !=
=, ==
==, =
!=, ==
