Suppose we wanted to label each data point on a scatter plot with its species…
1 Write the code to define sample1
to be the 10th row in the table.
2 Write the code to look up the species
column from sample1
?
3 Write the code that would use the text
function to show the species of sample1
in red, 15px letters?
Instead of writing this out over and over for each animal, let’s define a function to do it for us!
Species Tag
Directions: Define a function called species-tag
, which takes in a row from the Animals Table and draws its name in red, 15px letters. HINT: Use cat-row
and dog-row
in your examples!
Contract and Purpose Statement |
Every contract has three parts…
species-tag::___->_____
__________________________________________________________________________________
Examples |
Write some examples, then circle and label what changes…
examples:
___________ (_______) is ___________________________________
___________ (_______) is ___________________________________
end
Definition |
Write the definition, giving variable names to all your input values…
fun species-tag(_):
_____________________________
end
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.