Showing posts with label Fractions. Show all posts
Showing posts with label Fractions. Show all posts

Sunday, August 10, 2014

Solutions: Modular Programming with Squares on Pro-Bot

This is a subset of solutions for the assignment Modular Programming with Squares. This is just one way of coding the solutions, there are multiple correct solutions for the same.


Breaking Down Squares


1.  The shape is a square. It can drawn using the code:
Rpt 4 [    
Fd 12
Rt
]




2.  The above square needs to be divided into two equal parts. You can do this with a horizontal or vertical line across the middle or divide the square along the diagonal. The solution below divides the cake along the horizontal line
across the middle.
Rpt 4 [
Fd 12
Rt
]
Fd 6
Rt
Fd 12

3.  The square now needs to be divided into quarters. Two possible solutions, along the diagonals or using horizontal & vertical lines. The solution below divides the cake along the horizontal & vertical lines.
Rpt 4 [
Fd 12
Rt
]
Fd 6
Rt
Fd 12
Bk 6
Lt
Fd 6
Bk 12

4.  Here is another way to divide the cake into quarters, along the diagonals.
Rpt 4 [
Fd 12
Rt
]
Rt 45
Fd 17
Lt 135
Fd 12
Lt 45
Bk 17

5.  You need to divide the 12 x 12 cake into 9 equal pieces in this case.  Each slice is going to be 4cm x 4 cm.  Here is a solution using Nested Loops.
Rpt 4 [
Fd 12
Rt
]
Rpt 2 [
Rpt 2 [
Fd 4
Rt
Fd 12
Bk 12
Lt
]
Fd 4
Rt
]


Building Up with Squares as the Basic Building Blocks


1.  The square can be drawn using the code:
Rpt 4 [
Fd 6
Rt
]

2.   Here is the code for the rectangle drawn without using Nested Loops:
Rpt 4 [
Fd 6
Rt
]
Fd 6
Rpt 4 [
Fd 6
Rt
]
Fd 6
Rpt 4 [
Fd 6
Rt
]

3.  As seen from the code above, there is a repeating pattern. After drawing each square, you need to move to the starting position for the next square. The above code can be rewritten using Nested Loops as:
Rpt 3 [
Rpt 4 [
Fd 6
Rt
]
Fd 6
]


4. & 5.  To draw the large square that is double the size of the small square, different techniques can be employed. The easiest is to start from the midpoint of the figure. Each time, draw the small square and then turn 90 degrees to the right. Here is the code that uses Nested Loops.

Rpt 4 [
Rpt 4 [
Fd 6
Rt
]
Rt
]


Solutions to the Hopscotch figure:















Rpt 3 [      // Start drawing the rectangular part of the hopscotch from bottom left corner
Rpt 4 [
Fd 6
Rt
]
Fd 6
]
Rt             // Here, you want to try and get to the midpoint of the large square
Fd 3         // 3 cm from the top of the rectangle to the midpoint of large square
Lt
Fd 6         // You have reached the midpoint of the large square now
Rpt 4 [     // Now draw the large square using the previously written code for the same
Rpt 4 [
Fd 6
Rt
]
Rt
]

Breaking Down & Building Up: Modular Programming with Squares on Pro-Bot

We have already worked on drawing squares using Pro-Bot. We used Repeat Loops to create a square in our previous assignment here

Now, let’s work a bit more with squares, first breaking it down into smaller parts and then building up compound figures using squares as our basic building blocks.


Computer Science concepts involved:   Sequential programming, Repeat loops, Nested Loops, Modular programming

Math concepts involved:   Polygons (squares, rectangles), Measurement, Fractions, Compound figures, Angles

Grade levels:   3, 4, 5

Hours required:   2 or more


Breaking Down Squares

1.   You have spent your Sunday afternoon at home baking a delicious chocolate cake. You baked the cake in a square pan that measures 12 cm long on each side. What shape is your cake when you look at it from above? Can you draw this shape using Pro-Bot? 
2.   You plan to share the cake with 2 of your friends. You cut the cake into equal parts for yourself and your friends. Using Pro-Bot can you draw a figure to represent your cake and how you would cut it? What fraction of the cake would each person get? 
3.   One more friend comes along. So, you decide to cut the cake into equal parts for yourself and your 3 friends. Using Pro-Bot can you draw a figure to represent your cake and how you would cut it? What fraction of the cake would each person get now? 
4.   How many different ways can you think of to cut the cake into 4 equal parts? Using Pro-Bot, draw figures to represent each case. What shapes are the fractions in each case? 
5.   Your friend says that a single serving of cake should be no larger than 4 cm x 4 cm in size. How would you cut the cake to get slices of this size? Using Pro-Bot, draw a figure to represent your cake and how you would cut it in this case.  How many pieces can you cut the cake into?


Building Up with Squares as the Basic Building Blocks


1.   Use Pro-Bot to draw a square of sides 6 cm each. (Remember to use Repeat Loops for drawing the square).

2.   Now, let’s create a rectangular shape with the following dimensions, using the above 6 cm square as our building block:  
Length  =  3 x length of one side of the square 
Width  =  length of one side of the square 

Can you write a program for Pro-Bot to draw this figure, using the program for the 6 cm side square that you wrote earlier? 

























  

3.   Can we use Nested Loops to draw the above figure? Explain why.

4.   Next, let’s create a bigger square with the following dimensions:       
Side of big square  =  2 x Side of the 6 cm square

Can you write a program for Pro-Bot to draw this figure, using the program for the 6 cm side square that you wrote earlier? 



















5.   Can we use Nested Loops to draw the above figure? (Tip: It is easier to start drawing from the midpoint of the figure while using Nested Loops.)


Here is a set of possible solutions to the above assignments.


Modular Programming


From the two examples above, you can see how a small module that performs one distinct function (in this case, our program to draw the 6 cm side square) can be used to build bigger components. The big components that we created in turn can work as modules for an even bigger program. 

This activity provides a quick peek into modular programming, a principle that is widely used in most programming languages. Modular programming is the process of dividing a program into smaller, separate sub-programs. 

Let's look at an example that is familiar to you. Do you play with Lego construction sets? A lot of times, when you buy Lego sets, the box comes with several small bags inside of it, each labeled with a number. There will be an instruction booklet that tells you how to use the tiny pieces inside each bag to create a small component of the big toy that you plan to make. Once you have created a couple of such components from the different bags, the book tells you how to put them together to create a slightly bigger unit... and the process goes on till you get to the completed product... 

Just like you build large Lego toys using multiple smaller units, each of which in turn was made of still smaller pieces, we can build large programs using smaller components or modules, which in turn can be made of even smaller modules.

So, why do we prefer to use modular programming rather than develop one giant program? Here are some reasons...

  • Reusing the code. You write a module just once, but it can be used multiple times by different programs. In the above examples, you wrote the code for the 6 cm side square just once, but you used it multiple times while developing two different programs. 
  • Breaking up the program into smaller modules makes it easier to maintain the program. For example, if you decide to change the larger programs to be using 10 cm side squares, all you need to do is make one change in your smallest module for the square from 6 cm to 10 cm. The change is easily reflected in all the bigger modules that use it. 
  • It is easier to find and fix errors in smaller modules. 
  • Smaller modules ensure that the code is short, simple, easy to read and understand.
  • It makes it easier for different people to develop different modules independent of each other. You could have one person write the program for the 6 cm square, another person write the program for the rectangle using the 6 cm square and yet another person write the program for the bigger square. And then, all of these could be put together to create an even bigger program as seen below...


1.   Elmo and his friends are planning to play hopscotch. Elmo suggests a figure that looks like the following and draws it out using Pro-Bot. Each square in this hopscotch figure has 6 cm sides. Can you write a program for Pro-Bot to draw this figure? Can you re-use the programs that you wrote above to draw this figure?





















  • You can also store each of the programs that you wrote above (for the rectangle and the big square) as separate Procedures and call them from your Main program for Pro-Bot to draw the hopscotch figure.




A Different Approach to the above Program



If you have an even number of students/ groups working on this project, you could try the following exercise with the hopscotch figure:

  • Divide the class into an even number of teams, so that each team pairs with another.  Let’s call the teams in each pair as Team A & Team B.
  • Team A in each pair would create the procedure for the big square. Team B in each pair would create the procedure for the large rectangle.
  • The pairs then exchange the Pro-Bots.
  • So now, each team has the procedure that they created themselves plus the procedure that was created by the other team. They do not need to know how the other team created their procedure;  they just need to know what it does (a black box).
  • Each team shall give clear instructions to their partner team as to how their procedures work. They can even draw a picture to show what their procedure would create, specifying the start & end points, and give it to the other team.
  • Each team now integrates the procedures/modules (their own work + the other team’s work) to create the required final result & test it.
  • This could be a good activity to introduce the kids to the concepts of real world engineering projects: division of work among different teams, testing & integration of results.



Monday, August 4, 2014

Applying Fractions to Polygons

In this programming assignment, we shall draw polygons and divide them into fractions using Pro-Bot. This assignment can be a follow-up to the one where we learned to draw various polygons using Pro-Bot. We shall use sequential programming for drawing irregular polygons and Repeat Loops to draw regular polygons. Next, we shall divide the polygons into specified fractions using Pro-Bot as our drawing tool.


Computer Science concepts involved:   Sequential programming, Repeat loops

Math concepts involved:   Polygons (regular and irregular), Linear & Angular Measurements, Fractions, Area, Congruence

Grade levels:   3, 4, 5

Hours required:   2 or more



Polygons


In geometry, a polygon refers to a closed, two-dimensional figure formed by a set of straight line segments. The straight line segments are called the polygon’s edges or sides, and the points where two edges meet are the polygon's vertices or corners.

If all edges are equal and all angles are equal, then it is a regular polygon. Else, it is an irregular polygon.


Square:

  1. Use Pro-Bot to draw a square of sides 8 cm. Each interior angle is 90 degrees.
  2. Divide the square horizontally into quarters (1/4) using Pro-Bot as your drawing tool. 
  3. Divide the square vertically into quarters (1/4) using Pro-Bot as your drawing tool.
  4. Divide the square into 4 equal squares, using Pro-Bot as your drawing tool. What fraction of the large square does each small square occupy?
  5. Divide the square into 2 equal sized triangles, using Pro-Bot as your drawing tool. Are the triangles congruent? 

Rectangle:

  1. Use Pro-Bot to draw a rectangle of sides 4 cm and 6 cm. Each interior angle is 90 degrees.
  2. Divide the rectangle into thirds along the longer side using Pro-Bot as your drawing tool. 
  3. Divide the rectangle into halves along the shorter side using Pro-Bot as your drawing tool.
  4. Divide the rectangle into quarters using Pro-Bot as your drawing tool.
  5. Divide the rectangle into 2 triangles along a diagonal, using Pro-Bot as your drawing tool. Are the triangles congruent? Are they equal in area?

Rhombus:

  1. Use Pro-Bot to draw a rhombus of sides 6 cm. One pair of opposite interior angles is 60 degrees each and the other pair is 120 degrees each. 
  2. Divide the rhombus into thirds, using Pro-Bot as your drawing tool.
  3. Divide the rhombus into sixths (1/6) using Pro-Bot as your drawing tool. Are the fractions congruent shapes? Are they rhombuses? If not, what shapes are they?

Parallelogram:

  1. Use Pro-Bot to draw a parallelogram of sides 4 cm and 6 cm. One pair of interior opposite angles is 45 degrees each and the other pair is 135 degrees each (Remember that for a parallelogram, opposite angles are equal).
  2. Divide the parallelogram into 2 equal parallelograms, using Pro-Bot as your drawing tool. What fraction of the original parallelogram is occupied by the smaller ones?
  3. Considering that the minimum dimension that can be provided by Pro-Bot is 1 cm, what is the maximum number of smaller parallelograms that you can divide up the larger parallelogram into, using Pro-Bot as your drawing tool? What fraction of the larger parallelogram is occupied by each of the smaller units?

Equilateral Triangle:

  1. Use Pro-Bot to draw an equilateral triangle of sides 6 cm. Each interior angle is 60 degrees.
  2. Divide the triangle into 2 equal triangles, using Pro-Bot as your drawing tool.
  3. Divide the triangle into 3 triangles of equal area, using Pro-Bot as your drawing tool. You can do this in a couple of ways: 

  • Divide one side of the triangle into 3 equal parts. Then draw lines connecting the opposite vertex to the two points that trisect the side. 
  • Find the centroid: If you draw a line from each vertex to the midpoint of the opposite side, the point at which all three lines meet is the centroid. Draw a line from each vertex to the centroid to divide up the triangle into 3 equal triangles.

Thursday, July 31, 2014

Programming Tangrams using Pro-Bot

This is a comprehensive programming project spanning over 4 hours, that aims to teach the key concepts that can be introduced via Pro-Bot (namely sequential programming, Repeat Loops and Procedures) while applying them to geometrical concepts that are covered in the classrooms. 
We shall make use of the famous tangram puzzles for this assignment. Let us take a quick look at what tangrams are and then talk about how to write programs for Pro-Bot to create them.   


Tangrams:


The tangram is a dissection puzzle consisting of seven flat shapes, called tans, which are put together to form shapes. The objective of the puzzle is to form a specific shape (given only an outline or silhouette) using all seven pieces, which may not overlap. It is reputed to have been invented in China and is one of the most popular dissection puzzles in the world.(Wikipedia)

Research shows that tangrams are helpful for developing an intuitive sense of geometry and developing visual-spatial skills. Tangrams have both geometric and artistic features. They help with classifying shapes, understanding the spatial rotation of shapes, understanding fractions, understanding the properties of various shapes including angles, area, perimeter, etc.


















To create a tangram, a square is divided up into 16 equal squares. Diagonal lines are drawn to produce 7 shapes. The seven pieces (numbered in the above picture) are:
2 large right triangles  (A, D)
1 medium right triangle (E)
2 small right triangles (C, G)
1 square (F)
1 parallelogram (B)

Some of the properties of the tans (puzzle pieces) are: 
  1. The large triangle is twice the area of the medium triangle. 
  2. The medium triangle, the square, and the parallelogram are each twice the area of a small triangle. 
  3. Each angle of the square measures 90 degrees. 
  4. Each triangle contains a 90 degree and two 45 degree angles (isosceles right triangles). 
  5. The parallelogram contains two 45 degree and two 135 degree angles. 
The relationships among the pieces enable them to fit together to form many figures and arrangements.



Now that we have taken a look at tangrams, let us write programs for Pro-Bot to draw the tangram puzzles.

We shall start by writing simple sequential programs to generate the seven individual puzzle pieces of the tangram. Then, we shall modify some of those programs to use Repeat Loops. We may also take a look at developing a generalized algorithm for drawing regular polygons (polygons with all sides equal and all angles equal) using Pro-Bot. Next, we shall learn to store programs for the individual puzzle pieces as Procedures in Pro-Bot’s memory, and then “call” them within programs that draw more complex tangram puzzles. 

Note that the programming questions are given in the order of increasing complexity, starting with simple polygons, then combining two or three of those to create compound figures and finally, creating complex tangram puzzles that use all seven pieces. 



Programming Assignment: 


Given a large square of sides 14 cm each, divide it into sections as shown in the figure below and create the 7 pieces of a tangram. Find the dimensions for each of the seven pieces. Make suitable modifications to the dimensions so that they can be used by Pro-Bot. Write programs to draw each piece separately using Pro-Bot. Finally, draw simple/complex tangram puzzles using Pro-Bot, making use of the programs that you wrote for the 7 tans/puzzle pieces.

Computer Science concepts involved:  Sequential programming, Repeat loops, Procedures/Sub-routines

Math concepts involved:  Polygons (Quadrilaterals, Triangles), Measurement, Fractions, Decimals, Rounding of decimal numbers, Angles, Trigonometry, Area, Perimeter, Congruence, Symmetry

Grade levels:  4, 5, 6

Hours required:  4 or more



Lesson Plan:

Hour 1:   Introduce Pro-Bot and tangrams. 

Allow the students to get familiarized with the Pro-Bot and its control panel. Introduce tangrams. Find out the dimensions of the 7 pieces in the tangram puzzle. Use sequential programming to create each of the 7 pieces in the tangram.

14 cm side square divided into 16 equal parts, 
with the diagonals drawn to create the seven puzzle pieces
























  • On a piece of paper, draw a square of sides 14 cm each.
  • Divide this 14 cm side square into 16 equal squares and trace all 7 shapes, using the above diagram as your guide.     
  • For the right triangles, either calculate the hypotenuse using the mathematical formula or measure it using a ruler.
  • Find the dimensions of the square and the parallelogram.
  • Can you figure out what fraction of the large square is taken up by each of the seven puzzle pieces?
  • Check to see if the dimensions obtained for the sides of the seven puzzle pieces are whole numbers or decimals. If they are decimal numbers, think about whether decimals can be used with Pro-Bot. If not, how can you adjust these numbers to work with Pro-Bot?
  • Once you have adjusted the dimensions so that they work on Pro-Bot, write programs to draw the puzzle pieces using Pro-Bot.
  • You can see that some of the puzzle pieces are congruent. Hence, you need to write the program only once for each set of congruent shapes.
  • Test your programs on Pro-Bot, one at a time to see if you get the desired results for each shape.



Hour 2:    Introduce Repeat Loops on Pro-Bot.
  • Now that all the puzzle pieces have been drawn using sequential programming, show how the programs for the square and the parallelogram can be rewritten using Repeat Loops in Pro-Bot. 
  • Write programs for drawing a few regular polygons using Pro-Bot (polygons with all sides equal and all angles equal) such as pentagon, hexagon, etc. Show how Repeat Loops can be used to write programs for these figures. Develop a generalized algorithm (a set of steps for solving a problem) for drawing regular polygons using Pro-Bot. 


Hour 3:    Introduce Procedures on Pro-Bot. Draw compound figures that use a subset of the seven puzzle pieces.
  • Store the program for each puzzle piece as a Procedure on Pro-Bot. Since the puzzle pieces would be used multiple times in the project, it makes it easier for you as the programmer, to write the program for each puzzle piece just once, store it as a Procedure and re-use it multiple times.
  • Work on a few compound figures that use a combination of just two or three of the puzzle pieces. Call the procedures for the individual puzzle pieces while writing programs for the compound figures.

A.   Write programs for Pro-Bot to draw the following compound figures that use the square and a small triangle from the tangram. 



























B.   Write programs for Pro-Bot to draw the following compound figures that use the parallelogram and two small triangles from the tangram. 





















C.   Your class is planning to do a gardening project. You have decided to grow spinach in an area measuring 12.5 square feet and carrots in 25 square feet. The two designs that you are considering for the garden are the ones in Question A above. Would you choose the square or the triangle part of the garden for the carrots? If the cost of fencing the garden is $5 per foot, which design would you choose so that the cost of fencing can be minimized.

D.   Your school has decided to pursue more vegetable gardening projects. This time, the plan is to grow tomatoes and peppers in spaces of equal area and carrots in a space that is double the area of tomatoes. The garden designs being considered are the ones in Question B above. Determine which vegetable would go in the parallelogram part of the garden and which ones would go in the triangles. How many square feet each of tomatoes, peppers and carrots can be grown? If the cost of fencing the garden is $5 per foot, which design would you choose so that the cost of fencing can be minimized.

E.   Can you make a trapezoid using just two pieces from the tangram? Write a program to draw your trapezoid using Pro-Bot.

F.   Can you make a parallelogram using just two pieces from the tangram? Write a program to draw your parallelogram using Pro-Bot.

G.   In each of the compound figures that you worked with, can you see the relationship between the angles of the puzzle pieces that allows them to fit together seamlessly?




Hour 4:    Write programs to draw complex tangram figures using Pro-Bot, using all seven puzzle pieces. You can choose either option A or option B.


Option A:
Create geometric shapes using all seven puzzle pieces of the tangram. Write programs for Pro-Bot that uses some of the Procedures for the puzzle pieces to draw the following figures. Compare the areas and perimeters among the complex figures that you create.

A.   Can you make a square that uses all 7 of the tangram pieces? Write a program to draw your square using Pro-Bot.

B.   Can you make a triangle that uses all 7 of the tangram pieces? Write a program to draw your triangle using Pro-Bot.

C.   Can you make a trapezoid that uses all 7 of the tangram pieces? Write a program to draw your trapezoid using Pro-Bot.

D.   Can you make a parallelogram that uses all 7 of the tangram pieces? Write a program to draw your parallelogram using Pro-Bot.

E.   How many squares can you make using some or all of the tangram puzzle pieces?


Option B:

You can find hundreds of artistic tangram puzzles on Google. Choose the designs that are the most interesting to you and work with them. Write programs for Pro-Bot that uses some of the procedures for the puzzle pieces to draw the figures that you choose.

Here is an example. Can you write a program for Pro-Bot to draw this figure, using some of the procedures that you previously created for the tangram pieces?