Programming with python
Learning outcomes
• Learn the basics of python programming language.
• Learn hands-on programming with python in interactive environments.
• Learn to work hands-on with basic to advanced python packages.
Evaluation
References
Required/Recommended Text Books:
1. [RB] Scientific Python Lectures (https://lectures.scientific-python.org/)
Additional Reference Material:
1. Python tutorials from W3 Schools. (https://www.w3schools.com/python/)
2. NumPy Basics. (https://numpy.org/doc/stable/user/absolute_beginners.html)
3. SciPy. (https://docs.scipy.org/doc/scipy/tutorial/index.html)
4. Multiprocessing libraries.
(https://docs.python.org/3/library/multiprocessing.html#introduction;
https://docs.python.org/3/library/concurrent.futures.html; https://examples.dask.org/)
5. Flask. (https://flask.palletsprojects.com/en/stable/quickstart/#a-minimal-application)
6. Pandas. (https://pandas.pydata.org/docs/user_guide/10min.html)
7. Python for building web development.
(https://flask.palletsprojects.com/en/stable/quickstart/#a-minimal-application)
8. Pytorch. (https://pytorch.org/get-started/locally/)
Course Outline
Module 1: Getting started with Python
Session(s) Topic References and Hands-
On
1 Overview of the course. Installing Python. Setting up Jupyter Notebook. Chapter 1.1 from RB.
2 Basic data types and operators Chapter 1.2 from RB.
Control Flow: Conditional Statements and Loops. Chapter 1.2 from RB.
3
4 Functions, Modules, Packages, and Exception Handling. Chapter 1.2 from RB.
5 Introduction to Object Oriented Programming. Classes and Objects. Chapter 1.2. from RB.
6 Quiz, followed by session. Chapters 1.1 and 1.2
from RB.
Module 2: Advanced Topics
Session(s) Topic Readings
7 Exception handling, iterators, decorators, and context Chapter 1.2, and Chapter 2 from RB.
managers.
8 and 9 Packages for Scientific Computing in Python: NumPy Chapter 1.3 from RB. Additional References on NumPy and SciPy
and SciPy Basics.
10 Optimizing Programs: Vectorization and Parallelization.
Chapter 2.4 from RB. Additional References on Multiprocessing
libraries.
11 Overview of Domain-specific python packages such as Chapter 3.4 from RB. Additional References on Pandas, Scikit-
pandas, Scikit-learn, Pytorch, and Flask. Learn, Pytorch, and Flask.
12 to 14 Group Project Presentations
Installation
• Download from: https://www.python.org/downloads/
• Install. During installation check any boxes that suggest to add python to PATH.
• From the command line, install the following package
• Jupyter Notebook: pip install notebook
• Jupyter Notebook is an interactive development environment to program. It is
also a web application for creating and sharing computational documents.
Jupyter Notebook
• Combines code, narrative text, equations, and visualizations in a single interactive
document.
• Good for exploratory data analysis and experimenting with machine learning
pipelines.
• Some features: Interactive code execution (cell-based execution), Markdown
support for detailed explanations, Inline visualizations for real-time analysis.
Command line interfaces
• Text-based interface to interact with programs by typing commands. (E.g.,
windows cmd, python REPL, etc.,)
• Lightweight and fast. Suitable for automation and scripting.
• Weaknesses: Steep learning curve for beginners. Limited visualization and
narrative capabilities.
Integrated Development Environments
• Feature-rich environments for software development, offering advanced tools
like debuggers and code completion. (E.g., VS Code)
• Strengths: Comprehensive tools for large-scale development with advanced
debugging capabilities.
• Weakness: Can be resource-intensive. Less interactive for quick experimentation
or analysis.
Programming in python – key principles
• Principles of software development:
• Separation of concerns: Divide a problem along different aspects and tackle each of them
individually. (E.g., separation of technical and managerial tasks in the development process,
of use-case related concerns and implementation-related concerns, etc.,)
• Modularity: Division of a complex system into smaller modules or composition of a complex
system from existing modules. It relates to the first principle – dealing with details of a given
module in isolation and of the integration of different modules into an integrated system.
• Abstraction: Separation of Concerns where high-level use-case related services and features
are separated from their detailed implementation-level programs/codes.
• Generality: Develop general tools or packages anticipating their potential usage.
• Incrementality: Build subsets of an application for early user feedback.
Ghezzi, C., Jazayeri, M., & Mandrioli, D. (1991). Fundamentals of software
engineering. Prentice-Hall, Inc..
Programming in python – key principles
• Software Development Life cycle:
• Requirements elicitation and analysis: requirements expected from the software for a
specific use-case are elicited and analysed for their feasibility in terms of costs and benefits.
• Architectural design: entails a high-level organization of the software system in terms of their
abstract modules and their interactions.
• Detailed design: which provides increasingly detailed information about individual modules
and their precisely defined interfaces.
• Implementation: Actual codes produced by engineers which are integrated and composed as
a running system delivered to a user.
Ghezzi, C., Jazayeri, M., & Mandrioli, D. (1991). Fundamentals of software
engineering. Prentice-Hall, Inc..
Programming in python – key principles
• Object Oriented Perspective:
• Everything is an object.
• Every object is an instance of a class. Or, class is the repository for behaviour associated with
an object.
• Objects communicate by sending and receiving messages (a message is a request for action,
bundled with whatever objects may be necessary to complete the task)
• Objects have their own memory, which consists of other objects.
• Biological metaphor. https://www.youtube.com/watch?v=TbP2B1ijWr8
• Object-Oriented Programming is essentially one simple idea: build small things and compose
them with messages. https://www.aomran.com/object-oriented-programming-is-not-about-objects/