First Technology Transfer

Standard and Advanced Technical Training, Consultancy and Mentoring

Course RPI105 RaspberryPi Python Programming - An Introduction

Duration: 5 Days

Intended Audience

Attendees should have a basic understanding of Linux, e.g. as might be acquired by attending the Introduction to the RaspberryPi course and who have chosen Python as their first major programming language to study. You are expected to have a basic knowledge of how to use Linux, both from the desktop and from the command line. You are not expected to be programmers, though a little prior exposure to e.g. Javascript or VBA would not go amiss. As always, a positive attitude to open source software would be most helpful, as would an enthusiasm for exploring and playing around with new technologies.

Course Overview

The goals of this course are to get introduce students to the world of programming using Python as their first, serious, programming language. There have been many discussions over the years regarding the use of Python as the first programming language to teach. Unlike C Python is a high level interpreted language. It is also an extremely effective wrapper and glue language and provide access to many complicated applications written in e.g. C or C++. It can also be used as a scripting language for administering systems whether they be Linux or Microsoft Windows running on a PC, or Linux running on an embedded platform (e.g. the RaspberryPi). Another interesting aspect of Python is that it can support a variety of programming language styles.
This course will cover Python programming not only on Linux systems (PC running Linux, or RaspberryPi running Linux) - but will also, demonstrate the portability of Python by running Python programs on Windows platforms. In the eclectic spirit of FTT's RaspberryPi courses Python scripts communicating with embedded devices such as Arduino or Microchip PIC16/PIC18 devices. [ The necessary C /C++ code to run on the embedded targets will be provided together with instructions for loading and running the code on the selected target device ]

An important purpose of RPI105 is to "teach the teachers". To this end, as well as regular programming labs the course will include labs in which students are required to develop "teaching materials and their associated labs". This is why this course follows the intensive "Boot Camp" format. The "develop labs and teaching materials" sections will take place in the early evening "breakout" sessions. These will be group sessions involving groups of 3 to 4 students. This course will be a "dual mode" course.

Course Benefits

You'll learn how to write Python programs to process text and data, read and write files and communicate over e.g. RS232 and USB with Arduino or PIC16/18 based embedded systems. You will also be shown how to write Python scripts for performs various system administration and configuration tasks on Linux (PC based and RaspberryPi based), and, in the spirit of portability, shown how to develop and run Python applications on Microsoft Windows machines. Hopefully, if you are planning to teach Python at the school level this course will give you some ideas and starting points as to how you might go about setting up a Python curriculum in your school. Some of the ideas in this module have grown out of experiences learned running an Arduino workshop at Europython 2010.

Course Contents

  • First steps
    • How Python became - or a tale of what a restless programmer go up to one Christmas.
    • The upwards and upwards growth of Python and the many fascinating uses Python is being put to these days
    • Installing Python on your PC and on the RaspberryPi.
  • Python - Basic grammar and syntax
    • Basic I/O - print() and raw_input()
    • Comments
    • Variables and Assignment
    • Operators
    • Basic data types - numbers, strings, lists, tuples and dictionaries
    • Code blocks and indentation
    • if, elif and else
    • Iteration
      • for, in and range loops
      • while loops
    • File manipulation - open() and file()functions
    • Errors and Exceptions
    • Functions
    • Packages
  • Introduction to Object Oriented Thinking and Object Oriented Programming
    • What does Object Oriented mean ?
    • Advantages and benefits of object oriented approaches to designing applications
    • Python Classes
    • Python Modules
    • Python Objects
  • Computer Game Programming for Fun, Teaching and Profit
    • Structure of simple computer games
    • Programming problems that need to be solved when implementing a computer game
    • Overview of PyGame
    • Building and extending PyGame programming examples
    • Overview of some other Python game programming frameworks - e.g. Pyglet, Panda3D, GameBlender
    • Objects
  • Overview of more advanced Python topics and applications
    • Note: This will be a fast paced conference style presentation. Specialised courses can be created on demand, and discussed in a Python follow on discussion forum.
    • Regular Expressions
    • Network Programming
    • Internet Client Programming
    • Multithreaded Programming
    • GUI Programming
    • Web Programming
    • Scientific and Mathematical computing
    • Python and Geographic Information Systems
    • Python and Data Analysis and Statistics
  • Python applications to talk to small embedded systems targets, GPIO, motors, servos and sensors
    • Interacting with the GPIO pins - LEDS and Buttons
    • Controlling servos and motors
    • Working with I2C and SPI sensors - temperature, pressure, humidity, accelerometers
    • Talking to Arduino over RS232
    • Talking to PIC16/PIC18 embedded systems over RS232
    • Overview of communicating via ethernet and USB - demonstrations and examples