April 2018.
Introduction to coding course.
https://github.com/oliversheridanmethven/introduction_to_coding.
If you have questions about the course, find bugs in the code, discover issues running the code, or anything similar, then please email me at [email protected].
Prior to getting started on this course I strongly recommend doing the following:
- Install Python 2.7 - The latest version is Python 2.7.14 and can be downloaded from the Python downloads webpage.
- Install PyCharm - PyCharm is what we will be using to write and edit code. The community edition is free to use and can be downloaded from the PyCharm downloads webpage.
Don't install these as an administrator, but install them with regular user permissions (default installation).
Python 2.7.
Most of the code will be easily transferable to Python 3, and there may be examples from other languages such as C, JavaScript, etc. Before diving into Python, it is useful to install Python (if using MS Windows). If you are running UNIX/LINUX/OSX then you will most likely already have this installed. To check, open the terminal and type in
python --version
. In this course we will mostly be using Python 2.7 instead of Python 3. This is not a major issue, but there will be some small syntactic differences between the two. (For more information about getting started with Python).The default python version I am using on my machine is Python 2.7.12.
The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code - not in reams of trivial code that bores the reader to death. - Guido van Rossum.
This project will use git large file storage (git lfs
)
for any large files which are not predominantly source code.
(This is easy to install and use on UNIX/LINUX based systems,
and should also be installable on MS Windows with the
appropriate application).
Much of this code will be written using iPython notebooks. These are useful for interactively demonstrating the results from running different source code.
I am generally not a fan of coding notebooks, but occasionally they can be useful. However, they can be a pain when using VCS (such as git). To circumvent committing the output of such notebooks, see the instructions on StackOverflow.
The syllabus and topics we cover are very flexible, and can be heavily influenced by the students taking this course. The first few classes will constitute some of the basic requisites for understanding the building-blocks of the language, but after that any suggestions about topics which students would like me to include (or remove) are encouraged.
Currently there is no homework required for this course, although I will offer various exercises to demonstrate the topics covered. Hopefully you will find this useful practice and interesting. Feedback on this would be highly appreciated. Each lesson will have a file named
exercises
in it, please have a try at the tasks presented here.
The only way to learn a new programming language is by writing programs in it. - Dennis Ritchie.
Programming is a skill best acquired by practice and example rather than from books. - Alan Turing.
Writing your first program in Python. A comparison of the different programming languages and how to write hello world in a variety of languages. We also introduce some of the basics data types, containers, and operators.
We introduce control flow tools like if else
, while
, and for
. We also
show how to take use input, either from a file or interactively, and to output
this either to a file or the screen. We also introduce how to define functions
and consider variable scope.
We introduce the most commonly used packages in Python:
numpy
, pandas
, and matplotlib
. This will introduce the python package
installer pip
, namespaces, and some nice plotting features.
More advanced functionality and function calls are explained,
introducing variable and keyword arguments. Resetting default
values is shown using partial
, and we show how to vectorise
functions with the vectorize
wrapper. This leads to an
introduction of some function wrappers and decorators.
We introduce generators and yield
, and showcase their use with some examples
of prime number generation.
Classes are introduced and we introduce the basic class structure drawing attention to the notion of class variables and methods. We will show the ideas behind class inheritance introducing the notion of the super-class structure for good practice.
Using classes as an example, we will demonstrate the concept of operator overloading.
We introduce the notion of public and private class variables, and demonstrate virtual functions and abstract base classes.
The current list of topics which have been requested by students include:
- Algorithm design and analysis.
- Overview of hardware and underlying processes.
- Difference and similarities between OOP and functional programming.
- Von Neumann architecture:
- Differences between operation limited and bandwidth limited programms.
- CPU and GPU structures.
Hello world
.- Data types:
- Integers.
- Floats.
- Strings.
- Booleans.
- None.
- NaN.
- Containers:
- Lists.
- Sets.
- Dictionaries.
- Tuples.
- Control flow:
- If statements.
- While loops.
- For loops.
- Input and output.
- Functions:
- Lambda functions.
- Packages:
- Numpy.
- Matplotlib.
- Pandas.
- Scipy.
- Sklearn.
pip
.
- Iterators:
- Generators.
- Functions:
- Variable and keyword arguments.
- Recursive functions.
- Partial functions.
- Function wrappers and decorators:
- Meta decorators
- Virtual functions.
- Classes:
- Public and private variables.
- Inheritance.
- Virtual/abstract methods.
super
- LaTeX.
- Storing data:
- JSON.
- Pickling.
- Databases (MongoDB).
- Data-frames, (
pandas.DataFrame
). - Arrays, (
numpy.array
). - Changing values by reference or by copying.
- Machine learning, (
sklearn
). - Symbolic programming, (
sympy
). - Garbage collection.
- Object depth.
- Deep copy and shallow copy.
- System commands.
- Debugging.
- Interacting with different programming languages.
- Automatic testing.
- Executables and compiled python.
- Cython.
- Parallel computing:
- Multicore computing, (
mpi4py
). - GPU coding, (PyCuda).
- Multicore computing, (
- Asynchronous programming.
- Commenting code:
- Style guides, e.g. PEP8.
- Docstrings.
- Sphinx.
- Virtual environments.
- Modular organisation.
- Project structure.
- Unit testing.
- Version control:
- Git.
- Compiled languages, e.g. C, C++.
- Creating websites.
- Algorithm design.
- Pointers.
- Memory management.