- Docente: Niccolò Moggi
- Credits: 3
- SSD: ING-IND/18
- Language: Italian
- Teaching Mode: Traditional lectures
- Campus: Bologna
- Corso: First cycle degree programme (L) in Mechanical Engineering (cod. 0927)
-
from Feb 19, 2025 to Jun 11, 2025
Learning outcomes
On completion of this course the students will be able to develop simple algorithms in Python and will be familiar with numeric and graphic libraries.
Course contents
Part I, the bases of the language.
How to interact with Linux OS, how to use a text editor. Mentions to Linux commands. Introduction to VisualStudioCode. How to install Python/Anaconda on your laptop.
Introduction to Python v3. The interpreter. Documentation online. Python grammar and syntax. Arithmetic operators. Types. Objects. Conversions. Reference to objects.String manipulation. Flow control (if, while, for...). Functions and methods. Recursion. The structure of a script: modules and variable sharing. Built-in data structures: Lists, tuples, dictionaries, sets.
Part II, how to use Python to solve practical scientific problems.
The numeric library, the graphic library. Numpy arrays. Arithmetic of Numpy arrays. Matplotlib library. How to generate and visualize plots.
Bases of scientific data analysis. Histograms and normalized distributions, probability density. Simulations and Montecarlo method. Pseudorandom numbers generators. Numerical computation of probabilities. The Metropolis algorithm.
The Scipy package for scientific calculus. Numerical methods for approximation. Numerical approximation of functions. Machine and algorithm errors.
Numerical integration methods with Montecarlo. Integration of functions of many variables.
Readings/Bibliography
No study book is necessary, but a Python manual may be usefull together with a computationa physics text.
Possible suggestions:
- Hans Petter Langtangen, "A Primer on Scientific Programming with Python"
- "How to Think Like a Computer Scientist" (http://openbookproject.net/thinkcs/python/english3e/)
Teaching methods
Lectures will be held in laboratory where a computer will be available for each student.
Large part of the time will be devoted to exercises and practicing.
In each session, after a short introduction, a problem is proposed and students are asked to work on the practical implementation in order to solve it.
The slides show during each day will be available to students on the "Virtuale" platform.
Assessment methods
Some of the practical exercises done during lectures will be graded.
A final practice test is due at the end of the course.
Teaching tools
Overhead projector, computers available in the lab (Linux). It is possible to use your own laptop (Windows, Linux, macOS).
Office hours
See the website of Niccolò Moggi