Dutton Institute
Portfolio

Lesson 2: Python and programming basics

Overview

This lesson has a relatively large amount of reading from the course materials, the Zandbergen text, and the ArcGIS help. I believe you will get a better understanding of the Python concepts as they are explained and demonstrated from several different perspectives. Whenever the examples use the IPython console, I strongly suggest that you type in the code yourself as you follow the examples. This can take some time, but you'll be amazed at how much more information you retain if you try the examples yourself instead of just reading them.

At the end of the lesson, you'll be required to write a Python script that puts together many of the things you've learned. This will go much faster if you've taken the time to read all the required text and work through the examples.

Lesson 2 covers Python fundamentals (many of which are common to other programming languages) and gives you a chance to practice these in a project. To complete this lesson, you are required to do the following:

  1. Download the Lesson 2 data and extract it to C:\PSU\Geog485\Lesson2.
  2. Work through the online sections of the lesson.
  3. Read the remainder of Zandbergen chapters 4-6 that we didn't cover in Lesson 1 and chapter 7.1 - 7.5, and 7.11 (in the Python 3 version of the book) or 11.1 - 11.5 and 11.11 (in the Python 2 version of the book). In the online lesson pages, I have inserted instructions about when it is most appropriate to read each of these chapters. There is more reading this lesson than in a typical week. If you are new to Python, please plan some extra time to read these chapters. There are also some readings this week from the ArcGIS Help.
  4. Complete Project 2 and upload its deliverables to the Lesson 2 drop box. The deliverables are listed in the Project 2 description page.
  5. Complete the Lesson 2 Quiz.

Do items 1 - 3 (including any of the practice exercises you want to attempt) during the first week of the lesson. You will need the second week to concentrate on the project and quiz.

Lesson objectives

By the end of this lesson, you should:

  • understand basic Python syntax for conditional statements and program flow control (if-else, comparison operators, for loop, while loop);
  • be familiar with more advanced data types (strings, lists), string manipulation, and casting between different types;
  • know how to debug code and how to use the debugger;
  • be able to program basic scripts that use conditional statements and loops to automate tasks.