Lesson overview

In this lesson we will learn how to create and use functions, one of the most powerful concepts in programming. We will also introduce you to the concept of a module (also known as a library in other programming languages), which you can think of as a toolbox for a specific purpose. Each module contains specific functionalities (i.e., functions) that you can use for different tasks. Thus functions and modules are closely related.

  1. Basic concepts of functions
  2. Loading and using modules
  3. Writing scripts the “right” way
  4. Exercise 4: Classifying and converting temperatures

Learning goals

After this weeks lesson your should be able to:

  • Explain how functions are used and their benefits
  • Create your own functions to calculate an output value based on an input value
  • Save functions to a script file for future use

Lecture

Lesson 4.1 - Introduction to Functions

Dave Whipp & Henrikki Tenkanen, University of Helsinki @ Geo-Python channel on Youtube.

Lesson 4.2 - Functions and modules

Dave Whipp & Henrikki Tenkanen, University of Helsinki @ Geo-Python channel on Youtube.

Lesson 4 - Exercise 3 review

Dave Whipp & Henrikki Tenkanen, University of Helsinki @ Geo-Python channel on Youtube.