Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Functions MakeCode Lesson #127

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
32 changes: 32 additions & 0 deletions site/content/exercises/makecode/robotics/E7/index.md
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\)
wheeler-c marked this conversation as resolved.
Show resolved Hide resolved

## Creating Functions

![](Lesson35.png)

## Defining and Calling Functions

![](Lesson38.png)