The goal of this tutorial is to introduce the fundamentals of Python. This tutorial assumes familiarity with at least one other object-oriented programming language such as Java, MATLAB, or Perl.
For a more elementary introduction to Python for individuals with little or no programming experience, we recommend the following five websites. The first four of the websites provide interactive coding exercises.
To get started using Python, we recommend installing Python 3, the pip package manager, the Sublime text editor, and the ipython interactive shell. See Section 2.2.14.1 for more information.
Lists and tuples can both represent ordered series of values. The major difference between lists and tuples is that lists are mutable (elements can be added and removed), whereas tuples are immutable (elements cannot be added or removed). In addition, tuples can be unpacked as illustrated below.
Note, Python variables do not have to be declared and are not typed.
The continue directive can be used to advance to the next iteration of a loop and the break directive can be used to exit a loop.
Note, all Python class attributes are public. The _ prefix is often used to indicate attributes that should be treated as protected and the __ prefix is often used to indicate attributes that should be treated as private.
See intro_to_wc_modeling/concepts_skills/software_engineering/python_introduction.py for solutions to these exercises.