Updated: February 4, 2025
Learning objectives
Learn and apply the coding concepts:
- Conditionals
- Boolean logic
- If, If Else, and Elif Conditionals
- Boolean logic with Conditionals
Teacher prep and notes
This lesson is also a part of the Programming with Python computer science unit. Refer to the Curriculum Overview to find out more information about how to use this content as part of computer science instruction for students in Upper Secondary | Grades 9-12 | Ages 14-18. This curriculum overview can be found under the Supporting Files section.
This lesson also includes a classroom presentation. This presentation is intended to provide you with a scaffolded, step-by-step sequence following the gradual release model. Use this presentation during instruction to help guide the students. This resource can also be found under the Supporting Files section.
Guiding ideas
Students need to help CodingMine further develop the Agent. CodingMine wants to code the Agent so that it can drive a car by itself. However, this means that the Agent needs to be able to make decisions and analyze the road for any obstacles and signs. Before testing the Agent on the actual road, the students will be coding the Agent in a number of simulated traffic situations. Students will code the Agent using conditionals and Boolean logic.
Student activities
Coding Activities
Activity 1: Stop and go
The developer needs their help to write some code to make the Agent understand traffic lights.
- Part 1: The Agent should keep moving when green blocks are to its left.
- Part 2: The Agent should stop when there is a red block to its left.
- Part 3: The Agent should wait for 2 seconds when there is a yellow block to its left and then continue to the gold.
Activity 2: Is it left or right?
The programmer needs their help to write some code to make the Agent able to navigate busy streets by reading road signs. The Agent will have to stop and turn in different directions depending on the signs on a simulated road.
Activity 3: Getting through
The AI developer needs their help to write an obstacle detection code to make the Agent navigate through a course with randomly placed blocks. The Agent should be able to get to the end, no matter where the blocks are placed. Once the Agent detects a block, it will be highlighted.
Performance expectations
Ask the students about the skills that they have learned during the lesson, to reinforce the concepts. Upon completion of this lesson, students should be able to answer the following questions:
1. When talking about Boolean logic, what do 1 and 0 represent?
A. True (1) and false (0)
2. What are conditionals?
A. Conditionals are commands that run code if something is true or false.
3. What does the AND operator do?
A. The operator checks to see that two conditions are true.
4. What does the syntax == do?
A. Double equals compares a defined condition against the Minecraft world or coding outcome.
These questions can be used as a formative assessment. A printable version of these questions can be found at the end of educator's guide.
External reference
Skills
- Creativity
- Critical thinking
Estimated time
1 hour
Supporting Files
- Python 101-Lesson 6: Driving AroundEDU Guide
- Python 101-Lesson 6: Driving AroundPresentation
- Programming with PythonCurriculum Overview