PythonSneks Field Guide

An instructionally-designed, open-source introductory Python curriculum for university settings

Module 4 - Using Functions

Creating simple functions.

Before the week begins

Major Topics

Materials

Due This Week:

Graded This Week

Student Difficulty

???

Module 3 - Staff Meeting

Note: Most TA training materials come directly from:

Luther A. Tychonievich (2017) Training Course for Teaching Assistants in Computing, <https://www.cs.virginia.edu/luther/ta-training>. Accessed 2019-02-25

Lessons

Lesson 19- Debugging Techniques

Summary: When you encounter an error, you should attempt to debug them (using print statements, meticulously explaining your code, etc.).

Learning Objectives:

Activities:

Misconceptions: None listed so far

Lesson 20- Defining Functions

Summary: Function definitions have a body of code and are described by their header. Creating functions is necessary for building up programs of scale.

Learning Objectives:

Activities:

Misconceptions:

Lesson 21- Unit Tests

Summary: Unit tests are used to ensure that a function is correct.

Learning Objectives:

Activities:

Misconceptions: None listed so far

Lesson 22- Return and Print

Summary: Returning from a function causes a value to be made available at the callsite. Printing from a function makes a value appear on the console.

Learning Objectives:

Activities:

Misconceptions: None listed so far

Lesson 23- Scope

Summary: Variables created inside a function cannot be used outside the function, and variables created outside a function should not be used within.

Learning Objectives:

Activities:

Misconceptions: None listed so far

Lesson 24- Documenting

Summary: Documentation is a helpful tool for the benefit of programmers to better organize code. There are several ways to document in Python, but typically functions are documented using multi-line comments that describe the function’s inputs, outputs, and purpose.

Learning Objectives:

Activities:

Misconceptions: None listed so far

Lesson 25- Function Development

Summary: Functions allow us to extract commonly repeated chunks of code.

Learning Objectives:

Activities:

Misconceptions: None listed so far

Lesson 26- Data Flow

Summary: Data enters a function through parameters and leaves through returns. To make data available between functions, it will need to be returned.

Learning Objectives:

Activities:

Misconceptions: None listed so far