This is a practical course designed for chemical engineers that want to learn how to program in Python. The course is very practical and will cover various topics, such as basic Python syntax, solving ODEs, stoichiometry, data visualization and basic data analysis.
Recently, more and more chemical engineering students have expressed the desire to acquire basic programming skills early on in their career, with Python being the most requested language by far. For this reason, we decided to support the regular material taught in the Chemical Reaction Engineering (28342) with an introductory Python course. Therefore, we aim to provide material and practical tutorials to learn Python, so that you have the opportunity to use Python to solve the exercises and assignments.
This course is designed to be very practical, since the best way to learn how to program is by programming. You will start writing and executing code from day 1, through carefully designed exercises. The target of this course is students and professionals in Chemical Engineering that want to learn how to program in Python.
The course may be challenging and overwhelming at the beginning, but don't worry if you don't manage to complete everything. Each week, there will be a mandatory notebook of exercises 01-Exercises and an additional, optional, notebook containing more challenging exercises, for learners that want to test themselves and like to crack the code (pun intended).
Python is one of the most popular languages in use today, thanks to its easy syntax, readability, libraries available and broad documentation. It is open-source, unlike other very popular programs such as MATLAB, which require a license. It has a big community, meaning that other people have probably already asked any possible question you might be having right now. Some forums where to ask and look for questions: StackOverflow (for practical questions about code), StackExchange (for more theoretical questions). It is the to-go language for data analysis and data science, both in academia and industry.
Here you can find instructions how to install Python.
"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements."
— Brian Kernighan, "Unix for Beginners" (1979)
- The best way to learn how to program is by programming. It's normal that you cannot solve everything and you are overwhelmed at the beginning. Don't give up and just practice.
- Write, test and improve code. Do not expect to write a full program in one sitting: most programmers write, test and rewrite code many times before their program works, so do not get discouraged!
- Brainstorm first. Instead of reading a problem and looking for a solution on the Internet, try to think about it yourself. Re-read the problem, brainstorm possible solutions and try to write some code. Make sure that you actually understand what it is asked. Only after you have spent sufficient time on this, look for hints elsewhere.
- Learn to comment your code early on. Before coding, visualize what you plan to do and describe is in plan, non-technical text on paper. Try to be as detailed as possible and include all the steps, even the smallest ones. This will be helpful at the beginning of your coding experience to guide you through the process and ensure you do not forget important steps. Later on, when you are more comfortable coding, it will be helpful for reference for you or other teammates. Remember that just because something seems easy for you, it does not mean your colleague can read your code and understand it right away. This is a very important principle for code deployment.
- Understand what the program is doing. It is important that you understand what your program is doing. Often, it is useful to simply print what you are doing, this is an easy way to visualize, and therefore better understand, the output. This approach is called tracing or printf() debugging, after the print function name in the C language).
We are created other Python courses tailored for Chemical Engineers, such as AI for Chemical Engineers.
If you have any questions regarding the exercises or any feedback on the course, feel free to contact Fiammetta Caccavale ([email protected]).
Please fill in our online survey if you have any feedback. We really appreciate your suggestions and we will try to use them to improve the course.
If you would like to cite this work, please reference our paper: SPyCE: A structured and tailored series of Python courses for (bio)chemical engineers.
@article{CACCAVALE202390,
title = {SPyCE: A structured and tailored series of Python courses for (bio)chemical engineers},
journal = {Education for Chemical Engineers},
volume = {45},
pages = {90-103},
year = {2023},
issn = {1749-7728},
doi = {https://doi.org/10.1016/j.ece.2023.08.003},
url = {https://www.sciencedirect.com/science/article/pii/S1749772823000404},
author = {Fiammetta Caccavale and Carina L. Gargalo and Krist V. Gernaey and Ulrich Krühne},
keywords = {Python in engineering education, Digital education, Programming in engineering curriculum, Artificial Intelligence},
abstract = {In times of educational disruption, significant advances in adopting digitalization strategies have been accelerated. In this transformation climate, engineers should be adequately educated to face the challenges and acquire the new skills imposed by Industry 4.0. Among these, one of the most highly requested tools is Python. To tackle these aspects, this work establishes a pedagogical framework to teach Python to chemical engineers. This is achieved through a hands-on series of Python courses (sPyCE), covering topics as chemical reaction engineering and machine learning. Part of the series has been embedded in the curriculum of a Bachelor’s-level course at the Technical University of Denmark (DTU). Overall, students found the course to be useful; using Python, they solved systems of differential equations, mass and energy balances, set stoichiometric tables, regressions, simulations and more. Motivated by the large applicability and relevance of the covered topics, sPyCE is made publicly available on GitHub.}
}