Vocabulary
Variable
Boolean
If Statements
Functions
100

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

100

I am the first things you create at the top of your program.

Variables

100

I am used to make decisions. If something is true, do this. If something is false, do that

Boolean

100

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

&&, ||, !=

100

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

200

 Missing a comma or a quotation mark, or misspelling a word will result in this error in your program.

Syntax errors

200

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

200

This diagram is used to layout the process of a Boolean

Flowchart

200

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"
}

200

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

300

Means add strings together.

Use the + character to add a variable to another variable

String Concatenation

300

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

300

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:

  • (Choice A)A
    The code displays whichever number is greater, numA or numB, or displays numA if they are equal.


  • (Choice B)B
    The code displays whichever number is greater, numA or numB, or displays numB if they are equal.


  • (Choice C)C
    The code displays whichever number is smaller, numA or numB, or displays numA if they are equal.


  • (Choice D)D
    The code displays whichever number is smaller, numA or numB, or displays numB if they are equal.



  • (Choice B)B
    The code displays whichever number is greater, numA or numB, or displays numB if they are equal.
300

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"

300


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

400

 This pattern lets a variable "count" by whatever amount is added

The counter pattern

myVar + 1

400

A variable  which is either a variable declared within the function or is an argument passed to a function

Local Variable

400

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:

  • (Choice A)
    age > 35 AND residency ≥ 14
  • (Choice B)
    NOT(age < 35) AND residency > 14
  • (Choice C)
    NOT(age < 35) AND NOT (residency < 14)
  • (Choice D)
    age ≥ 35 AND NOT (residency > 14)



  • (Choice C)
    NOT(age < 35) AND NOT (residency < 14)
400

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"

400

True or False

A function can be called max 4x in your program

False

500

 Finish these phrases 

"when": Means there is an 

"if": Means there is


onEvent


Conditional Statement

500

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

500

identify the 6 relational operators we have used in writing our booleans.


500

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)A 
    IF (percentGrade < 70) 
    {
      grade ← "FAIL"
    }
    ELSE
    {
      grade ← "PASS"
    }

  • (Choice B)B
    IF (percentGrade ≤ 70) 
    {
      grade ← "FAIL"
    }
    ELSE
    {
      grade ← "PASS"
    }
  • (Choice C)C
    IF (percentGrade > 70) 
    {
      grade ← "PASS"
    }
    ELSE
    {
      grade ← "FAIL"
    }
  • (Choice D)D
    IF (percentGrade ≥ 70) 
    {
      grade ← "PASS"
    }
    ELSE
    {
      grade ← "FAIL"
    }
  • (Choice E)E
    IF (percentGrade ≤ 70) 
    {
      grade ← "PASS"
    }
    ELSE
    {
      grade ← "FAIL"
    }
  • (Choice F)F
    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"
    }
500
  • Add code to make the "Child" and "Senior" buttons work. They should increase the total number of tickets sold and the total money collected. Make sure you call your updateScreen function where it is necessary.

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();

});

M
e
n
u