I make it easier to debug your program since you are not writing redundant code. You only need to rewrite and debug the code once.
Function
I am the first things you create at the top of your program.
Variables
I am used to make decisions. If something is true, do this. If something is false, do that
Boolean
Used to check more than one boolean expression. They will only run the code for the first boolean expression that evaluates to true.
Logical Operators
&&, ||, !=
Is only declared once but is called as many times as you wish
Function is only declared once but is called as many times as you wish
Missing a comma or a quotation mark, or misspelling a word will result in this error in your program.
Syntax errors
Elvira is experimenting with assigning and displaying variables. Here's a snippet of her code:
a ← 12
DISPLAY (a)
b ← 32
DISPLAY (b)
a ← b
b ← 52
DISPLAY (a)
DISPLAY (b)
What will be the output of that code?
12 32 32 52
This diagram is used to layout the process of a Boolean
Flowchart
flow chart:
She must implement that logic in code, using the variables diceRoll and action.
Write a code snippet that correctly implements the logic in that flow chart?
IF (diceRoll ≥ 15)
{
action ← "success"
}
ELSE
{
action ← "failure"
}
Read the code below and identify why the screen won't update
onEvent("submit", "click", function( ) {
Updatescreen();
});
function updateScreen() {
light = getText("light");
waterSchedule = getText("wateringSchedule");
humidity = getText("humidity");
});
updateScreen is spelled incorrectly
Means add strings together.
Use the + character to add a variable to another variable
String Concatenation
Darian is coding a program that draws a face and is storing the eye coordinates in variables. They mistakenly used the same variable names for both eyes, however:
eyeX ← 200 eyeX ← 250
250
The code below processes two numerical values with a conditional statement.
numA ← INPUT() numB ← INPUT() IF (numA > numB) { DISPLAY(numA) } ELSE { DISPLAY(numB) }
The code relies on a built-in procedure, INPUT(), which prompts the user for a value and returns it.
Which of the following best describes the result of running this code?
Choose 1 answer:Choose 1 answer:
IF (x < 0 AND y < 0) {
quadrant ← "BL"
} ELSE {
IF (x < 0 AND y > 0) {
quadrant ← "TL"
} ELSE {
IF (x > 0 AND y < 0) {
quadrant ← "BR"
} ELSE {
IF (x > 0 AND y > 0) {
quadrant ← "TR"
}
}
}
}
When x is 52 and y is -23, what will be the value of quadrant?
"BR"
Which of the following is true of functions?
A. Programs written with functions run more quickly
B. Functions can help remove repeated code from a program
C. Replacing repeated code with a function will reduce the number of commands the computer needs to run
D. Functions are called once but can be declared many times
B. Functions can help remove repeated code from a program
This pattern lets a variable "count" by whatever amount is added
The counter pattern
myVar + 1
A variable which is either a variable declared within the function or is an argument passed to a function
Local Variable
According to the US constitution, a presidential candidate must be at least 35 years old and have been a US resident for at least 14 years. The variable age represents a candidate's age and the variable residency represents their years of residency.
Which of the following expressions evaluates to true if a candidate meets the criteria?
Choose 1 answer:Choose 1 answer:
IF (inHurry = true AND eggDish = "fried")
{
heatLevel ← "high"
}
ELSE
{
IF (inHurry = false AND eggDish = "scrambled")
{
heatLevel ← "low"
}
ELSE
{
heatLevel ← "medium"
}
}
When in a hurry is true and egg dish = "scrambled"
When in a hurry is false and egg dish = "fried"
True or False
A function can be called max 4x in your program
False
Finish these phrases
"when": Means there is an
"if": Means there is
Conditional Statement
You have just completed your program.
You run the app however, you keep receiving the message" 'myVar' is declared but not called in your program."
What are 3 possible reasons for this message?
Consistency in spelling
Labeled correctly(lowercase & without parenthesis)
Created variables inside an onEvent() or function() blocks
identify the 6 relational operators we have used in writing our booleans.
Lucie is developing a program to assign pass/fail grades to students in her class, based on their percentage grades.
Their college follows this grading system:
PercentageGrade70% and abovePASSLower than 70%FAIL
The variable percentGrade represents a student's percentage grade, and her program needs to set grade to the appropriate value.
Which of these code segments correctly sets the value of grade?
👁️Note that there are 2 answers to this question.
(Choice A)AIF (percentGrade < 70) { grade ← "FAIL" } ELSE { grade ← "PASS" }
IF (percentGrade ≤ 70) { grade ← "FAIL" } ELSE { grade ← "PASS" }
IF (percentGrade > 70) { grade ← "PASS" } ELSE { grade ← "FAIL" }
IF (percentGrade ≥ 70) { grade ← "PASS" } ELSE { grade ← "FAIL" }
IF (percentGrade ≤ 70) { grade ← "PASS" } ELSE { grade ← "FAIL" }
IF (percentGrade < 70) { grade ← "PASS" } ELSE { grade ← "FAIL" }
Choice A
IF (percentGrade < 70) { grade ← "FAIL" } ELSE { grade ← "PASS" }
Choice D
IF (percentGrade ≥ 70) { grade ← "PASS" } ELSE { grade ← "FAIL" }
var dollars = 0;
var tickets = 0;
var adultPrice = 12.50;
var childPrice = 8.50;
var seniorPrice = 10;
// Add code to make this button work
onEvent("childButton","click",function(){
});
// Add code to make this button work
onEvent("seniorButton","click",function(){
});
onEvent("childButton","click",function(){
tickets = tickets + 1;
dollars = dollars + childPrice;
updateScreen();
});
// Add code to make this button work
onEvent("seniorButton","click",function(){
tickets = tickets + 1;
dollars = dollars + seniorPrice;
updateScreen();
});