Warning: This document is for the development version of Geo-Python. The main version is master.

Lesson overview

This week we will focus on making decisions and repeating tasks in Python. Both of these concepts are part of the larger computing idea called control flow, which refers to how the execution of different parts of a computer program is determined. We will learn how to alter the execution of our scripts are using (1) loops, which are used to repeat execution of parts of a program, and (2) conditional statements, which use basic logical tests to determine which parts of a program will be run.

  1. Definite loops
  2. Conditional statements
  3. Good coding practices - Writing readable code
  4. Exercise 3: for loops and conditional statements

Learning goals

After this weeks lesson your should be able to:

  • Create a for loop and use it to repeat a section of code
  • Use if, elif, and else statements to make decisions in your programs
  • Explain how values can be compared using comparison operators

Lecture

Lesson 3 - Loops and conditional statements

Dave Whipp & Vuokko Heikinheimo, University of Helsinki @ Geo-Python channel on Youtube.