Search Header Logo

if, elif, and else Conditionals

Authored by Bryan Campbell

Computers

9th - 12th Grade

Used 13+ times

if, elif, and else Conditionals
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the purpose of the if statement in Python?

To declare a variable

To loop through a sequence

To perform conditional execution of code

To define a function

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How many possible values are there for a boolean variable?

1

2

3

4

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Assume you are writing a program, and you have a boolean variable called b, defined like so:

b = True

Pick the correct if statement to follow the code above. The if statement should be correct Python, and the body of the if statement should only run if b is True.

Media Image
Media Image
Media Image
Media Image

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

In Python, how is the if statement terminated?

With a semicolon

With a colon

With a period

With an exclamation mark

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is not a logical operator in Python?

and

or

not

because

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following programs will run but will not print anything?

Media Image
Media Image
Media Image
Media Image

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Mr. Ramesh is writing a Python program to check if Carlos and Charlie have both completed their homework. He wants to use the and operator in an if statement. What is the purpose of the and operator in this context?

It is used for bitwise operations

It combines two conditions, and both must be true for the if statement to execute

It is used to exit a loop

It is used for logical negation

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

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?