The Editor is a software program we use to write Code. Our Editor allows us to experiment with Code on the right-hand side, in the Interactions Area. For Code that we want to keep, we can put it on the left-hand side in the Definitions Area. Clicking the "Run" button causes the computer to re-read everything in the Definitions Area and erase anything that was typed into the Interactions Area.

## Data Types

Programming languages involve different data types, such as Numbers, Strings, Booleans, and even Images.

• Numbers are values like 1, 0.4, 1/3, and -8261.003.

• Numbers are usually used for quantitative data and other values are usually used as categorical data.

• In Pyret, any decimal must start with a 0. For example, 0.22 is valid, but .22 is not.

• Strings are values like "Emma", "Rosanna", "Jen and Ed", or even "08/28/1980".

• All strings must be surrounded in quotation marks.

• Booleans are either true or false.

All values evaluate to themselves. The program 42 will evaluate to 42, the String "Hello" will evaluate to "Hello", and the Boolean false will evaluate to false.

## Operators

Operators (like +, -, *, <, etc.) work the same way in Pyret that they do in math.

• Operators are written between values, for example: 4 + 2.

• In Pyret, operators must always have a space around them. 4 + 2 is valid, but 4+2 is not.

• If an expression has different operators, parentheses must be used to show order of operations. 4 + 2 + 6 and 4 + (2 * 6) are valid, but 4 + 2 * 6 is not.

## Applying Functions

Applying functions works much the way it does in math. Every function has a name, takes some inputs, and produces some output. The function name is written first, followed by a list of arguments in parentheses.

• In math this could look like f5$\displaystyle f(5)$ or g(10, 4)$\displaystyle g(10, 4)$.

• In Pyret , these examples would be written as f​(​5​) and g​(​10, 4​).

• Applying a function to make images would look like star​(​50, "solid", "red"​).

• There are many other functions, for example num-sqr, num-sqrt, triangle, square, string-repeat, etc.

Functions have contracts, which help explain how a function should be used. Every contract has three parts:

• The Name of the function - literally, what it’s called.

• The Domain of the function - what types of values the function consumes, and in what order.

• The Range of the function - what type of value the function produces.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.