Showing posts with label Programming for kids. Show all posts
Showing posts with label Programming for kids. Show all posts

Monday, September 28, 2015

Draw Polygons & Compound Figures with a Given Area using Pro-Bot

Can you program the Pro-Bot to draw polygons & compound figures with a given area?

This, again, is an assignment that I designed for our Grade 3 students. It relates to the Common Core Math Standards: Geometric measurement: understand the concepts of areaFor this exercise, I highly recommend using graph paper, as it provides a helpful medium for the kids to work out the math problems. Provide at least one sheet per child to work out the problem and then additional sheets as required for the groups to draw the figures using Pro-Bot. Here is a link to a graph paper with 1 cm grid in PDF format; you can make copies for the students to draw on using the Pro-Bot.


Area of a Figure


The area of a figure is the number of squares required to cover it completely, and is specified in square units. Here's an article from math.com that gives a quick overview of the topic.

How do you calculate the area of a given figure? You add the number of squares needed to cover the entire figure. Say you are given a square with sides 3 cm each. You need 9 squares of sides 1 cm x 1 cm to cover it completely. The area of the square is 3 x 3 = 9 sq.cm. Similarly, a 5 cm x 6 cm rectangle has an area of 30 sq.cm.

Can we do the reverse too? Given the area, can we come up with the design for a figure with that area? 

Let's look at an example. Given an area of 9 sq.cm, how many polygons can we draw? We can draw multiple polygons, all with the exact same area of 9 sq.cm. In the figure below, you can see:
  • a square 3 cm x 3 cm,
  • couple of polygons with an area of 9 sq.cm.

Can you think of more polygons with an area of 9 sq.cm?

Let's now look at a scenario that shows the practical application of the concept of area. And then program the Pro-Bot to draw a few polygons with a given area.

Programming Assignment

You work for an architectural firm, and have been asked to design a single story house with a floor area of 100 square meters (roughly 1076 sq.ft.) You are to draw and present various designs for the floor plan.

  1. How many different ways can you draw the floor plan with an area of 100 sq.m.? Provide at least 2 to 3 different designs and make a rough drawing of the figures that you come up with.
  1. Classify the figures that you came up with into the various classes of polygons based on the number of sides.
  1. Program the Pro-Bot to draw them on graph paper. Use 1 sq.cm. to represent 1 sq.m. in your figures.
  1. Assume that the plot of land available for the construction, is a rectangle that is 15 m long and 8 m wide. Can you provide a design(s) to build a 100 sq.m. building in this plot? Program your Pro-Bot to draw the design. 
  2. You can program the Pro-Bot to draw other figures with the 100 sq.m. area. Or explore other figures with different areas.

Draw Polygons with a Given Perimeter using Pro-Bot

Can you program the Pro-Bot to draw polygons & compound figures with a given perimeter?

This is an assignment that I designed for our Grade 3 students. It relates to the Common Core Math Standards: Geometric measurement: recognize perimeterFor this exercise, I highly recommend using graph paper, as it provides a helpful medium for the kids to work out the math problems. Provide at least one sheet per child to work out the problem and then additional sheets as required for the groups to draw the figures using Pro-Bot. Here is a link to a graph paper with 1 cm grid in PDF format; you can make copies for the students to draw on using the Pro-Bot.


Perimeter of a Figure


A perimeter is a path that surrounds a two-dimensional shape. The term may be used for either the path or its length. It can be thought of as the length of the outline of a shape. (Wiki)

How do you calculate the perimeter of a given figure? You add the length of all the sides of that figure that form its outline. Say you are given a square with sides 3 cm each. The perimeter of the square is 3 + 3 + 3 + 3 = 12 cm. Similarly, a 5 cm x 6 cm rectangle. has a perimeter of 5 + 6 + 5 + 6 = 22 cm. 

Can we do the reverse too? Given the perimeter, can we come up with the design for a figure with that perimeter? 

Let's look at an example. Given a perimeter of 12 cm, how many polygons can we draw? We can draw multiple polygons, all with the exact same perimeter of 12 cm. In the figure below, you can see:
  • a square 3 cm x 3 cm,
  • a rectangle 5 cm x 1 cm,
  • a rectangle 4 cm x 2 cm,
  • a hexagon with sides 3 cm, 1 cm, 1 cm, 1 cm, 4 cm, 2 cm

Can you think of more polygons with a perimeter of 12 cm?

Let's now look at a scenario that shows the practical application of the concept of perimeters. And then program the Pro-Bot to draw a few polygons with a given perimeter.

Programming Assignment

Old McDonald lives on a farm and has lots of animals. He would like to build a new set of fences to keep his cows safe.

  1. If Old McDonald has 36 meters of fencing available, how many different ways can he build an enclosed area for his cows? Make a rough drawing of the figures that you come up with and then program the Pro-Bot to draw them on graph paper. Use 1 cm to represent 1 m in your figures.
  2. Classify the figures that you came up with into the various classes of polygons based on the number of sides.
  3. Write programs for Pro-Bot to draw at least 3 of the figures that you came up with.
  4. Suppose Old McDonald has only 35 meters of fencing available, but wants to build a square or rectangular fence using all of that fencing material. Would it be possible for him to build it? Why or why not? 
  5. You can program the Pro-Bot to draw other figures with the 36 cm perimeter. Or explore other figures with different perimeters.


Tuesday, July 29, 2014

Solutions: Art with Pro-Bot - A Dancing Robot

The picture of the Dancing Robot consists of 2 main parts - the body and the head, both of which are squares and can be drawn using Repeat Loops. The interesting part is that the limbs of the robot can also be drawn as part of the Repeat Loop for drawing the body.




Let's look at the code for drawing the body of the robot first. Please keep in mind that depending on the starting point and the direction in which Pro-Bot is facing, you can have different ways of drawing this figure.


Here is one way of drawing it, refer to the figure on the right for the Starting point.

    Rpt 4 [
    Fd 10       // body + limb = 10 cm
    Bk 4          
    Rt        
    ]




Now, let's try to draw the neck and the head of the robot. Again, the following code is just one of the possible solutions.

Starting from the neck and going up,

    Fd 1          // 1 cm long neck
    Lt
    Fd 1
    Rt
    Rpt 4 [      // Repeat loop to draw the square for the head
    Fd 2
    Rt
    ]
 

Combining the two pieces of code above, we have the final program to draw our dancing robot:
 
    Rpt 4 [      // Start by drawing the body of the robot
    Fd 10    
    Bk 4          
    Rt        
    ]
    Fd 3         // After drawing the body, get to the start point for drawing the neck
    Lt
    Fd 1          // Draw the 1 cm long neck
    Lt
    Fd 1
    Rt
    Rpt 4 [      // Draw the square for the head
    Fd 2
    Rt
    ]



Art with Pro-Bot: A Dancing Robot



Write a program to draw the following figure of a dancing robot. All measurements are in centimeters. 

Do you see patterns in the figure that keeps repeating? How many Repeat Loops can you use in the program for this robot?

The sides of the body are 6 cm long, the limbs are 4 cm each. The neck is 1 cm long and the head is a square measuring 2 cm on each side.






















This assignment can be used as a follow-up to drawing squares with Repeat Loops. The body of the robot can be written using a Repeat Loop as can the head. 

The children in the classes that I taught drew multiple ones of these and drew in other features by hand. Imaginations ranged all the way from groups of ballet dancers to soccer players to swimmers (with the picture rotated to the right)...

Click here to see one set of solutions.

Solutions: Art with Pro-Bot - Snails

Let's create four procedures for the squares of sides 2 cm, 4 cm, 8 cm and 12 cm. We could store them in Proc 1, Proc 2, Proc 3 and Proc 4.


Here is one way of writing these procedures:

// Proc 1 - procedure for drawing 2 cm side square
Rpt 4 [
Fd 2
Rt
]


// Proc 2 - procedure for drawing 4 cm side square
Rpt 4 [
Fd 4
Rt
]


// Proc 3 - procedure for drawing 8 cm side square
Rpt 4 [
Fd 8
Rt
]


// Proc 4 - procedure for drawing 12 cm side square
Rpt 4 [
Fd 12
Rt
]



Next, we shall use the above procedures to draw the snails. Keep in mind that this is just a subset of the possible solutions. Both the procedures as well as the following programs can be written in multiple ways.

Program for the small snail as written from Main:


Proc 1
Rt
Fd 4
Lt
Proc 2
Rt
Fd 1
Lt
Proc 1


Program for the large snail as written from Main:


Proc 2
Rt
Fd 8
Lt
Proc 4
Rt
Fd 2
Lt
Proc 3
Rt
Fd 2
Lt
Proc 2



Art with Pro-Bot: Snails

Write a program for Pro-Bot to draw a picture of snails as shown below. 

The bigger snail has a square head of side 4 cm and a 4 cm long neck. The outer square of its shell has 12 cm sides, the middle one 8 cm & the inner one 4 cm. The smaller snail has a square head of side 2 cm & a 2 cm long neck. The outer square of its shell has 4 cm sides & the inner one 2 cm.


Remember to use Repeat Loops when you write programs for drawing squares using Pro-Bot. We shall reuse the pattern for the larger snail's shell from the Repeat Loops Maze project. 



Once you are done drawing the body of the snail using Pro-Bot, you can draw in other features such as eyes, mouth, antennae, etc. You can also draw in more features in the background to make your picture more interesting. 

























I designed this project to let the children practice Repeat Loops and Procedures in a fun way using Pro-Bot. Repeat Loops were used for drawing the squares. The 4 cm side square was stored as a procedure and used multiple times in the figure. We did the same for the 2 cm side square as well. 


Here is a set of solutions.


Solutions: Art with Pro-Bot - Snowmen

Let's first write the programs for the squares of sides 6 cm, 4 cm and 2 cm.  We shall store these are three different procedures, say in Proc1, Proc2 and Proc 3.

Here is one way of writing the programs:


Proc 1      // procedure for 6 cm side square
Rpt 4 [
Fd 6
Rt
]


Proc 2      // procedure for 4 cm side square
Rpt 4 [
Fd 4
Rt
]


Proc 3      // procedure for 2 cm side square
Rpt 4 [
Fd 2
Rt
]



Now let's draw the small snowman using the above procedures. From Main, the program shall be written as:


// Program for the Small Snowman


Proc 2
Fd 4
Rt
Fd 1
Lt
Proc 3


You can use the above procedures for drawing the large snowman as well. From Main, the program for the large snowman can be written as:


// Program for the Large Snowman


Proc 1
Fd 6
Rt
Fd 1
Lt
Proc 2
Fd 4
Rt
Fd 1
Lt
Proc 3









Art with Pro-Bot: Snowmen


Write a program for Pro-Bot to draw some snowmen using three different sized squares. The squares have sides measuring 6 cm, 4 cm and 2 cm. Remember to use Repeat Loops while programming the squares. Draw in other features by hand for the snowmen (eyes, nose, mouth, scarf, hat, etc.) after you draw the snowmen’s bodies using Pro Bot.

























I designed this "art" project to allow the children to practice using Procedures as well as Repeat Loops. The squares were all drawn using Repeat Loops. The 4 cm side square and the 2 cm side square were stored as Procedures and reused in the figures. In fact, they can be even reused for other projects, like the Snails.

Some of the children imagined these to be wedding cakes instead of snowmen and drew in features accordingly... There was even a picture of a snowman eating a two-tiered cake.


Here is a set of solutions to the above.



Solutions: A Maze Using Repeat Loops in Pro-Bot

1.  Assuming that you start at the leftmost corner and facing forward, here is a possible solution for the maze given in the figure:


Rpt 3 [
Fd 12
Rt
]
Fd 2
Rt
Rpt 3 [
Fd 8
Lt
]
Fd 2
Lt
Rpt 3 [
Fd 4
Rt
]



2.  Assuming that you start at the leftmost corner and facing forward, here is a possible solution for the maze given in the figure. The program is same as the one above, with an addition of two more instructions at the end, to draw the solid line at the bottom of the maze.


Rpt 3 [
Fd 12
Rt
]
Fd 2
Rt
Rpt 3 [
Fd 8
Lt
]
Fd 2
Lt
Rpt 3 [
Fd 4
Rt
]
Bk 2
Fd 10


A Maze using Repeat Loops in Pro-Bot: Assignment 2

(1)   Here is a maze that combines parts of 3 squares. All measurements are in centimeters.

The outer section has 12 cm sides. The middle section has 8 cm sides and the inner-most section has 4 cm sides.

Each of the partial squares can be drawn using Repeat Loops in Pro-Bot, as we saw in our previous assignment. Can you write a program for Pro-Bot to draw this figure?

Your program will have three sets of Repeat Loops as well as other instructions in between. So far, all of the programs that you wrote for Pro-Bot used either a sequence of simple instructions or stand-alone Repeat Loops. This is a good example to see a mix of both in a program.






















(2)   This is a follow-up exercise to the above maze. All measurements are in centimeters.

The outer section has 12 cm sides. The middle section has 8 cm sides and the inner-most section has 4 cm sides. Each of the sections can be drawn using Repeat Loops in Pro-Bot, as we saw in our previous assignment.

Can you write a program for Pro-Bot to draw this figure?

Can you modify the previous program for the maze, adding just a couple lines of code, for Pro-Bot to draw this figure?

This is a good exercise in modifying or editing an existing piece of code to create a new functionality.






















Here is a set of solutions.

Solutions: Repeat Loops for Drawing Squares with Pro-Bot

Let’s write down the code for drawing a square with sides 6 cm each, using Pro-Bot. 

Assuming you start at the left most bottom corner and you are facing forward, the square can be drawn using the following code:


  

   Fd 6
   Rt
   Fd 6
   Rt
   Fd 6
   Rt
   Fd 
   Rt     // optional




Do you see a repeating pattern in the code?

Circle the part in the code that repeats. Circle the corresponding part in the picture as well.

Write down the part of the code that repeats.

   Fd 6
   Rt


How many times do we repeat the pattern?

   4 times

Can you now rewrite the code for the above square using a Repeat loop?

   Rpt  4  [                                 
   Fd 6
   Rt
   ]


How many lines of code were there in your first version, without the Repeat Loop?

    8 lines

How many lines of code are there in your new version using the Repeat Loop?

    4 lines

By how much did you reduce the number of lines of code in your new version?

    4 lines

Can you now write a program for Pro-Bot to draw a square of sides 10 cm using a Repeat Loop?

   Rpt  4  [                                 
   Fd 10
   Rt
   ]



Part of a Square

The following figure looks like a square with one side of it removed. Each side measures 6 cm. Can you write a program for Pro-Bot to draw it using a Repeat Loop? 

Assuming you start at the left most bottom corner and you are facing forward, the pattern can be drawn using the following code:



Rpt 3 [
Fd 6
Rt
]















Repeat Loops for Drawing Squares with Pro-Bot

Let’s write down the code for drawing a square with sides 6 cm each, using Pro-Bot. 





















Do you see a repeating pattern in the code?

Circle the part in the code that repeats. Circle the corresponding part in the picture as well.

Write down the part of the code that repeats.




How many times do we repeat the pattern?


Can you now rewrite the code for the above square using a Repeat loop?

Rpt  _________   [                                 




]



How many lines of code were there in your first version, without the Repeat Loop?


How many lines of code are there in your new version using the Repeat Loop?


By how much did you reduce the number of lines of code in your new version?


Can you now write a program for Pro-Bot to draw a square of sides 10 cm using a Repeat Loop?


Rpt  _________   [                                 




]



Part of a Square

The following figure looks like a square with one side of it removed. Each side measures 6 cm. Can you write a program for Pro-Bot to draw it using a Repeat Loop?