Basic Python programming

Site: IHE DELFT OPEN COURSEWARE
Course: WaterPIP ToT2 – FAO WaPOR for Water Productivity - Part 1
Book: Basic Python programming
Printed by: Guest user
Date: Tuesday, 26 October 2021, 10:30 AM

1. Introduction

Before using Python programming for Water Productivity analyses in Module 3 and 4, you will be introduced to the concept of Python and how to run Python scripts on a cloud server (Google Colaboratory).

This video will help you learn to:
  • Describe what Python is
  • Give definitions of the main concepts of Python

This tutorial was developed by Dr. Hans van der Kwast for the course "Programming for Geospatial Hydrological Applications"


2. Learn Python basics with Jupyter notebook

Now if you haven't any experience with Python, you'll make your first steps with Python today. You'll learn the basics of Python using an interactive web-based Jupyter Notebook tutorial. The Jupyter Notebook not only gives you theory in text, but you can also run real Python code through and see the output directly on the web.

By launching the Jupyter Notebook on cloud servers, you don't have to install anything on your computer yet and just focus on learning the concepts of Python programming. 

Click on one of the badges below to run the notebook:

Open In Colab (This option requires you to log in with a Google account)

Open In Binder

Once open the notebook, you will see the first content page. There are 10 lessons covering the basics of Python scripting. Click on a lesson and begin learning.

For example, the animated photo below shows how you run the first code cell in Lesson 1 of the notebook:
notebook run

3. Python terminology and libraries

If you are familiar with Python basics now, you might still feel you cannot do a lot with Python. That is true! You cannot do a lot with Python without using libraries. There are many libraries developed in Python for various purposes: data processing, data visualization, machine learning, web scraping, web development,... Later in the next modules, you will learn to use many Python libraries to fetch data from the WaPOR portal automatically, to analyze geospatial data, and to visualize our Water Productivity analyses results.

But what is a library? You will learn it from this video: