Lesson Summary


In the first portion of this lesson, students continue their inquiry into the properties of functions, with a focus on communication to and from other functions. In the lab portion of the lesson, students develop three Python modules using both Runestone Interactive and their Python IDE. Students use their own functions to perform calculations and draw a variety of polygons and a circle using turtle graphics.


  • Students will understand the process of communication with functions.
  • Students will be able to create and call functions.
  • Students will be able to use both "fruitful functions" (sometimes just called functions) and "unfruitful functions" (which do not return a value - these are usually called procedures).
  • Students will understand how functions simplify a project's creation.


Session 1

  1. Warmup (10 min)
  2. Exploring Functions (40 min)

Session 2

  1. Function Labs (45 min)
  2. Wrap-up (5 min)

Learning Objectives

CSP Objectives

Big Idea - Creativity
  • EU 1.2 - Computing enables people to use creative development processes to create computational artifacts for creative expression or to solve a problem.
    • LO 1.2.2 - Create a computational artifact using computing tools and techniques to solve a problem. [P2]
    • LO 1.2.3 - Create a new computational artifact by combining or modifying existing artifacts. [P2]
Big Idea - Programming
  • EU 5.1 - Programs can be developed for creative expression, to satisfy personal curiosity, to create new knowledge, or to solve problems (to help people, organizations, or society).
    • LO 5.1.2 - Develop a correct program to solve problems. [P2]
  • EU 5.3 - Programming is facilitated by appropriate abstractions.
    • LO 5.3.1 - Use abstraction to manage complexity in programs. [P3]

Math Common Core Practice:

  • MP4: Model with mathematics.
  • MP5: Use appropriate tools strategically.

Common Core ELA:

  • RST 12.2 - Determine central ideas and conclusions in the text
  • RST 12.3 - Precisely follow a complex multistep procedure
  • RST 12.4 - Determine the meaning of symbols, key terms, and other domain-specific words and phrases
  • RST 12.10 - Read and comprehend science/technical texts

NGSS Practices:

  • 1. Asking questions (for science) and defining problems (for engineering)
  • 5. Using mathematics and computational thinking

Key Concepts

  • Students will understand the process of communication with functions.
  • Students will be able to create and call functions.
  • Students will be able to use both fruitful and unfruitful functions.
  • Students will understand how functions simplify a project's creation.

Essential Questions

  • How does abstraction help us in writing programs, creating computational artifacts and solving problems?
  • How are algorithms implemented and executed on computers and computational devices?
  • How are programs developed to help people, organizations or society solve problems?
  • How do computer programs implement algorithms?
  • How does abstraction make the development of computer programs possible?
  • How do people develop and test computer programs?

Teacher Resources

Student computer usage for this lesson is: required

Lesson Plan

Session 1

Getting Started (10 min)

  • Display Python for Informatics: Exploring Information Chapter 4 (Functions) - Section 4.11.
  • Students record in their journals four reasons to use functions and discuss with elbow partners to identify their two most important reasons.
  • Ask students to identify two or three people they know who have the same name.
    • Explain to their elbow partners who the people are and how they tell them apart when talking about them.
    • Explain that we are going to working with functions today and that sometimes functions use the same names for different variables.
    • Before writing programs with functions, we want to address the possibility of functions that use the same names.

Exploring Functions (40 min)

Teaching Note: 

Use of a format such as Google forms is sugggested for collecting student responses to the questions for each activity. It is important to keep this portion of the class moving so students have enough time for the labs. If students work with partners during their program development, they will have someone to share their progress with. Use a timer and have students briefly share their progress roughly every 10 minutes. This will not only help them understand an iterative development process, but also gives students practice with a collaborative development style.


  • Display Section 4.12 of Python for Informatics.  
  • Explain: when progam developers write their own functions, they often run into problems (bugs) they need to fix. These debugging suggestions should help the students to prevent or correct problems.
  • As students investigate and work with functions today, they should an eye out for function design problems and strategies used to prevent or solve them. We will add the rules we develop to this list. 

Variables and Parameters

  • Students should open the Runestone Interactive Functions page (http://interactivepython.org/runestone/static/CCPS_Python/Functions/functions.html).
  • Have students read "Variables and parameters are local" and run the Codelens to completion.  
  • Ask:
    • What caused the error that occurred when the last line of the code was executed?
    • What happens to local variables when a function finishes?
    • Are parameter's values that are assigned inside a function also accessible outside the function? 

Global Variables (Don't Use Them!)

  • Run ActiveCode 9.
  • What is the value of the variable power inside the function?
  • At what point was the variable power given that value?
  • This form of communication is risky, since programmers may not realize that a variable used in one code segment is also used inside a function elsewhere in the program.  
  • What is the recommended way to communicate values to a variable?
  • Emphasize that avoiding global variables supports collaboration and reuse of code, since different authors can avoid interfering with each other's work.

Variable Scope

  • Complete the "Check for Understanding" after CodeLens 5, answering questions func-10, func-11, and func-12.
  • Share "Check for Understanding" results either with elbow partners or the class as a whole. 

Accumulating Values

  • Go to the section entitled "The accumulator pattern."
  • Do ActiveCode 10 and CodeLens 6.
  • After reviewing the execution in the CodeLens, answer the "Check for Understanding" questions func-13 through func-14.
  • See if the students can add any rules for creating and using functions to the list from Python for Informatics.

Functional Decomposition

  • Go to the section entitled "Functions can call other functions".
  • Do CodeLens 7 and ActiveCode 12.
  • Ask:  
    • What function is started first when the code in ActiveCode 12 is executed?
    • What function is finished first when the code is executed?

Session 2

Function Labs (45 min)

  • Preview the three lab projects that students will complete and help students to get started with the Slope Y-Intercept project.
  • Complete the Slope Y-Intercept Project and the Drawing a Circle Labs.
    • The Slope Y-Intercept Project is described in the document of the same name.
    • The document includes descriptions of two functions to complete and contains a small sample of test data.
    • The Slope Y-Intercept Project is in the Lesson Resources folder along with the starter Python file.
  • Continue in Runestone to the Lab entitled Drawing a Circle (http://interactivepython.org/runestone/static/thinkcspy/Labs/lab04_01.html).
    • In this second lab, students develop a function that uses a turtle to draw a circle.
    • After finishing the lab, students should copy their code to a Python module in PyCharm.
    • Students should create three functions named drawSquare, drawTriangle, and drawOctagon, along with main module code that calls each function.
  • After completing the Drawing a Circle lab, students should follow the link below to the Lessons from a Triangle lab.
  • Students should create a second Python module with the code from the starting point for the drawPolygon function code and finish implementing the drawPolygon function.
  • Students should complete the Function Labs by developing the drawCircle function in Finally a Circle (the second half of the Lessons from a Triangle lab).
    • Additional components of the lab can be used as extensions for more able students.

Wrap-Up (5 minutes)

  • After submitting the labs, students present their labs with elbow partners and groups.
  • Students reflect on the following prompts about writing programs with functions.
  • What problems did they encounter?
  • How did they overcome the problems?
  • How do functions simplify the task of developing a program?

Options for Differentiated Instruction

Iterative development works by developing, then sharing, programs at many points during the development process. Students should work in pairs as they create their programs and share the work through various completion stages.

Students who are completing projects quickly should be introduced to the Python turtle API at (https://docs.python.org/3.4/library/turtle.html). Students can investigate and implement such methods as fill, speed and others as described by the API documentation.  

Evidence of Learning

Formative Assessment

Check for understanding by assessing student performance on the Runestone Interactive questions. Students should first try to resolve any difficulties with their partners and groups.

Students should be able to make suggestions for creating and using functions.

Identify and address any areas discovered that students have been unable to come to a consensus understanding. 

Summative Assessment

Create functions that receive parameters, perform calculations using those parameters, and return a value.

Write a function to return the slope and y-intercept of a function of the line through two points.

Write functions to create a variety of polygons and a circle.