7_resized-554x368.png

Python 101 - Lesson 7

11-13 yrs old

14-18 yrs old

Computer Science

Technology

EMERFENCY RESPONSE While loops and sequences

0
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 while loops.

- the concept of sequences.

- how to use while loops with different conditions.

- how to sequence certain tasks.

Tell the students that they need to help to code the Agent so that it can help in emergency situations by building multiple structures like water barriers, firebreaks, and rebuilding house foundations. Tell the students that the Agent will be used in situations where it is not safe for humans. Tell the students that the Agent will be coded in simulated situations until the software is advanced enough to try the Agent in the real world. Tell the students that emergency workers have already marked out guidelines, using Redstone dust, for the Agent to follow and to know where the structures need to be built.

Student Activities

Coding Concepts:

- While loops

- Sequences

Coding activities: (30 min)

1. Activity 1: Water barrier

Explain to the students that the emergency worker needs their help to write some code to make the Agent build a water barrier to stop the damage that water does during floods. Tell the students that this Activity is in two parts.

2. Activity 2: Firebreak

Explain to the students that the fireman needs their help to develop the Agent to make it build a firebreak to stop the spread of the fire in the simulated area. This firebreak needs to be concrete and one block high and it will be placed on uneven ground. Tell the students that to make this wall they will have to use two while loops, one to make the Agent follow the Redstone dust and another to make the Agent check the elevation of the ground. Tell the students to write two sequences in the code, one where the Agent will place a block to its left and move forward, and another where the Agent will place a block to its left, move up, then place one more block and then move forward. The second sequence is needed when there is a change in terrain elevation.

3. Activity 3: Home reconstruction

Explain to the students that the emergency worker needs their help to develop the Agent to make it build foundations for homes that need to be rebuilt after a hurricane. Tell the students that they will be doing this by coding the Agent to follow a foundations plan laid out on the floor, made from Redstone dust.

Performance Expectations

Ask the students about the skills that they have learned during the lesson, to reinforce the concepts.

Q.  When does a while loop repeat code?

A. When its condition is met.

Q. What is a sequence?

A. A sequence is the order in which we want the computer to execute a group of commands.

Q. What happens if the condition in a while loop is false?

A. It will not run the code.

Q. When would you use a while loop instead of a for loop to make the Agent move forward?

A. You would use a while loop if you did not know the number of blocks that the Agent needed in order to move forward.

Skills

  • Creativity
  • Critical Thinking