Font size
WorksheetsCode.org Variables and Conditionals
Total questions: 88
Worksheet time: 2hrs 32mins
The visual elements of an program through which a user controls or communications the application.
Unlimited Internet
User Interface
Universal Images
User Images
What will be displayed if grade is set to 70?
You passed!
Time to start studying again!
You passed! and Time to start studying again!
Nothing will be displayed
What is the output of the following JavaScript code segment?
10
error on str1 + str2: type mismatch
55
result
UI Elements include all of the following EXCEPT:
Images
Functions
Pull Down Menus
Text Boxes
A syntax error in your code includes:
A. - The program running correctly but not actually doing what you think it should do
B. - A word you misspelled in a way the computer doesn't understand
Both A and B
Neither A or B
Which of the following is FALSE with regards to the command console.log?
You can use this command in sending messages to yourself to verify the program is doing what you think it's doing which helps prevent errors down the line.
Using this command is a way to debug your program
This command cannot be used in determining potential errors down the line in your programming
Console.log is a way to display a simple plaintext output
Trace the code, and choose the option that correctly shows what will be displayed.
a = 12, b = 20, c = 32
a = 12, b = 12, c = 12
a = 4, b = 12, c = 16
a = 12, b = 20, c = 24
Look at the following:
var age = "20 + 5"
As a result of the above, using this variable throughout the remainder of this program would result in a value of 25.
True
False
In the above picture, this would be an example of a:
Local Variable
Nested Variable
Global Variable
Variable Scope
In the above picture, this would be an example of a:
Local Variable
Nested Variable
Global Variable
Variable Scope
The following would be considered an example of a string:
'This is an example of a string'
True
False
A logical error in your code includes:
A. - The program running correctly but not actually doing what you think it should do
B. - A word you misspelled in a way the computer doesn't understand
Both A and B
Neither A or B
The visual elements of a program through which a user controls or communicates with the application. Often abbreviated UI.
Callback Function
User Interface
Debugging
Event Handler
A function specified as part of an event listener; it is written by the programmer but called by the system as the result of an event trigger.
UI
Event Handler
Callback Function
Turtle
A program designed to run blocks of code or functions in response to specified events (e.g. a mouse click)
Event-driven Program
Event Handler
Beaver Programming
Event Listener
An action that causes something to happen.
Debugger
Data Type
Variable
Event
All values in a programming language have a "type" - such as a Number, Boolean, or String - that dictates how the computer will interpret it.
Data Type
Variable
Operation
Bug
Any valid unit of code that resolves to a value.
Variable
Expression
Data
Code
The common programming structure that implements "conditional statements".
"Maybe" Statement
"When" Statement
"If" Statement
"Could" Statement
Dictates what portions of the code can "see" or use a variable, typically derived from where the variable was first created.
Variable Room
Variable Travel
Variable Space
Variable Scope
A variable whose scope is "global" to the program, it can be used and updated by any part of the code. Its global scope is typically derived from the variable being declared (created) outside of any function, object, or method.
Global Variable
Local Variable
Wide Variable
Limited Variable
A variable with local scope is one that can only be seen, used and updated by code within the same scope. Typically this means the variable was declared (created) inside a function -- includes function parameter variables.
Short Variable
Small Variable
Global Variable
Local Variable
Debugging
Putting commands in correct order so computers can read the commands.
a step-by-step procedure for solving a problem
to write instructions for a computer.
Finding and fixing problems in your algorithm or program.
Which of the following would NOT be an acceptable ID when following the rules for naming IDs?
A. thisWouldBeAcceptable
B. This_Would_Be_Acceptable
C. this-would-be-acceptable
All three options would be acceptable IDs
When naming IDs for your elements, they may NOT contain:
Spaces
Hyphens
Underscores
Periods
When setting the setPosition command, the coordinates (0,0) begins where on the screen?
Top Right Corner
Bottom Left Corner
Top Left Corner
Bottom Right Corner
The following line of code would not appear on the screen of an app you have just created:
console.log("Welcome to My App!");
True
False
A player starts off a game with 3 lives (assigned by a variable named "lives"). After the player runs out of lives and the game is over, a "Play Again" button is pressed to start a new game. However, what needs to happen here?
The following code should be added again: var lives = 3;
The following code should be added to reset the lives: lives = 3;
The following code should be added to reset the lives: reset lives = 3;
No action needed; the game will automatically reset with 3 lives
Which of the following is TRUE regarding = and ==
When assigning a value to a variable, use ==
The command if (count=20) is the correct way to type this command for this IF statement
The command count = count-1; would be the correct way to update this variable each time you want it to decrease
The correct way to start off with 3 lives would be typing this command first: var lives == 3;
Once a value is assigned to a variable, it cannot be updated with a new value.
True
False
Note the following line of code (note: Numlikes is a variable): write (So far + numLikes + people like this Quizizz); What will happen when this is ran?
It will not run because the variable name does not follow proper naming rules
It will not run because there are double quotation marks missing
It will not run because the command "write" does not exist in Javascript
The line would run perfectly: "So far ____ people like this Quizizz"
When is a compound condition using the logic operator AND true?
When either of the conditions are true
When both of the conditions are false
When both of the conditions are true
When the NOT operator is also used
Which of the following is FALSE regarding ELSE IF statements?
You add an ELSE IF when you have another condition you want to check.
You are limited to only one ELSE in your code
Each condition in an ELSE IF is checked from top to bottom
The final ELSE clause is executed if all the previous conditions evaluated to false.
Which of the following statements regarding AND/OR operators are FALSE?
true && true = true
true && false = true
false || true = true
false || false = false
Which of the following statements regarding AND/OR/NOT operators are TRUE?
!(true) = true
true || true = false
false && true = true
false || true = true
Based on the following, determine whether each expression is TRUE or FALSE
var season= “Spring”;
!(season== “Summer”)
True
False
Based on the following, determine whether each expression is TRUE or FALSE
var season= “Spring”;
!(3 > 2)
True
False
Based on the following, determine whether each expression is TRUE or FALSE
var score= 80;
(score != 90) && (score > 70)
True
False
Based on the following, determine whether each expression is TRUE or FALSE
var score= 80;
(score > 90) && (score < 100)
True
False
Based on the following, determine whether each expression is TRUE or FALSE
var month = “March”;
(month == “Mar”) || (month== “March”)
True
False
Based on the following, determine whether each expression is TRUE or FALSE
var month = “March”;
(month== “April”) || (10<12)
True
False
Read the following line of code:
var statement = "Hello my name is " + firstName);
This would be considered an example of:
concentrate
concatenate
conditional statement
selection
Which of the following would not be a correct way to use strings?
"aString"
"look at all these spaces"
"$100 bills are the best"
'myStringname'
Looking at the image above, which of the following commands would you use as a text box you want the user to type into on a particular screen?
Label
Text Area
Text Input
Button
In order to hold and retain the information obtained from the Name field, a variable should be used as follows:
var userName = getText("nameInput");
userName=textInput("nameInput");
var userName=getText(nameInput);
userName=textInput(nameInput);
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
What is my result?
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 my result?
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 result?
You can buy some gum
You are rich
Get a job!
You are rich
Get a job!
With regards to IF ELSE Statements, either of the lines of code inside the IF will execute or the lines inside the ELSE will execute.
True
False
With regards to IF ELSE Statements, ELSE shares it's opening and closing curly braces with the same curly braces from the IF portion of this statement
True
False
Back in Lesson 8, you compared the user's password input to what we wanted the password to be. How would you write this in Javascript?
if (textInput("password_input")=="my secret")
if (getInput("password_input")=="my secret")
if (password("password_input")=="my secret")
if (getText("password_input")=="my secret")
When creating an IF ELSE statement with multiple else if conditions, you should always start this statement with:
ELSE
IF ELSE
ELSE IF
IF
When working with an IF ELSE statement, you can only have one possible else if condition in it.
True
False
It is possible to write a chain of else-if conditions without a final else, in which case it's possible that the whole structure will be skipped.
True
False
Decide if the expression evaluates to true or false:
True
False
Decide if the expression evaluates to true or false:
True
False
Decide if the expression evaluates to true or false:
True
False
Decide if the expression evaluates to true or false:
True
False
Decide if the expression evaluates to true or false:
True
False
What will the value of "score" be at the end of this program?
1
The score is: 8
8
The score is: score
What will be displayed after this code segment is ran?
4
8
9
13
What is my result?
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 will be displayed after this code segment is run?
Perfect Game!
You Win!
You Lose!
Nothing Will Be Displayed
The program above asks a user to type in a number and then will output a message. What number will a user need to input for the message "GREEN" to be displayed?
10
20
30
40
Which of the following is FALSE with regards to variables?
Numbers and strings are two different types of values
Old values are deleted forever
Expressions evaluate to multiple new values
When variables are in the expression just make a copy, don’t change the actual variable
"This" + "would" + "be" + "an" + "example" + "of" + "this":
Expression
Concatenation
Single String
Procedure
Which of the following is TRUE regarding variables?
It's advised to create them multiple times
Variables should go at the bottom of your program code
A variable name such as "myvariable" can have two words in the name
Variables can never be created inside OnEvents or Functions
Logical operators can include any of the following EXCEPT:
&&
==
||
!
Which of the following is FALSE regarding Boolean expressions?
A decision is made with the single Boolean value
Boolean expressions can include Comparison Operators like <, >, <=, >=, ==
Flowcharts can illustrate the steps of making a decision with a Boolean expression
Each side of the Boolean expression is reduced to a single value
These can check more than one Boolean expression. They will only run the code for the first Boolean expression that evaluates to true.
IF-ELSE-IF Statements
IF Statements
IF-ELSE Statements
All of these statements
These add the functionality that if the condition is false it can still run some code before returning to running the program as normal
IF-ELSE-IF Statements
IF Statements
IF-ELSE Statements
All of these statements
This checks if one Boolean expression is true. If it is, a piece of code is run. Otherwise the code runs as normally.
IF-ELSE-IF Statements
IF Statements
IF-ELSE Statements
All of these statements
