Function Refresher 1: maroon-square
Open the Functions Study Starter File and "Save a Copy".
Before you click "Run", answer questions 1-3 by reading the Contract, Examples, and Definition for the function maroon-square
in the Definitions area.
1 What is the Domain of maroon-square
?
2 What is the Range of maroon-square
?
3 What do you expect the function maroon-square
to do?
4 Click "Run".
What do you learn about examples-block-1
when you click "Show Details"?
5 What happens when you type maroon-square(20)
in your Interactions Area and hit enter?
6 Change the code in the Definitions Area so that all 3 tests in examples-block-1 pass when you click "Run" (and save your changes). What did you change?
Function Refresher 2: mystery
7 What are the names of the 3 defined values at the beginning of this section?
Let’s examine what happens when we use each of those values as inputs for mystery
.
-
Type
small-yt
into the Interactions Area and hit enter. -
Then, test out
mystery(small-yt)
.
8 What do you Notice? What do you Wonder?
9 What do you expect to happen when you test hello-text
and mystery(hello-text)
?
Note: If you like, you can run mystery
with any image-producing function!
10 In your own words, describe how the function mystery
transforms its input.
11 Take another look at the EXAMPLES
section. Notice how the programmer made use of indentation and new lines. Why do you think they wrote the code that way?
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). 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.