דלג לתוכן

Lesson 32: Look before you go

English

A function that answers

  • A procedure does a job. A function does a job and gives back an answer.
  • look(90) turns the robot to heading 90, measures, and gives back the distance. The answer is used where the call was.
  • With small functions like look, a big program is easier to read and to fix.

Words for this lesson

Word Meaning
return give a value back to the code that called the function
define write the function once, with def
call use the function: look(90)
parameter the value given to the function: heading

היכנס או צור חשבון

IGCSE, A-Level & AP