Showing posts with label Real world problem. Show all posts
Showing posts with label Real world problem. Show all posts

Tuesday, April 21, 2015

A Drive through the Zoo: Learning about Angles using Pro-Bot

My child's class started learning about angles about a week ago. And the teacher requested me to design an exercise for Pro-Bot that will introduce the idea of angles. As the kids are very new to the concept, I wanted to keep this one fairly simple, while still using a mix of acute, obtuse and right angles.

A trip to the zoo is almost always part of our field trips every school year. The zoo in our city happens to have buses that drive along the various points of interest/ themed animal enclosures. I felt that the turns made by the bus in this familiar setting of the zoo, might be a good way to introduce angles.

In this exercise, a scaled down version of the bus route, provides the path for Pro-Bot to drive on. As the Bot drives along the path, it is required to make angular turns at each point. I have provided the angular measurements required in degrees and distances in centimeters. The bus travels in a loop, the directions are shown using arrows. Note that the map below is not drawn to scale.





Based on the above map, write a program for Pro-Bot to drive along the following paths, assuming that the Pro-Bot is facing in the forward direction:
  1. The path from the Entrance of the zoo to the African Savanah. How many turns did the Pro-Bot make? Were the angles acute, obtuse or right angles?
  2. To continue from the African Savanah (where you stopped before), to the Elephants enclosure, how many degrees did the Pro-Bot turn? 
  3. Program the path from the African Savanah to the Raptors. How many turns did the Pro-Bot make? Were the angles acute, obtuse or right angles?
  4. Continue the path from the Raptors to the Kids' Play Area. Did you use acute, obtuse or right angles for the turns?
Alternatively, the kids can be asked to program the entire bus route as a single program, marking the types of angles used along the way.


Saturday, April 11, 2015

A Food Chain: Made from Scratch

Here is a Scratch project that my 9-year-old put together, depicting a Food Chain in the Northern Temperate Forests. An avid lover of animals, this project combining learning in two areas, was a very fun one for him. I loved the fact that he could create a presentation about an ecosystem, while combining his learning with art, storytelling and programming. A good example of an interdisciplinary project...

This project took him a few weeks to create, including the time for the initial research about the ecosystem. We went through the project in small steps, designing the various stages... deciding on the characters in the food chain, the order in which they appear, special effects if any, etc. As you can see from the progression along the length of the project, more special effects started appearing as he learned more about creating animations.

Major learnings for my child were:
  • Using "show" and "hide" instructions to make characters appear and disappear in the story.
  • Timing -- using the wait statement and figuring out how long to wait, before each sprite makes its appearance on screen.
  • Animation: Creating multiple costumes for a sprite and alternating between them to create the effect of movement.
  • Changing the size of a sprite to create the visual effect of distance.
  • Creating and using different backdrops at various points to create the effect of multiple scenes.
  • Using XY coordinates to decide on positions of the sprite at various points of the presentation.







Note:

This project simulating a food chain, could potentially be a Grade 5 class project. Food chains are part of the Grade 5 syllabus; the description can be found here on the NGSS (Next Generation Science Standards) website. The students are expected to  "develop an understanding of the idea that plants get the materials they need for growth chiefly from air and water. Using models, students can describe the movement of matter among plants, animals, decomposers, and the environment and that energy in animals’ food was once energy from the sun".

Tuesday, August 5, 2014

Transmit Electricity with Minimum Loss from the Power Plant to the Cities

In this programming assignment, we shall work on finding the shortest path to reach a point on the XY plane. We shall then write a program for Pro-Bot to travel along the shortest path that we found. This is a peek into the world of optimization, comparing and contrasting various solutions to a problem and choosing the best one that fits our needs and constraints. 

Your task is to find the paths to the various points on the XY plane, given the XY coordinates. Next, compare and contrast the cost options for the different paths and choose the best one that meets the constraints. Once you have found the best option, determine the  distances and angles at which Pro-Bot has to make turns, in order to traverse the path and write your program. 



Computer Science Concepts involved:   Sequential programming, Optimization

Math concepts involved:   Right triangles, Coordinates on XY plane, Measuring distances between points given (x, y) coordinates, Angles,  Finding shortest paths

Grade levels:   4, 5

Hours required:   1



Programming Assignment



Electricity is generated in power stations and then it gets transported to various cities for distribution to the consumers. Not all of the electricity that gets generated will reach the consumer. Several losses occur along the way on the distribution network. The power company would like to keep the distribution losses at a minimum as the consumers do not pay for it. 


Here is a set of coordinates given, representing 3 cities X, Y and Z and the power generation station at point A. 





















Power is generated at location A and then transported to the cities. For each unit of distance between the points, 1 Kilowatt-hour of energy is lost (Kilowatt-hour is a unit  used to measure energy). Your task is to find the best option for drawing electric lines between the power station and the cities, which will have minimum total loss of electric power during transmission.

Your options are: 
(a) to have direct power lines drawn from A to the cities separately or 
(b) draw power lines from A to a city and then draw more power lines from that city to the next and so on. 

Given the coordinates of the cities and the power station, can you find the shortest distances between them? Use the values that you found to calculate the amount of electrical energy that is lost during transmission to the various cities. Which option do you think would work better, option (a) or option (b) as given above? 

Compare all options to see which approach can minimize the total loss of power during transmission from the power station A to all three cities X, Y and Z. 

If Pro-Bot is driving along the path that provides the minimum loss of electricity, starting from point A and visiting all three cities, can you write a program to trace Pro-Bot’s path? Assume that Pro-Bot is at the point (0, 0) and facing the X axis when it starts its journey.

Wednesday, July 30, 2014

Procedures in Pro-Bot


Let’s start this lesson by taking a look at your typical school day. What are some of the functions that you perform on a given school day? Here are a few: you wake up, make your bed, brush your teeth, take a bath, get dressed, eat breakfast, travel to school, study, play, eat lunch, study again, travel home, play, sports/activities, watch TV, read a book, do homework, eat dinner, brush your teeth, sleep... If you look closely at each of these functions, you notice that each one of these involves multiple steps.

For example, brushing your teeth more or less involves the following steps: (1) pick up toothbrush (2) pick up toothpaste (3) squeeze the toothpaste onto the brush (4) actual brushing of the teeth (5) open the tap for water (6) fill up your glass (7) close tap (8) rinse your mouth (9) put away the toothbrush and toothpaste.

We bunched up all these steps and gave it a unique name: “brush teeth”. When your dad or mom wants you brush your teeth, do they say all these 9 steps one by one, or do they just say “brush teeth”? Why? Because you understand what “brush teeth” means. You have been taught in your younger days what that means and how to do all those 9 steps. All those steps are in your memory. So when you hear it, you know all the steps to do.

Now let us take a look at a computer… like your Pro-Bot. Don’t you think if a computer is first told how to draw a 6 cm side square, then each time you want to draw a 6 cm side square, you should be able to say a unique name like “square” or draw square”, or something like that, instead of telling it each time “Fd 6, Rt, Fd 6, Rt, Fd 6, Rt, Fd 6, Rt”? Guess what? The computer can do that! And that is what we call “Procedure”.

A procedure is a set of computer program instructions that performs a specific task.
  
In your daily life example, “brush teeth” is a procedure. It is a small group of instructions that performs a specific function. Any time your parent wants you to perform this function (which involves those 9 steps), he or she would just call it by the name “brush teeth”, rather than specify every step involved in it. This way, they get to reuse the “procedure” they taught you and made you memorize. Similarly, in a computer program, you write those steps once into the computer’s memory and give it a unique name. Then you can use it multiple times in your program.

Maybe, the dentist has advised you and your parents to include flossing into your routine. Flossing is also a procedure just like “brush teeth”. It involves some of these steps: (1) take the box of floss, (2) cut off about 10 inches of the flossing thread (3) coil it around your fingers (4) insert it between 2 of your teeth and pull (5) repeat this for all the gaps between your teeth (6) uncoil the string from your fingers (7) throw it into the garbage. Your parents work with you to teach you these steps until you have learned it. Then while brushing your teeth, he or she may remind you to “floss”. They don’t have to tell you all those 7 steps every time anymore. So here you can see that the “floss” procedure is called from within the “brush teeth” procedure.

Now let’s go back to the computer. Let’s say you want it to make a beeping sound after you draw the square. What would you do? You could write a procedure to make that beeping sound. Then call that “beep” procedure from within your “square” procedure after all those steps to draw the square. In this way, you just easily modified your first procedure to do something different.

Thus, you can call other procedures from within a procedure.

Back to our “brush teeth” example. You may decide to floss before you do other steps in your “brush teeth” procedure, or after you have done those steps. Similarly you may decide to make the Pro-Bot “beep” before it starts drawing the square instead of after drawing the square. Can you see how easy that would be? You just have to call the “beep” procedure first instead of last within your “square” procedure.

You can think of “school day” as a Program, and functions like “wake up”, “make bed”, “brush teeth”, etc., as Procedures inside the program. Now, try writing two different programs using the procedures for the daily functions: one program for a school day and the other program for a holiday. You can easily see that you would not call every one of the procedures for either program. There might be some procedures that are common to both programs and there might be some that are exclusive to each. Such as, you don’t “travel to school” on a holiday, but you “brush teeth” every day. You might also call them in different orders for the two programs. For example, you may watch TV at different times during a holiday, than on a school day.

Procedures thus help us to customize our programs easily.

We already mentioned that procedures and programs can call other procedures from within. They can be called multiple times as well. You can write a procedure for drinking water. You might call this procedure multiple times throughout the day, while performing other functions. This means that you can call “drink water” from within your “eat lunch” procedure or from within your “play” procedure or from within your “do homework” procedure, etc.


How to create and edit a procedure for Pro-Bot
Pro-Bot lets you create and store up to 32 procedures in its memory. In the case of Pro-Bot, these procedures are named Proc 1, Proc 2, …, …, Proc 32.
Pro-Bot’s Menu button provides two options to access procedures:
·      New Proc
·      Edt Proc

Let’s discuss each of these options.
1.   New Proc:
Press the Menu button & then scroll down to “New Proc”. Choose this option when you want to create a new procedure. It will show you a list of 32 procedures on the screen. Choose any procedure name from this list (Proc 1 to Proc 32). Let’s say that you choose Proc 3. Your Pro-Bot screen will now show Proc 3. Type in the instructions for the specific function that you want Proc 3 to perform. Next, press Menu. This will take you back to the Main program. You can now call Proc 3 from your Main program anytime you want to use it. You do this by pressing the “Proc” button and then the number key 3.

2.   Edt Proc:
Press the Menu button & then scroll down to “Edt Proc”. Choose this option when you want to edit a procedure that you created earlier. It will show you the list of 32 procedures on the screen. Choose the procedure that you want to edit from this list. Let’s say that you choose Proc 3. Your Pro-Bot screen will now show the instructions that you put in earlier for Proc 3 (or an empty program if you put in no instructions earlier). Make the changes that you want for this procedure. Next, press Menu to go back to the Main program. You can now call Proc 3 from your Main program and it will provide you with the updated functionality.

For example; you can write a procedure to draw a square of side 6 cm. Let’s say we name this procedure “Proc 1”. Proc 1’s code will be “Rpt 4 [ Fd 6   Rt ]”. You can store this procedure in memory and anytime you need to draw a 6 cm square, you just call Proc 1 from your Main program.


In addition to the 32 procedures that you can create and edit, Pro-Bot also provides 5 other procedures with pre-defined names related to the touch, light & sound sensors. You can edit these using the Edt Proc option from Menu. These procedures are:
·      33 FRONT (runs when the front touch sensor is triggered)
·      34 REAR (runs when the rear touch sensor is triggered)
·      35 DARK (runs when the light sensor goes from light to dark)
·      36 LIGHT (runs when the light sensor goes from dark to light)
·      37 SOUND (runs when the sound sensor is triggered)

There are also 3 built-in, pre-defined procedures that you cannot edit, but can call from Main. These are:
·      38 HEXGN: draws a hexagon
·      39 DIAMND: draws a diamond
·      40 FLOWER: draws eight diamonds using Proc39

Note: You can call other procedures from within any other procedure. Just take care not to run procedures that call each other, in which case you would get into an endless loop.






Tuesday, July 29, 2014

Pro-Bot drives up a steep mountain


Pro-Bot is trying to go up a mountain. But the mountain is so steep that for every 4 miles that Pro-Bot climbs up, it slides back 1 mile. Pro-Bot attempts this 5 times. How far is Pro-Bot from its starting point at the end of the 5th attempt? 

Write a program to trace the path taken by Pro-Bot. Use 1 cm to represent 1 mile in your program.
Do you see a repeating action here? If yes, can you use a Repeat Loop in writing this program?  

After tracing the path with Pro-Bot, use a ruler to measure the distance traveled to check if it matches the distance that you calculated.






I designed this question to let the children map a word problem to a math problem and finally to a computer program. It represents a real-life problem solving scenario which includes reading and understanding a word problem, identifying recurring patterns in it, applying mathematical concepts to the problem, scaling of quantities to reasonable sizes and finally coming up with the solution to the problem in the form of a computer program.



The solution is a very simple program:

  Rpt 5 [
  Fd 4
  Bk 1
  ]

The total distance traced by Pro-Bot is 15 cm.


Help Pro-Bot find his way home


Pro-Bot has been on a trip to a new park and needs to find its way back home. The GPS says that Pro-Bot has to travel 9 miles North from the park, then 7 miles East and finally 2 miles South to get home. 

Can you write a program to trace Pro-Bot’s path as it finds its way home?
Use a scale of 1 centimeter to represent 1 mile in your program.





















I designed this question to go along with the Geography lessons in class that teach the North, South, East & West directions. It allows for the children to map the compass directions to Logo instructions in Pro-Bot. It represents a real-life problem solving scenario which includes reading and understanding a word problem, applying concepts of computer science to geography and math, scaling to reduce the size of the figure traced by Pro-Bot and finally coming up with the solution in the form of a computer program.



The solution is a simple 5 line program:

  Fd 9
  Rt
  Fd 7
  Rt
  Fd 2