Learn to program

 
  Finch assignments ::

Learning Goal: Understand how to write a program to control a robot, using loops, conditionals and subroutines where appropriate.

 

 
 

Finch lesson 7 - Functions

Part 1

Python has many Built-In Functions - watch these videos:

Lesson Video - Python built-in functions 1

Lesson video - Python built-in functions 2

 

Assignment 7 Part 1 - The video is wrong! to call the directory use the commands:

import builtins

dir(builtins)

Write a paragraph summarizing what you learned in the videos.

Explain how you think the help function could be useful. Head the document with Name, date, class color, and

turn the paragraph in to Shared - Students - Pereira - AI 201x - Class color - Builtin as builtinyourname.

 

Part 2

Instead of writing long, repetitive, confusing programs, you can write short bits (functions)
that can be called again and again. This makes the program easier to write, and also easier to read.

 

Before you start the lesson, play Lightbot for about 10 minutes.

 

You need to learn how to create your own functions.

Lesson video - Defining Functions Part 1

Lesson video - Defining Functions Part 2

Lesson notes - Defining Functions Part 3

 

Every time you write a function, you should use the 'Function Recipe'.

 

Assignment 7 Part 2:

Define a function called ‘rainbow’ to make the Finch nose color change from red
to orange to yellow to green to blue to purple.  Remember how you made the Finch
change its nose color right in the beginning. You need to give that set of commands
for every color change. There is no short cut. You Must use rgb notation or hex codes for the color.

Use the function recipe!!!!!! (Nothing is returned.)

 

Write a program that makes the scribbler spin
twice to the right, call the rainbow  function, spin twice to the left, call the rainbow  function again,
then finally move  forward 30 cm.

Call me to see the program running, and turn the program in to
Shared - Students - Pereira - AI 201x - Class color - Finch - Rainbow as rainbowyourname.

 

 

.

Write a Reflection on what you have learned.