Session 2 – Programming in Python and using a Raspberry Pi

This session covers the following subjects

  • Python syntax, documentation and tutorials
  • Objects
  • Reading and writing from/to files
  • Text input and output in console
  • Getting the time
  • Hard-coded vs input
  • Logging data to ThingSpeak
  • Basics of Raspberry Pi and Linux
  • Reading analog and digital inputs on a Raspberry Pi
  • Version control and tracking changes using Git, Kdiff, Git Extensions for Windows, and GitHub
  • (Taking over the mouse and keyboard using pyautogui)
  • (Web scraping)

Example programming challenges

  • Write a class for some animal, specify properties and instantiate a few animals of that class.
  • Log the current time and free memory to a text file and Thingspeak
  • Make a simple calculator
  • Write a program for training your multiplication skills
  • Write a program that scrambles an input name so that the order of the letters is changed.
  • Log the timing between button presses (input)
  • Make a conversational robot that reacts to your input with answers/replys randomly chosen from a list.
  • Connect to Hacklab’s server using SSH with putty and create some Python script running there
  • Write a short game based on a story you make up. The user enters a number to choose his action from a list all the time.

Links

Download Python
https://www.python.org/downloads/

Python documentation
https://docs.python.org/3/

Python tutorials
https://www.tutorialspoint.com/python/index.htm

Python objects
http://www.tutorialspoint.com/python/python_classes_objects.htm

Installing Python packages

https://packaging.python.org/tutorials/installing-packages/