Skip to main content
Logo image

Section 2.1 Scripts & Functions

Scripts execute statements from top to bottom by default, and functions bundle a sequence of tasks you can reuse. However, most programs need to make decisions and repeat actions based on conditions. This section discusses the different flow patterns of code and the ways you can control them.
Table 14. Scripts versus Functions
Feature Script Function
Goal Run a sequence of commands to complete a task Create a reusable tool (inputs β†’ outputs)
Running it Press the β€œRun” button or type the script name in the command window Call it with inputs in the command window or another script or function
Workspace Shares the base workspace Uses its own workspace
Reusability Often specific to one situation Designed to be used many times