Course syllabus

Course-PM

DAT171 Object-oriented programming in Python lp3 VT20 (7.5 hp)

Course is offered by the department of Industrial and Materials Science

Contact details

Examiner: Thomas Svedberg, IMS, thomas.svedberg@chalmers.se, tel. 772 1522
Lecturer: Mikael Öhman, Physics, mikael.ohman@chalmers.se, tel. 772 3191 
Lecturer: Hugo Strand, Physics, hugo.strand@chalmers.se, tel. 772 1112

Consultation

Questions are primarily answered at computer sessions and lectures. You are also welcome to visit the teachers for questions. Email is however preferred.

Course purpose

The aim of the course is to provide the students with good opportunities to develop a fundamental understanding of object-oriented programming, particular in Python and how to use standard libraries for development of graphical user interfaces, numerical computations and plotting.

Course literature

[1] C. Horstmann: Python for everyone 3rd ed., ISBN: 978-1-119-63829-2
[2] Python tutorial: https://docs.python.org/3/tutorial/
[3] Python 3 course: http://www.python-course.eu/python3_course.php
[4] NumPy & SciPy references: http://docs.scipy.org/doc/
[5] Matplotlib reference: http://matplotlib.org/contents.html
[6] PyQt 5 reference: http://zetcode.com/gui/pyqt5/ and http://doc.qt.io/qt-5.14
[7] NumPy for Matlab users: https://docs.scipy.org/doc/numpy-1.17.0/user/numpy-for-matlab-users.html

All references to chapters and sections in the course material will also refer to free online material as well for those who choose not to buy the book.

Software

The software will be available on the Windows machines in E-Studion, ES61-62 and the M building. If you want to use your own computer then you have multiple options when installing Python. Make sure to get version 3.6 (or later) and a compatible version of NumPy, SciPy, PyQt, and IPython.
If you are using a Linux machine, the packages should be available in the software repository. Mac and Windows users can get a hold of a Python 3 distribution such as Anaconda at https://www.anaconda.com/distribution/
Installation support for personal laptops are held on the first computer lab.
The editor PyCharm is highly recommended https://www.jetbrains.com/pycharm/download/

Course specific prerequisites

Good working knowledge of basic programming structures such as variables, conditionals, loops and functions in any programming language (for example Matlab).
Students who feel they lack sufficient knowledge in programming can have a look at https://www.learnpython.org (at least the “Learn the Basics” part).

Learning outcome

After successfully passing the course, the student should be able to independently write object oriented software using Python. Furthermore, the student should be able to read reference literature for the Python programming language as well as being able to use the SciPy/NumPy package for numerical computations and PyQt for writing graphical user interfaces.

Course design

The course is given in the form of lectures and tutored hand-in assignments.

Time budget

About 200 work hours per student, where 32 hours are spent on lectures, 48 hours of tutored computer sessions. The assignments are worth 1 hp each and should represent ~26 hours of work per student.

Content

  • Basic building blocks of a Python program (variables, conditional statements, loops, libraries, functions, errors).
  • Data structures (trees, dictionaries, tuples)
  • Object Oriented programming (classes, objects, inheritance, polymorphism, abstract classes).
  • PyQt for creating graphical user interfaces for interactive programs
  • NumPy (Matrices, vectors, linear algebra)
  • SciPy (Package for numerical computations)
  • Matplotlib (Plotting)
  • Interactive Python (IPython)

Examination

Examination form: Examination is in the form an exam where you write solutions (code) to given tasks on provided computers. These solutions are graded.

To pass on the course, the three compulsory computer assignments must have been completed and approved.

The exam will not contain anything on the GUI (5 hours would not be sufficient).

Examination dates: Will take place at 17th of March 2020 in the computer rooms in the SB-building from 8:30-13:30. The re-exams will be on June 9 and August 18.

Note! Last day to register for the exam is March 1!

Internet access will be prevented at the exam, but the PDF version of the Python 3 -, SciPy-, Numpy- and Matplotlib manuals as well as the Lecture Notes will be available on the computers. You are also allowed to bring the course book to the exam.

The exam will consist of 4-5 questions with will be determining the final grade of the course.

Maximum total of 25 points. For passing grade 10 points is required, for grade four 15 points is required, and for grade five 20 points is required. The examination time is 5 hours.

Old exams will be available on the course homepage.

Course evaluation

The course will be evaluated at 2 occurrences throughout the course. In addition, there will be a course survey for all students at the end of the course. The course board representatives are:

Assignments

There will be 3 compulsory assignments, which covers most of the content of the course. The assignments will be performed in groups of two students.

In addition, there will be practice problems available that are not compulsory, but come highly recommended.

Corrections for returned assignments must be handed in before the exam!

Assignment 1:

  • Getting familiar with Python
  • Reading files
  • Using NumPy for numerics
  • Using more advanced data structures (e.g. KDTree and sparse graph library from SciPy)
  • Matplotlib

Assignment 2:

  • Creating a library
  • Creating classes

Assignment 3:

  • Interactive programs
  • Creating a GUI with PyQt
  • Creating classes with multiple inheritance

Knowledge checklist

Before the exam, please go through the checklist to know you have mastered the components of the course!

This list tries to be as detailed as possible

  • Python language
    • Built in documentation: help(...)
    • Variables
    • pass
    • Conditionals: if elif else
    • Looping: for, while, continue, break
    • with as
    • Boolean operators: and, or, in, is, not, ==, !=, <>, <, >, >=, <=, 
    • Bit operators: >>, <<, ~, ^, |, &
    • Arithmetic operators:  +, -, *, /, %, **, //
    • Assignment operators: =, +=, -=, *=, /=, %=, **=, //=
    • Functions
    • Lambda functions / anonymous functions
    • List/set/dictionary comprehensions
    • Exceptions: try, raise, except, finally 
    • Libraries
    • Common errors
    • Documentation with PyDoc
    • *args (e.g.  foo(*x) ➔ foo(x[0], x[1], x[2]) )
  • Common structures
    • Strings
    • Lists (indexing, slicing)
    • Tuples
    • Sets
    • Dictionaries, del
  • Object oriented programming
    • Classes
    • Inheritance and polymorphism
    • Constructors and destructors
    • Abstract methods and decorators
    • Operator overloading
  • NumPy
    • Being able to look up what you need in the reference!
    • numpy.array
    • numpy.linalg
  • SciPy
    • Being able to look up what you need in the reference!
    • scipy.spatial
    • scipy.sparse.csgraph
  • Matplotlib

Schedule

The course schedule is available here: Course schedule DAT171 VT20.pdf

Course summary:

Date Details Due