-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
template: exercise | ||
title: Functions | ||
level: 3 | ||
exercise: 7 | ||
category: Robotics | ||
tags: ['MakeCode', 'Functions', 'CPX'] | ||
description: Creating functions to perform calculations and group commands | ||
--- | ||
|
||
- **What are functions?** | ||
- Functions are fundamental building blocks of programs\. | ||
- They let you name a set of commands\. | ||
- Once defined\, a function can be re\-used over and over\. | ||
- **Examples of functions:** | ||
- Add\( *x\, y* \) | ||
- Take two numbers *x* and *y* \, and return the sum *x\+y* | ||
- \(takes input and returns output\) | ||
- TurnOn\( *x* \) | ||
- Take a number between 0 and 9\, and turn on that LED | ||
- \(takes input\, does not return output\) | ||
- PartyTime\(\) | ||
- Set all pixels to red\, play a tune | ||
- \(doesn’t take input\, doesn’t return output\) | ||
|
||
## Creating Functions | ||
|
||
![](Lesson35.png) | ||
|
||
## Defining and Calling Functions | ||
|
||
![](Lesson38.png) |