/basic-python-classes

A set of scripts designed to help novice programmers learn the basics of Python

Primary LanguagePython

A Basic Introduction to Python 2.7

This repo is a collection of Python scripts designed to teach the basics of the language.

Provided that python is installed on your machine, you should be able to run any of these scripts by typing

python scriptname.py

With the exception of boid.py and vector.py, as these define Objects (see below).

If you're using a Mac, it's best to install your own python distribution rather than using the native version (I recommend Anaconda, as it will help you install lots of useful modules as well) The scripts are best considered in the following order:

  1. helloworld.py - the standard first script to run in a new language,
  2. counter.py - a script showing you how to use if statements and loops, and how to import a module
  3. sequences.py - a script showing you how to manipulate datasets (lists, tuples, strings and dictionaries)
  4. filecheck.py - a script showing basic file reading and writing, as well as exceptions (i.e. how to catch your own mistakes)
  5. plotting.py - a script showing how to use numpy and matplotlib to read data and make plots
  6. flocking.py - a script that runs a flocking simulation, using object oriented programming (objects defined in boid.py and vector.py)

This should be enough to begin basic Python programming. It's definitely worth checking out the numpy and matplotlib modules to find all sorts of functions (that you'll never have to write yourself!) to do all kinds of scientific programming.