Mis bloques#
Introducción#
My Blocks is the equivalent to functions in Python. My Blocks group blocks into reusable, efficient sections of blocks designed to perform a specific task. My Blocks can be called multiple times within a program, making project organization easier, and helping to avoid repeated blocks.
definir myBlock
myBlock
Parámetros |
Descripción |
|---|---|
nombre del bloque |
A name you give to your My Block. |
parámetros |
Opcional. Variables que aceptan valores de entrada al llamar a la función, lo que permite pasar datos a la función. Puede ser texto, un número o un valor booleano. |
Definiendo y llamando a mis bloques#
Mis bloques#
If a My Block does not require input, you can define it without parameters.
definir greeting
[Define a My Block to display a message]
imprimir [Hello!] en la pantalla ▶
cuando empezó
[Call a My Block to display the message]
greeting
Mis bloques con parámetros#
Parameters let you give a My Block the information it needs to work, such as how many times to complete a sequence of movements. For example, a My Block could use a number parameter to tell the drone how high to fly. This lets you use the same My Block in different ways depending on what values you give it.
definir Divide by 3 (number) :: custom
[Display the quotient with two decimals.]
Establezca la precisión de impresión en [0.01 v] en la consola
imprimir ((number) [/ v] (3)) en la consola ◀ y coloque el cursor en la siguiente fila
cuando empezó
[Set the equation's dividend.]
Divide by 3 [4]
Divide by 3 [12]