Search Header Logo

Conditional Quiz

Authored by Donna Panter

Computers

3rd - 12th Grade

Used 6+ times

Conditional Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

21 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is output by the code below?

var dogs = 4;

if (dogs > 3) {

write("Boxer");

} else if (dogs <= 2) {

write("Golden Retriever");

}

Boxer

Golden Retriever

True

No output

Answer explanation

4 is greater than 3 so the first if statement evaluates true. Therefore the first write is what is outputted.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?

var cat = 3;

if (cat == 2) {

write("Good kitty");

} else if (cat == 3) {

write("Mean kitty");

} else if (cat == 1) {

write("Ugly kitty");

}

Good kitty

Mean kitty

Ugly kitty

true

Answer explanation

if (cat == 2) {

write("Good kitty");

} else if (cat == 3) {

write("Mean kitty");

} else if (cat == 1) {

write("Ugly kitty");

}

Since cat is assigned the value of 3, the else if statement of cat == 3 is true. So the write of Mean kitty is written.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output?

var dog = 9;

if ( (dog > 2) && (dog < 13) ) {

write("I love dogs");

} else if ( dog < 5 ) {

write("I love cats");

}

I love dogs

I love cats

true

no output

Answer explanation

if ( (dog > 2) && (dog < 13) ) {

write("I love dogs");

} else if ( dog < 5 ) {

write("I love cats");

}

Since dog holds the value of 9, the first if statement evaluates to true. So the output is I love dogs. The else if statement will not be evaluated since the if statement is true.

4.

FILL IN THE BLANKS QUESTION

1 min • 1 pt

What is output?

var song = 3;

if (song > 9) {

write ("My favorite song is ");

} else if (song > 3) {

write("I don't like the song ");

} else if (song < 4) {

write("Sing the song ");

}

write("Chicken Nugget Song");

(a)  

5.

FILL IN THE BLANKS QUESTION

1 min • 1 pt

What is output ?

var school = 3;

if (school <= 2) {

write("Texans");

} else {

write("Astros");

}

(a)  

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is output?

var school = 3;

if ( school == 5 || 3) {

write("Phillies");

} else if (school > 4){

write("Cardinals");

}

Phillies

Cardinals

true

Phillies, but there is a syntax error

Answer explanation

syntax error because the or in the first if statement should have:

(school == 5) || (school == 3)

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is output?

var x = 32;

write( x >= 45 || x < 32 ) ;

true

false

32

45

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers