[RL46] Grade 4 - Session 6

Session 6: Robot Math – Solving Problems with Code

Session Architect: Muhammad Bilal
Duration: 50-60 minutes


Equipment Required:

  • M3D Robotics kit with the display attachment.
  • Laptops with Scratch pre-installed.
  • Paper and pencils for students to document their math problems.
  • Markers or small objects for creating visual representations of math problems (optional).

Learning Objectives:

  • Understand how coding can automate math calculations.
  • Use Scratch to create code that makes the robot perform math tasks.
  • Display live data such as question numbers or results on the robot’s screen.
  • Develop problem-solving and critical thinking skills through math challenges.

Resources:

Scratch code for the session:
Grade 4 Session 6.sb3 (3.4 MB)


1. Introduction to Robot Math (5 minutes)

Activity:
Introduce the concept of using the robot to solve math problems. Explain that the robot will help them with calculations, displaying the results on its screen, just like a calculator.

Instructions:

  • You can say:

“Today, we’re going to teach our robot to solve math problems! Instead of solving them on paper, we’ll write code to tell the robot what to do, and it will show the answers on its screen. The robot will be your helper. Just like a little calculator, just with a cute face.”

  • Help them recall how they used the “Show Text” block in Scratch to display numbers or results. You may say:

Let’s see how the robot can display numbers and results on its screen. What if we asked it to show the number 5? One way of doing it is:"

“But that is just one number and we know that in solving math problems, our results change depending on the numbers we’re solving and whether we are doing addition or subtraction. So we need something that can change it’s value.”

Use this as an exercise and ask them what can they use here instead of a number. Lead them to the answer that a variable would be the right choice here/

  • Show the students the “Set variable to” block in Scratch, explaining that variables can store numbers, which the robot can then use to calculate and display results.

  • Help them recall how to create a new variable and assign a value to it.

Teacher’s Role:

  • Guide students in understanding how coding can help automate math problems, making math more interactive and fun.
  • Use simple examples to illustrate how the robot will use math input and display answers.

2. Writing Code for Basic Math Problems (15 minutes)

Activity:
Students will use Scratch to code the robot to perform basic arithmetic tasks (addition problems). The robot will add the numbers and display their results on the screen.

Instructions:

  • You can say:

“Now that we know we have to use a variable, let’s use Scratch to write some code that will make the robot solve our problem! We’ll start with simple addition problems. The robot will show the question and then display the answer on its screen.”

Help them write down the steps they need to code in Scratch. You may assist the thinking process as:

“When we are solving an addition problem, the first thing that we need are the number that we are going to add. So, let’s create two variables and store our numbers in them.”

Ask them to create the two variables.


Remind them of the importance of setting the right name for the variable that they are creating.

“Now that we have two variables which can be used for our numbers, we just need to add them. We have to create a block which adds the two numbers and shows the answer on the screen. In addition to that, the robot moves the number of steps equal to the sum of the two numbers.”

  • Guide them as to how they can add the numbers and add them.

  • Recall with them how they can change the value of a variable as well so that they can try adding different numbers and see how the result changes.

  • Let students try coding their own basic math problems.

  • Encourage them to use variables in different blocks where they would normally write the input themselves.

Teacher’s Role:

  • Assist students in writing their math problem code and guide them in understanding how variables store the answer.
  • Encourage students to experiment with different math problems and display them on the robot’s screen.

3. Making the robot do the work (20 minutes)

Activity:
Once students are comfortable with basic problems, they can program the robot so that the students don’t have to change the numbers of the variables manually. The robot will ask them which numbers they want to add and display their sum on the screen.

Instructions:

  • You might say:

“Let’s take it up a notch! So far we have been working with variables ourselves. But we don’t want to do that. It takes too much time and it’s not fun. Do you know what would be fun? If the robot asked us which numbers we wanted to add, and just added them without asking us to change variables. Let’s try that!”

Explain how this blocks asks us something and stores our answer in “answer” named variable. Remind them how they saw it and used it in the starting sessions. You may say:

“It’s really simple. The blocks are named exactly what the robot does. Let’s think what the robot is doing. It asks us something. It waits for our answer and finally. It stores the answer in the variable named “answer”.”"

  • Encourage them to play around with this block with different answers and click on the variable “answer” to see the value it has stored.
  • Once they understand how it works, ask them to program the robot to ask which numbers we want to add, store the answer we give in the variable.

{E5E8BF3B-D4AA-437B-823D-43298B94660A}

Ask them to repeat this for the second number as well. Once they have both numbers, they simply need to add them and display the answer using the custom “Show Text” block in the M3D category.

The final code will look like this:

Encourage them to play around with different combinations and check if the robot is giving the correct answer.

Teacher’s Role:

  • Guide students as they incorporate “Ask and wait” block into their math problem code, helping them understand the block works and automates the process.
  • Provide support as they test and adjust their code.

4. Trying different conditions and operations (15 minutes)

Activity:
After completing the guided tasks, students will try to add conditions to check if their answer is even or odd. They will choose their own math problems and code the robot to solve them.

Instructions:

  • You can say:

“That’s great! We have made our own working calculator with this robot. But our robot is very smart. It can do a lot more than just solving the math problem. Our answer can be either even or odd. Let’s see if our robot can tell which one it is”.

You can start a discussion on the basic condition which helps us identify if a number is even or not. The basic rule is that if the number is divisible by 2 i.e. if the remainder is zero, it is even. Otherwise it is not.

Once they understand the idea behind it, they can make the code using this operator called “mod” which divides two numbers and gives the remainder as the answer:

{B569FC0F-9ED9-4ECC-A64B-D1FCAD5DF165}

  • Explain to them how this operator works similar to the division operator, but instead of the answer, it gives us the remainder.
  • Encourage them to solve a division problem on paper i.e. 25 divided by 5. Help them identify which part is our answer and which part is our remainder.
  • Once that is done, help them connect the idea of how they need to check the remainder of their problem’s answer when it is divided by 2. If the remainder is zero, the number is even. Otherwise it is odd.

1.They can use the code they just made:

  1. Then, to check the answer with the following blocks:

{2DB8C4D0-5FEC-462F-BAB6-855F01CCE51B}

  1. Their final code will be:

Teacher’s Role:

  • Encourage creativity and problem-solving as students create their own math challenges.
  • Provide guidance if students need help with writing their code or setting up the new conditional blocks.

5. Reflection and Wrap-Up (5 minutes)

Activity:
Gather the students to reflect on their experience coding math problems. Let them share their favorite challenges and discuss how coding helped automate the math.

Reflection Questions:

  • “What was the most fun part about coding the robot to solve math problems?”
  • “Was it easier or harder than doing math on paper?”
  • “How did coding help you solve multiple problems quickly?”

Teacher’s Role:

  • Lead the reflection discussion, helping students understand how coding can be a tool for solving real-world problems like math.
  • Celebrate their creativity and coding achievements.

Learning Outcome:

By the end of the session, students will understand how coding can automate math calculations. They will have written code to solve and display math problems, and created their own math challenges for the robot.

Make it move as well

Move too! Also, see if you can give an exploratory activity to include conditionals as well