Unit 2. Developing Programming ToolsRevision Date: Jul 27, 2017 (Version 2.1.1)
In Python, a function is a named sequence of statements that belong together. In this lesson, students learn why functions are used, how they are used, and how they are defined.
Students will work extensively with the online version of How to Think Like a Computer Scientist (HTLACS) hosted by Runestone Interactive.
Students will understand the purpose of functions and how they allow a program to be built and maintained in a modular way.
- students often think that functions (or any code) written will run. They don't connect that it must be called in order to be run.
- students often think that functions have access to variables that they don't have access.
Student computer usage for this lesson is: required
Homework: Students should read Python for Everybody Chapter 4: Sections 4.7, 4.8 and 4.9. Complete Exercises 2 and 3.
Answer the following questions:
Students should be paired through this exercise since paired discussion is used for formative assessment. Question can be provided to students through a variety of formats including production of a Google form or using student response systems.
Three suggested strategies are:
After Activity D, have students compare results with their elbow partners. Discuss any unresolved issues. This strategy can be used after any check for understanding.
After Activity F, ask students to suggest a rule for creating functions that would help avoid this error.
Students work alternately between the web site, partners, and the whole group. Teachers are to monitor student responses to the questions following each activity to be sure that students are addressing the key content within each activity.