6_resized-554x368.png

Python 101 - Lesson 6

11-13 yrs old

14-18 yrs old

Computer Science

Technology

DRIVING AROUND Conditionals and Boolean logic

11
avatar Submitted By: Minecraft Education

September 8, 2020

Skills

  • Creativity
  • Critical Thinking

Learning Objectives

  • Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs. 2-AP-13
  • Create programs that include sequences, events, loops, and conditionals. 1B-AP-10
  • Systematically test and refine programs using a range of test cases. 2-AP-17

Guiding Ideas

In this lesson the students will learn:

- the coding concept of conditionals.

- the concept of Boolean logic.

- how to use if, if else and elif conditionals.

- how to use Boolean logic with conditionals.

Tell the students that they 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 analyse the road for any obstacles and signs. To do this in a safe manner, before testing the Agent on the actual road, the students will be coding the Agent in a number of simulated traffic situations. Tell the students that they will be helping by coding the Agent using conditionals and Boolean logic.

Student Activities

Coding Concepts:

- Boolean logic

- Conditionals

Syntax/ Operators: compare ==, indentation

Coding activities: (30 min)

1. Activity 1: Stop and go

Explain to the students that the developer needs their help to write some code to make the Agent understand traffic lights. In part 1, the Agent should keep moving when green blocks are to its left. In part 2, the Agent should stop when there is a red block to its left. In part 3, the Agent should wait for 2 seconds when there is a yellow block to its left and then continue to the gold.

2. Activity 2: Is it left or right?

Explain to the students that 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. Tell the students that this Activity is in two parts.

3. Activity 3: Getting through

Explain to the students that 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.

Q. When talking about Boolean logic what do 1 and 0 represent?

A. True (1) and false (0)

Q. What are conditionals?

A. Conditionals are commands that run code if something is true or false.

Q. What does the AND operator do?

A. The operator checks to see that two conditions are true.

Q. What does the syntax == do?

A. Double equals compares a defined condition against the Minecraft world or coding outcome.

Skills

  • Creativity
  • Critical Thinking