Lesson 9
Conditionals
Foundations of AI Programming
Warm Up
Do This:
Foundations of AI Programming Conditionals – Warm Up
Let's Review: Algorithms
An algorithm is a set of instructions to accomplish a task. This usually includes:
Foundations of AI Programming Conditionals – Warm Up
Which component of an algorithm did you just experience when you either stood or stayed seated?
Discuss:
Foundations of AI Programming Conditionals – Warm Up
Lesson Objectives
By the end of this lesson, you will be able to . . .
Foundations of AI Programming Conditionals – Warm Up
How can we use conditional statements to help a computer make decisions?
Question of the Day
Foundations of AI Programming Conditionals – Warm Up
Activity
| |
| if isabel.can_move("south"): |
| isabel.move() |
| isabel.paint("blue") |
| |
| if isabel.can_move("south"): |
| isabel.move() |
| isabel.paint("blue") |
Foundations of AI Programming Conditionals – Activity
| |
| if isabel.can_move("south"): |
| isabel.move() |
| isabel.paint("blue") |
| |
| if isabel.can_move("south"): |
| isabel.move() |
| isabel.paint("blue") |
Foundations of AI Programming Conditionals – Activity
You should have:
Unit Guide
Foundations of AI Programming Conditionals – Activity
A conditional statement tells a computer to do something only if a certain condition is True.
| |
| if painter.can_move("south"): |
| painter.move() |
| painter.paint("blue") |
📝 Unit Guide
What is a Conditional Statement?
Foundations of AI Programming Conditionals – Activity
| ||
| 1 | if isabel.can_move("south"): |
| 2 | isabel.move() |
| 3 | isabel.paint("blue") |
| |
|
| | |
| | |
| | |
| | |
| | |
📝 Unit Guide
Foundations of AI Programming Conditionals – Activity
| ||
| 1 | if isabel.can_move("south"): |
| 2 | isabel.move() |
| 3 | isabel.paint("blue") |
| |
|
| | |
| | |
| | |
| | |
| | |
📝 Unit Guide
Foundations of AI Programming Conditionals – Activity
| ||
| 1 | if isabel.can_move("south"): |
| 2 | isabel.move() |
| 3 | isabel.paint("blue") |
| |
|
| | |
| | |
| | |
| | |
| | |
📝 Unit Guide
Foundations of AI Programming Conditionals – Activity
| ||
| 1 | if isabel.can_move("south"): |
| 2 | isabel.move() |
| 3 | isabel.paint("blue") |
| |
|
| | |
| | |
| | |
| | |
| | |
📝 Unit Guide
Foundations of AI Programming Conditionals – Activity
| ||
| 1 | if isabel.can_move("south"): |
| 2 | isabel.move() |
| 3 | isabel.paint("blue") |
| |
|
| | |
| | |
| | |
| | |
| | |
📝 Unit Guide
Foundations of AI Programming Conditionals – Activity
Why do you think conditionals are useful in programs? What kinds of decisions might a program need to make?
Discuss:
Foundations of AI Programming Conditionals – Activity
Do This:
Exploring Conditionals
1
Lesson 9
Foundations of AI Programming Conditionals – Activity
What did you learn about if statements?
Discuss:
Foundations of AI Programming Conditionals – Activity
What questions do you still have about if statements?
Discuss:
Foundations of AI Programming Conditionals – Activity
What are the benefits of using if statements in our code?
Discuss:
Foundations of AI Programming Conditionals – Activity
UMPIRE
Remember to use the UMPIRE strategy as you work on using conditionals within your programs.
U
M
P
I
R
E
Understand
Make a plan
Produce
Inspect
Refine
Explain
Foundations of AI Programming Conditionals – Activity
Do This:
Decisions with the Painter
6
Lesson 9
A
B
C
D
Foundations of AI Programming Conditionals – Activity
Wrap Up
Today, you learned about . . .
Foundations of AI Programming Conditionals – Wrap Up
How can we use conditional statements to help a computer make decisions?
Question of the Day
Foundations of AI Programming Conditionals – Wrap Up
Key Vocabulary
Foundations of AI Programming Conditionals – Wrap Up