Minds On

Check the map below

A delivery driver needs to drop off various items at different locations in the local town. Brainstorm what factors need to be considered for when the delivery driver is planning their route?

Record your ideas using a voice recorder, speech-to-text, or writing tool.

A map showing different destinations which are: home, school, library, bank, coffee shop, grocery store, and gym.

Action

Task 1: Efficient Coding

What does the word efficiency mean?

Efficiency means completing a task in the least amount of time, and most productive way possible.

How does efficiency relate to coding?

Efficient coding refers to coding that provides the most concise instructions to allow coding in the least amount of time, and steps that still make sense and achieve the goal.

Why is being efficient in coding valuable and important?

Which is more efficient?

Examine the following two sequences of code – Option A and Option B.

Decide which code is more efficient, and explain why. You do not need to write your own code, just record your thoughts.

Record your ideas using a method of your choice.

This is an image showing a 5x6 grid and the sequence of 2 coding options.

Option A reads: Start program, Move forward – Distance 3, Turn left, Move forward – Distance 2

Option B reads: Start program, Move forward – Distance 5, Turn left, Move forward – Distance 2, Turn left, Move forward – Distance 2

Which option do you think is more efficient?

Press ‘Which is the more efficient option?’ to access how we can determine efficiency

You may notice that although both options A and B accomplish the goal, option A takes less steps to complete, and is therefore more efficient.

Make an Efficient Code

Examine options A and B below for the sequences of code.

Identify the most efficient code and record it using a method of your choice. Justify your thinking.

Option A:

  • Start program
  • Move forward – Distance 2
  • Turn left
  • Move forward – Distance 2
  • Turn left
  • Move forward- distance 2

Option B:

  • Start program
  • Turn right
  • Move forward- distance 2
  • Turn left
  • Move forward – Distance 2
  • Turn left
  • Move forward- distance 4
  • Turn left
  • Move forward- distance 2

Task 2: Loops

Loops are used in coding to improve efficiency. Loops repeat part of the code to decrease the number of steps in the code.

Here is an example of using loops in coding:

An image showing a grid. One square has an apple and there is a robot in another square. Few squares are brown.

A 5 x 6 grid with an apple, a robot, and several brown squares. There is a visual code below the grid that outlines the following steps:

  • Start program

  • Move forward – Distance 2

  • Turn left

  • There is a loop 2 for steps 2 and 3 followed by the step:

  • Move Forward - Distance 2

Now examine the following codes

Code A:

How can you make the code more efficient by adding in loops? Alter the code to add in the loops. Record your ideas using a method of your choice.

A 6 x 6 grid with an apple, a robot and several brown squares. There is a visual code beside the grid that outlines the following steps:

Start program

Move forward – Distance 2

Turn left

Move forward – Distance 1

Turn right

Move forward- distance 1

Turn left

Move forward- distance 1

Turn right

Move forward- distance 1

Turn left

Move forward- distance 1

Turn right

Move forward- distance 1

Turn left

Move forward- distance 1

Code B:

How can you make this code more efficient by adding in loops? Create the code using loops. Record your ideas using a method of your choice.

Start program

Move forward – Distance 2

Turn right

Move forward – Distance 1

Turn left

Move forward- distance 1

Turn right

Move forward- distance 1

Turn left

Move forward- distance 1

Turn right

Move forward- distance 3

Turn right

Move forward- distance 3

Complete the Code Design in your notebook or using the following fillable and printable document.

A 6x6 grid with a robot at its bottom left corner, an apple one square up from the bottom right corner and several brown squares.

Press the ‘Activity’ button to access Code Design. 

Consolidation

Task 1: Coding Challenge

Create a route of your choice that uses loops within the code.

Use your imagination and be creative!

Use fictional directions and routes.

Decide on the starting and ending points.

It should allow for the opportunity to include loops in the code.

Record your ideas using a method of your choice.

Task 2: Think about your learning

Answer the following questions using a method of your choice:

  • Why is it important for code to be efficient?
  • What is something new that you learned about coding?

Reflection

As you read through these descriptions, which sentence best describes how you are feeling about your understanding of this learning activity? Press the button that is beside this sentence.

I feel...

Now, record your ideas using a voice recorder, speech-to-text, or writing tool.

Connect with a TVO Mathify tutor

Think of TVO Mathify as your own personalized math coach, here to support your learning at home. Press ‘TVO Mathify’ to connect with an Ontario Certified Teacher math tutor of your choice. You will need a TVO Mathify login to access this resource.

TVO Mathify (Opens in a new window)