Learn to program

 
  Finch assignments ::

Learning Goal: Understand how to write a program to control a robot,

 

 
 

Python lesson 6 - Functions

 

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

Lesson Video - Python built-in functions 1 [YT] [WK]

Lesson video - Python built-in functions 2 [YT] [WK]

This lesson has two parts!

part 1

 

Assignment 6 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 save it as builtinyourname.

To turn it in, look at the instructions below:

  • Go to Google Drive
  • Open the Class Assignments AI folder in 'Shared with me'
  • Open your class folder and assignment folder
  • Click on the "New" button on the top left
  • Upload the program from your computer

part 2

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.

 

You need to learn how to create your own functions.

Lesson video - Defining Functions Part 1 [WK] [YT]

Lesson video - Defining Functions Part 2 [WK] [YT]

Lesson notes - Defining Functions Part 3

Finch Lesson Notes

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

 

Assignment 6 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 finch:

  • 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 save it to your computer as rainbowyourname.

To turn it in, look at the instructions below:

  • Go to Google Drive
  • Open the Class Assignments AI folder in 'Shared with me'
  • Open your class folder and assignment folder
  • Click on the "New" button on the top left
  • Upload the program from your computer

 

.

Write a Reflection on what you have learned.