Referenced from lesson Defining Values (Spring, 2021)
1 What image do you see repeated in the flag?
2 Highlight or circle all instances of the structure that makes the repeated image in the code below.
3 In the code below, highlight or circle all instances of the expression for that image.
4 Write the code to define a value for the repeated expression.
5 Open the
Chinese flag starter file (Pyret)
and click Run.
Then type china
into the interactions area and click Enter.
6 Save a copy of the file, and simplify the flag code using the value you defined. Click Run, and confirm that you still get the same image as the original.
7 Now change the color of all of the stars to black, in both files. Then change the size of the stars.
8 Why is it helpful to define values for repeated images?
Challenge:
-
This file uses a function we haven’t seen before! What is it?
-
Can you figure out its contract? Hint: Focus on the last instance of the function.
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap:Algebra 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.