wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

U6/L3 HS Kira- Nested If Statements

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

Which phrase best defines a nested if statement in programming?

a)

An if statement that repeats until a condition is false

b)

A conditional placed inside another if statement to make more complex decisions

c)

A standalone if followed by multiple else statements

d)

A loop that contains a conditional check

2.

What is the primary purpose of a flowchart when planning conditionals?

a)

To measure program speed in real time

b)

To show the sequence of steps and decisions needed to solve a problem

c)

To translate code directly into machine language

d)

To store variables and their data types

3.

In programming, conditionals allow the computer to do what?

a)

Repeat code a fixed number of times

b)

Make decisions based on whether something is true or false

c)

Convert text to numbers automatically

d)

Draw user interface elements by default

4.

In a nested if structure, when does the inner if run?

a)

Only if the outer if statement is true

b)

Only if the outer if statement is false

c)

Regardless of the outer condition

d)

Only after an else clause executes

5.

Complete the idea: The deeper the nesting, the more ____ the logic becomes.

a)

efficient

b)

confusing or complex

c)

portable

d)

deterministic

6.

A nested if statement provides more control and flexibility by allowing a program to respond to ____ conditions.

a)

static

b)

multiple or layered

c)

numeric-only

d)

random

7.

Consider the scenario: “If it’s raining, then check if I have an umbrella. If I do, I’ll go outside.” What makes this a nested decision?

a)

It checks two unrelated conditions at the same time

b)

It checks a second condition only after confirming the first is true

c)

It always executes both checks regardless of weather

d)

It uses loops to repeat the decision

8.

In Python, what must be used carefully to show which code blocks belong to which conditions when nesting ifs?

a)

Curly braces

b)

Semicolons

c)

Indentation

d)

Line numbers

9.

Why might writing a short story using nested conditionals be useful for students?

a)

It helps memorize syntax without understanding logic

b)

It demonstrates how decisions unfold step by step

c)

It eliminates the need for testing code

d)

It automatically generates flowcharts

10.

Before coding a nested if statement, creating what can help plan the logic clearly?

a)

A database schema

b)

A flowchart

c)

A variable table

d)

A performance profile

11.

Which Python keywords can be combined with nested ifs to handle different outcomes?

a)

switch and case

b)

else and elif

c)

for and while

d)

try and except

12.

What is a potential downside of overusing nested if statements?

a)

They always slow down the CPU

b)

They make code harder to read and debug

c)

They prevent the use of variables

d)

They cannot include else clauses

13.

Given age = 16 and money = 20, which nested condition correctly prints “You can have a ticket.” only when the person is old enough for PG-13 (age >= 13) and has more than $15?

a)

if age > 13: if money >= 15: print("You can have a ticket.")

b)

if age >= 13: if money > 15: print("You can have a ticket.")

c)

if age >= 18: if money > 15: print("You can have a ticket.")

d)

if money > 15: if age > 18: print("You can have a ticket.")

14.

What is one advantage of using a nested if structure instead of multiple separate if statements when solving a problem?

a)

Nested ifs always execute faster

b)

Nested ifs allow checking a second condition only when the first is true, keeping logic orderly

c)

Nested ifs reduce the number of variables required

d)

Nested ifs remove the need for else or elif

15.

In a game where a door opens only if the player chooses the left path and has a key, which structure best models this logic?

a)

Two independent if statements checked in any order

b)

A nested if where the key is checked only after confirming the left path

c)

A while loop that runs until a key is found

d)

A switch-case selecting the path

16.

What strategy can help make complex nested-if code easier to understand and maintain?

a)

Increase nesting depth to capture all cases in one place

b)

Remove indentation to simplify the look

c)

Use flowcharts and consider else/elif to reduce deep nesting

d)

Replace all conditionals with loops