Search Header Logo
CS2 Conditionals

CS2 Conditionals

Assessment

Presentation

Computers

9th - 12th Grade

Practice Problem

Easy

Created by

Maria Cruz Farooqi

Used 2+ times

FREE Resource

3 Slides • 7 Questions

1

CS2 Conditionals Part 1

By Maria Cruz Farooqi

​Learning Target: I can create and use if statements with boolean expressions to solve problems with up to three variables and apply them to situations like making decisions in basic algorithms.

media

2

media

3

Dropdown

Question image
This image is an example of a concept in programming called
. More specifically, selection allows our computers to
, just like the image might help us make a decision on
– if it’s hot outside, eat
!

4

Dropdown

Question image
Conditional expressions are how we represent
in our programs. More specifically, an expression occurs when values are combined using
.  When you need to compare two values, you need to use a comparison operator. You can think of this like asking your computer a
question. Except our computer uses True to represent “yes” and False to represent “no.” We say the
when our computer answers the question.

5

Drag and Drop

Question image
If statements like this are called
because they
of a program. You can see this more clearly if we map out our program with a
. Just like “while loops,” the condition of an “if statement” is constructed from
, like count < 3. The shapes in the flowchart represent different types of actions. For example, the diamond shape represents a conditional statement
Drag these tiles and drop them in the correct blank above
control structures
control the flow
flowchart
boolean expressions

6

Drag and Drop

Question image
Let’s see how we can translate our flowchart into Python.

Notice the
in front of the
line of code? This line has been indented because it is in the
. All code in the body of the if statement should be
.
Drag these tiles and drop them in the correct blank above
hero.say(“Attack Brak!”)
body of the if statement
indented
space

7

Dropdown

Question image
 Translate the following flowchart into a Python program.

We should use the variable that we use to store the name of the nearest enemy, like ‘
’.

We should ask if the nearest enemy is “
.” So ‘enemy == “skeleton”’.

Statements that tell the hero to
‘Attack the skeleton’ should be in the
.


8

Dropdown

Question image



= hero.findNearestEnemy ( )

if (enemy ​
"skeleton")

hero.​
( "Attack the skeleton!")

9

Match

Match the following:

The process of selectively running blocks of code only if certain conditions are met.

A code block that executes another block of code only if a condition is true.    

The combination of two or more values using a comparison operator.

A conditional expression that is used to determine whether a block of code, like an if statement or a while loop, runs.

Selection

If Statement

Conditional Expression

Condition

10

media

CS2 Conditionals Part 1

By Maria Cruz Farooqi

​Learning Target: I can create and use if statements with boolean expressions to solve problems with up to three variables and apply them to situations like making decisions in basic algorithms.

media

Show answer

Auto Play

Slide 1 / 10

SLIDE