instagram

Students develop and define a function of their own. The function must take in an image and manipulate it using at least three transformations. This project supports the learning goals of Functions: Contracts, Examples & Definitions.

Lesson Goals

Students will be able to…​

  • represent function composition with Circles of Evaluation

  • use image-producing functions and functions that transform to define a function

Student-facing Lesson Goals

  • Let’s make our own functions in Pyret!

Materials

Preparation

  • Before launching this project, ensure that students are comfortable using image-producing functions and function composition.

  • Note that for this project, students must submit four items: (1) Sample Function Study, (2) Designing Your Function, (3) two Coding Your Function pages, and (4) a published Pyret program link

  • This project is designed to span multiple days.

🔗Create Your Own Function flexible

Overview

Students explore two sample functions, then design a function of their own and represent it with a Circle of Evaluation and code. Finally, they publish and share their program.

Launch

To launch this project, you’ll facilitate a conversation to review with students some of the functions that they have already created.

Use the Functions Starter File to complete the first section of the Sample Function Study.

After this refresher on how to use a defined function (maroon-square, invite students to find a partner. In each partner group, one student will pose the questions below and the other will answer them. If you prefer, you can pose these questions to the class and call on individual students.

Turn and talk to a partner. One student will ask questions, and the other will answer. The student who is asking the questions should point to the line of code in the Functions Starter File that the the question refers to.

  • In the first example, how did we decide what number to use as the input for maroon-square?

    • We randomly chose the number! We can use any number.

  • How did we decide on the output for maroon-square?

    • We thought about "what our actor would need to say" or looked at the directions.

  • How would we decide what to circle in the examples?

    • We would look to see what changes.

  • How did we decide on our function definition?

    • We looked at the examples. We wrote down everything that remained the same, and we used what we circled as our variable.

For this project, we’re going to create a function that takes in an image, and transforms that image at least three times. Let’s look at a function like that!

Using the Functions Starter File, complete the second section of the Sample Function Study.

  • What does the function sample do?

    • It consumes an image, which will be scaled, rotated, and overlayed on a purple rectangle that is overlayed on a green star.

  • How are the maroon-square and sample alike? How are they different?

    • Both functions produce images, but maroon-square consumes a number, while sample consumes an image. The function sample is more complex: it uses a variety of composed functions, while maroon-square uses only one function.

We recommend printing and distributing the student-facing Rubric: Create Your Own Function to help students understand the scope of the project and your expectations at the outset. Teachers are welcome and encouraged to edit and adapt the rubric for their unique classroom context.

Before moving onto the next phase of the project, some teachers have students submit their work now, and evaluate it using the first row of the rubric. Intermittently receiving feedback is useful for many students.

Turn to Designing Your Function, where you will thinking about which functions you’d like your function to use.

If students get stuck, you can refer them to Sample Function Study.

Note that if you are collecting student work intermittently, now is a good time to do so. This phase of the project can be evaluated according to the second row of the rubric.

Investigate

In this phase of the project, students begin to think more deeply about how they will write the code needed to produce their function. They also code and test their function in Pyret, before publishing and submitting.

Students who are able to conceptualize their function by drawing an accurate Circle of Evaluation will be able to progress through the remainder of the project much more confidently. It is vital to ensure that students have done adequate planning before they begin coding in Pyret. If you’d like, this is another good opportunity to assess student work using the third row of the rubric.

Open My Function Starter File, which you will use to complete Coding Your Function (2).

Coding Your Function (2) asks students to define a value, add examples, and define their functions. They also complete a second round of peer review. When students are struggling, encourage them to read error messages carefully and refer to any relevant contracts.

Finally, students publish and submit their program links. Specify how you would like students to do this. Email, a form, or any SMS (ie, Google Classroom or Schoolology) will work!

Synthesize

  • Encourage students to self-assess and revise their work. Peer review is a powerful tool if time allows! The rubric is a useful resource for facilitating both self and peer review.

  • Finally, celebrate students' work! In many instances, students will want to share their project, given how much time they have invested. Class or public presentations can instill a sense of pride.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge 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.