if, elif, and else Conditionals

if, elif, and else Conditionals

9th - 12th Grade

20 Qs

quiz-placeholder

Similar activities

CS -XII A

CS -XII A

12th Grade

20 Qs

Python Basics Quiz

Python Basics Quiz

9th Grade

15 Qs

Циклы

Циклы

9th Grade

16 Qs

Coding Basics

Coding Basics

11th - 12th Grade

15 Qs

2.2 Programming techniques

2.2 Programming techniques

10th - 11th Grade

24 Qs

Grade 8 End of Unit Revision

Grade 8 End of Unit Revision

8th Grade - University

15 Qs

Algoritma Fungsi Phyton

Algoritma Fungsi Phyton

10th Grade

20 Qs

Python elif and Nested if

Python elif and Nested if

12th Grade

15 Qs

if, elif, and else Conditionals

if, elif, and else Conditionals

Assessment

Quiz

Computers

9th - 12th Grade

Medium

Created by

Bryan Campbell

Used 13+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?