CSCI2040: Introduction to Python

General Expectations: Student/Faculty Expectations on Teaching and Learning

Teacher: Prof. John C.S. Lui

This is a 2-unit course which provides an introduction to Python. It is designed to give students fluency in Python, its programming paradigm (such as object-oriented programming and functional programming style), its data structures, as well as various modules and libraries (e.g., NumPy, SciPy, mathplotlib,..etc). The course consists of both lectures and labs with students doing sample Python problems. Problem-based Python assignments will be given which require significant time on Python programming.

IMPORTANT: We assume you have some programming experience and background.

Note that Python is one of the "TOP THREE" programming languages nowaday. Many companies are now using Python (e.g., Google, Facebook, Tencent,..etc), and Python is considered an essential programming language for big data analytics and machine learning. In fact, for the course CSCI3320 (Fundamentals of Machine Learning), it uses the Python language.

Important reminder: Students need to spend time to read resources on the Internet, do the homework, attend the lectures and labs so to understand and keep pace with this course.

Teaching Assistants


Usefule Links:

Course Grades:



Outline for the course:
(Note: I usually prepare more materials than we can cover in a semester. I will leave those materials I can't cover to students as a self-learning tool.)

Optional: Setting up PyDev for Eclipse

Lecture Notes (Lecture Notes are available at CUHK Blackboard (

Lecture 0: Introduction and setup
Lecture 1: Variables, Strings, and Numbers
Lecture 2: Lists and Tuples
Lecture 3: Functions
Lecture 4: If statement and its usage
Lecture 5: Loops and Input Functions
Lecture 6: Terminal apps and Pickle
Lecture 7: Dictionaries
Lecture 8: Functions (advanced topic)
Lecture 9: Object-oriented Programming
Lecture 10: Functional Programming
Lecture 11: Regular Expressions and its processing
Lecture 12: Files and utilities
Lecture 13: NumPy and SciPy
Lecture 14: Visualization
Lecture 14: Optional topics (if time allows)
Lecture 15: Advanced topics: Blockchains (if time allows)

Lab Exercises

Please go to the "Blackboard" to access the specification and testing script of all labs.