BIlly - AP Comp Scie 3rd 9 week test

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What symbol represents the and operator in JavaScript?

&&

What is the proper operator for "not equals" in JavaScript?

!=

Which of the following Boolean expressions is equivalent to the expression (a OR b) AND NOT (c OR d) (a OR b) AND ((NOT c) OR (NOT d)) (a AND NOT (c OR d)) OR b (a OR b) AND (NOT c) AND (NOT d) NOT (a AND b) AND NOT (c OR d)

(a OR b) AND (NOT c) AND (NOT d)

What is the proper way to compare if two values are equal in a boolean expression in JavaScript?

==

In the following code block, assume that the variables rainy and tooCold are boolean. IF (NOT (rainy OR tooCold)) { DISPLAY("It's a good beach day") } Which of the following are equivalent to the above code block? ---- A) IF (( NOT rainy) OR (NOT tooCold)) { DISPLAY("It's a good beach day") } B) IF (( NOT rainy) AND tooCold) { DISPLAY("It's a good beach day") } C) IF (( NOT rainy) AND (NOT tooCold)) { DISPLAY("It's a good beach day") } D) IF (rainy AND tooCold) { DISPLAY("It's a good beach day") }

C

Symbol for comparison operators: EQUAL NOT EQUAL LESS THAN GREATER THAN LESS THAN OR EQUAL GREATER THAN OR EQUAL

EQUAL == NOT EQUAL != LESS THAN < GREATER THAN > LESS THAN OR EQUAL <= GREATER THAN OR EQUAL >=

What are logical operators?

Let you connect and modify boolean expressions

Is "yes" a valid value for a boolean?

No, only true or false

What are the three logical operators ?

Not: ! Or: || And: &&

How can we check if a variable num is even?

Use the mod function (num % 2 == 0) will be true

What is a Boolean?

a boolean refers to a value that is either true or false

Write a conditional that checks to see if number is not equal to 30 and temp is at least 50, where number and temp are variables.

if (number != 30 && temp >= 50)

What kind of statement allows us to run a block code only if a certain condition is true?

if statement

What is the format of an if - else if statement ?

if( x == "abc"){ println("x is abc?"); } else if ( x == "def"){ println("x is def") ; }else if(x == "efgi") println("x is efg") }

You are a teenager if you are 13 or older less than 20. How would you code this?

if(age >=13 && age < 20){ println("Yes, you are a teenager"); }else{ println("You are not a teenager"); }

What kind of statement allows us to run one block of code if one condition is true, and a separate block of code otherwise?

if/else statement

if you have the value: var happy = true; How would you change happy to false?

its assigning the value of false to happy so happy = !happy;

How would you write a the following statement in Javascript. If you are over the age of 16 and are not blind you can drive

over16 = true; notBlind = true; if ( over16 && notBlind) youCanDrive = true;

what do comparison operators let us do

they let us compare two values

After the following code runs, what is the value of isWeekend? var isSaturday = true; var isSunday = false; var isWeekend = isSaturday || isSunday;

true

After the following code runs, what is the value of weatherOK? var isRaining = true; var isFoggy = true; var WeatherNotOK = isRaining || isFoggy;

true

The AP Exam uses the following relational (comparison) operators: =, ≠, >, <, ≥, and ≤.As well, AND, OR and NOT are used instead of &&, || and !=.A comparison using a relational operator evaluates to a Boolean value. For example, a = b evaluates to true if a and b are equal; otherwise, it evaluates to false.Determine whether the following expression would evaluate to true or false. 7 = 6 OR 8 ≥ 4 True or false?

true

what would you get for this if statement over16 = true; blind = false; if ( over 16 && blind) youCanDrive = false; else youCanDrive = true;

youCanDrive = false;

What symbol represents the or operator in JavaScript?

||


Ensembles d'études connexes

NE 105- Test 2- Practice Questions- Toddler/Preschooler

View Set

Leadership I (Corporal's Course)

View Set

Chapter 13: Deserts and Wind Action

View Set

Intermediate Accounting Chapter 8 Inventory

View Set

ethics and corporate responsibilities FINALE

View Set