Difference between revisions of "Class 6: April 11, 2008"
Line 1: | Line 1: | ||
We advanced with the concepts of loops and conditionals in this class by playing a number game, drawing different shapes and playing in a life-size maze. First, we reinforced the concepts by talking to the class and clarifying any confusions. Then we played a number game - the computer would choose a number and the students would try to guess it. If they guessed it right, then they won and the game ended; if not, the computer would tell them if the number is too high or too low accordingly. This taught them about if-else statements. Also, they were given only 10 tries - this taught them more about loops. Then we let the students play in the maze- they could steer their robots around by writing little programs and pick up objects that had been scattered along the way. We wrote a wall function that the students could use in their code to tell whether or not they see a wall. Then they could use their knowledge of if, else and loops to make their robots go around. After this activity, we allowed the students to make squares, triangles and rectangles - again with using conditional statements. | We advanced with the concepts of loops and conditionals in this class by playing a number game, drawing different shapes and playing in a life-size maze. First, we reinforced the concepts by talking to the class and clarifying any confusions. Then we played a number game - the computer would choose a number and the students would try to guess it. If they guessed it right, then they won and the game ended; if not, the computer would tell them if the number is too high or too low accordingly. This taught them about if-else statements. Also, they were given only 10 tries - this taught them more about loops. Then we let the students play in the maze- they could steer their robots around by writing little programs and pick up objects that had been scattered along the way. We wrote a wall function that the students could use in their code to tell whether or not they see a wall. Then they could use their knowledge of if, else and loops to make their robots go around. After this activity, we allowed the students to make squares, triangles and rectangles - again with using conditional statements. | ||
+ | |||
+ | We defined wall as: | ||
+ | <pre> | ||
+ | def wall(): | ||
+ | return getObstacle(1) > 4500 | ||
+ | |||
+ | def heads(): | ||
+ | return flipCoin() == "heads" | ||
+ | |||
+ | def flipCoin(): | ||
+ | return("heads","tails")[random.randrange(2)] | ||
+ | </pre> | ||
+ | |||
+ | so that it could be used in the following manner: | ||
+ | <pre> | ||
+ | def walk(): | ||
+ | if wall(): | ||
+ | if heads(): | ||
+ | turnLeft(0.7, 0.2) | ||
+ | else: | ||
+ | turnRight(0.7, 0.2) | ||
+ | else: | ||
+ | forward(0.7) | ||
+ | </pre> | ||
+ | |||
Here are survey results from that class: | Here are survey results from that class: | ||
Line 14: | Line 39: | ||
- 0% replied no! | - 0% replied no! | ||
- 92.3% are excited to come and play with their robots next week. The rest are neutral, again a 0% no! | - 92.3% are excited to come and play with their robots next week. The rest are neutral, again a 0% no! | ||
+ | </pre> | ||
+ | |||
+ | Here is some code that one of the students in the class wrote: | ||
+ | |||
+ | <pre> | ||
+ | def maze(): | ||
+ | if wall(): | ||
+ | if heads(): | ||
+ | turnLeft(1,.4) | ||
+ | if wall(): | ||
+ | turnLeft(1,.4) | ||
+ | else: | ||
+ | turnRight(1,.4) | ||
+ | if wall(): | ||
+ | turnRight(1,.4) | ||
+ | else: | ||
+ | forward (0.1) | ||
</pre> | </pre> | ||
[http://wiki.roboteducation.org/CREU CREU Project Home]. | [http://wiki.roboteducation.org/CREU CREU Project Home]. |
Revision as of 08:16, 14 January 2009
We advanced with the concepts of loops and conditionals in this class by playing a number game, drawing different shapes and playing in a life-size maze. First, we reinforced the concepts by talking to the class and clarifying any confusions. Then we played a number game - the computer would choose a number and the students would try to guess it. If they guessed it right, then they won and the game ended; if not, the computer would tell them if the number is too high or too low accordingly. This taught them about if-else statements. Also, they were given only 10 tries - this taught them more about loops. Then we let the students play in the maze- they could steer their robots around by writing little programs and pick up objects that had been scattered along the way. We wrote a wall function that the students could use in their code to tell whether or not they see a wall. Then they could use their knowledge of if, else and loops to make their robots go around. After this activity, we allowed the students to make squares, triangles and rectangles - again with using conditional statements.
We defined wall as:
def wall(): return getObstacle(1) > 4500 def heads(): return flipCoin() == "heads" def flipCoin(): return("heads","tails")[random.randrange(2)]
so that it could be used in the following manner:
def walk(): if wall(): if heads(): turnLeft(0.7, 0.2) else: turnRight(0.7, 0.2) else: forward(0.7)
Here are survey results from that class:
- 69.2% said their favorite part was playing in the maze; 30.8% the number game was their favorite; 23.1% enjoyed drawing the shapes most. - When asked what their least favorite part of class was, 50.3% replied that they liked everything that was done in class. - When asked if they liked their robot: - 69.2% said that they did. - 23.1% said that it was OK. - 7.7% said that they did not like it. - When asked if they liked this class more than last week's class: - 69.2% replied yes - 30.8% replied were neutral. - 0% replied no! - 92.3% are excited to come and play with their robots next week. The rest are neutral, again a 0% no!
Here is some code that one of the students in the class wrote:
def maze(): if wall(): if heads(): turnLeft(1,.4) if wall(): turnLeft(1,.4) else: turnRight(1,.4) if wall(): turnRight(1,.4) else: forward (0.1)