Course syllabus

Course-PM

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

The course is offered by the department of Industrial and Materials Science.

This page was last updated 2024-01-10.

Contact details

Examiner: Thomas Svedberg, Physics, thomas.svedberg@chalmers.se, tel. 772 1522
Lecturer: Mikael Öhman, Physics, mikael.ohman@chalmers.se, tel. 772 3191 
Assistants: Chia-Jung Hsu, Physics, chiajung.hsu@chalmers.se
                   Ahmet Semih Ertürk, IMS, erturk@chalmers.se

Schedule

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

And in TimeEdit

Consultation

Questions are primarily answered at computer sessions and lectures. You are also welcome to contact the teachers for questions. Email is 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 (optional)
[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: https://matplotlib.org/stable/users/index.html
[6] PyQt 5 reference: http://zetcode.com/gui/pyqt5/ and http://doc.qt.io/qt-5.15
[7] NumPy for Matlab users: https://numpy.org/doc/stable/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

To use your own computer you have multiple options when installing Python. Make sure to get version newer than 3.8 and a compatible version of NumPy, SciPy, PyQt 5, 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/download.
Installation support for personal laptops are held on the first computer labs.
The editor PyCharm is highly recommended https://www.jetbrains.com/pycharm/download/other.html (the Community Edition is free).

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 12th of March 2023 from 8:30-13:30. The re-exams will be on June 5 and August 20.

Note! Last day to register for the exam is February 25!

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 and will be determining the final grade of the course.

Maximum total is 25 points. For a 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.

Please note dates for handing in final corrections of the assignments; Assignment 1: Sunday 25/2, Assignment 2: Sunday 10/3 and Assignment 3: Sunday 17/3! 

Assignment 1:

  • Getting familiar with Python
  • Reading files
  • Using NumPy for numerics
  • Using more advanced data structures
  • 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

 

Course summary:

Date Details Due