Font size
Worksheetscoding variables
Total questions: 28
Worksheet time: 1hrs 15mins
Programming is when humans write computer instructions
true
false
A computer needs correct syntax to understand code
True
False
_______ are the rules for writing code
Syntax
Loops
Variables
Functions
variables have names
true
false
optional
A _________ holds your data for later
syntax
Expression
Variable
Value
A variable is just a _____ for storing a____
constant; value
container; value
constant; variable
container; variable
What is the purpose of a variable?
To store data, and give it a name for later use
To replace numbers
To make algebra work
show the x axis or y axis
The operator to assign values?
==
<==
=
new
______ is a type of data that represents text
Basic
Syntax
Argument
String
Words that signal to the computer that you are about to create a variable in Javascript or Java ?
var
con
constant
new
class
function
score
x
y
javaScript
coding language
variable
data storage
10
a number value of ten
=
assignment operator
"10"
A string value "10"
what can we store in a JavaScript variable?
food storage
example
tupperware
strings
example
"abc"
objects
example:
new Circle()
boolean
example:
true
numbers
example
3
Select 2: Why create variables with precise names?
Write code understandable to others or yourself later in time
Avoid duplicate names or reserved words in a language
Create long names as a form of cryptic encoding
Short names are always bad
join a string "your heath points: " with variable hp
concatenation
+
++
merge
var s = "1";
var i = "3";
var t = s + i;
// what is stored in variable t?
(a)
print( "health points: " + hp );
// what describes the + operator?
+
syntax error
+
add hp points
+
increment points
concatentation
radius is a property of what?
Circle object
Circle and Rectangle
Image
Image and Circle
The screen area where JavaScript circles can be drawn on screen
canvas
area
radius
HD
coordinates that best match the red dot in the image
canvas.width/2
,
canvas.height/2
canvas.width
,
canvas.height
(y,x)
axis_y, axis_x
var planet = new circle();
planet.draw()
//are there bugs here?
must use animate
missing x,y values
Make C
in Circle
UPPERCASE
missing radius
dot.draw()
// what is .draw() most like?
noun
verb
adjective
doing
nothing
alien = new image();
alien.x = 200;
alien.y = 200;
alien.name = "monster1.png";
monster.draw();
// what code revisions fix the bugs above
alien = monster.png
draw image()
var alien= new Image()
alien.draw()
("alien.png")
what clue shows x is assigned a literal string value 3
quotes
"3"
var = new Literal
colon
3: 3
var x = syntax
Defining variable for the first time.
Declare a Variable
Variable
Console
readLine
var ship = new Circle(40,40);
ship.radius = 30;
30 is a value
ship is an object
radius is a property of ship
objects are properties
var ship = {
shields: 40,
seats: 10,
fuel: 0,
}
40 and 10 are properties
seats is a property
there are 4 properties
40 and 10 are values
var morgan = {
eyeColor: "brown",
age : 10,
walletValue: 0,
}
age and eyeColor
properties
zero && brown
values
object name
morgan
var x = {}
declare object literal x
var pat = {
humor: "good",
age : 40,
pronoun: "they",
}
they good
values
object name
pat
humor, pronoun
properties
var x = {}
declare object literal x
