Unit PRINCIPLES OF PROGRAMMING
- Course
- Mechanical engineering
- Study-unit Code
- A005613
- Curriculum
- In all curricula
- Teacher
- Luca Grilli
- Teachers
-
- Luca Grilli
- Hours
- 54 ore - Luca Grilli
- CFU
- 6
- Course Regulation
- Coorte 2025
- Offered
- 2026/27
- Learning activities
- Base
- Area
- Matematica, informatica e statistica
- Sector
- ING-INF/05
- Type of study-unit
- Obbligatorio (Required)
- Type of learning activities
- Attività formativa monodisciplinare
- Language of instruction
- ITALIAN
- Contents
- The course introduces the principles of programming using Python. It covers fundamental computer science concepts, the main control structures, functions, and data structures (lists, dictionaries, sets, tuples). It also addresses the input/output management and the use of scientific libraries (numpy, matplotlib, pandas). Finally, a brief introduction to object-oriented programming is provided. Practical exercises are focused on solving engineering-related problems.
- Reference texts
- Cay Horstmann, Rance D. Necaise. Python for Everyone (3rd ed). Wiley, 2019.
Tony Gaddis. Starting Out with Python (6th ed). Pearson, 2024.
Also, the following tutorials, books, and online documentation can be helpful for further deepening the various topics covered.
Python Docs — Python.org [https://docs.python.org/]
The Python Tutorial — Python.org [https://docs.python.org/3/tutorial/index.html]
Al Sweigart. Automate the Boring Stuff with Python. [https://automatetheboringstuff.com/] - Educational objectives
- The course aims to provide students with the basic knowledge and skills for solving simple technical, scientific, and engineering problems using Python programming.
By the end of the course, students will be able to:
• write, execute, and debug Python programs;
• understand the fundamental concepts of procedural programming;
• use the main control structures and basic data structures (lists, dictionaries, sets, tuples);
• read and write data to/from files;
• use scientific libraries for managing and processing numerical and graphical data (numpy, matplotlib, pandas);
• understand the basic principles of object-oriented programming;
• apply the concepts learned to solve simple practical problems of a technical-scientific and engineering nature. - Prerequisites
- No prior knowledge is required.
- Teaching methods
- There are two main types of lessons:
• Lectures (80% of the total time): The instructor introduces new theoretical concepts, often accompanied by practical programming examples.
• Guided computer-based exercises (20% of the total time): Students are involved in the design and implementation of programs, under the direct supervision and guidance of the instructor. - Other information
- None.
- Learning verification modality
- The exam consists of a theoretical test to evaluate the understanding of programming concepts and a practical programming test where students will need to apply the knowledge they have acquired.
- Extended program
- Introduction
- Anatomy of a computer.
- System software and application software.
- Information representation.
- A first program in Python.
- Development environments and tools for programming.
Processing numbers and strings
- Variables, numeric types, constants.
- Basic arithmetic operators.
- Fundamental mathematical functions.
- Strings, characters, concatenation, and repetition.
- Conversions between numbers and strings.
- Functions for input acquisition and screen output.
Decision structures and boolean logic
- The if and if-else statements.
- Relational operators.
- Nested branches.
- Multiple alternatives.
- The if-elif-else statement.
- Boolean variables and operators.
Iterative structures
- The while and for loops.
- Nested loops.
- Algorithms using loops.
Functions and modularization
- Definition and use of functions.
- Passing parameters and return values.
- Variable scope.
- Python standard libraries (math, random, time, etc.).
- Modularization: importing and reusing code.
Lists, tables, and tuples
- Basic properties of lists.
- Fundamental list operations.
- Elementary algorithms that operate on lists.
- Two-dimensional lists (tables or matrices).
- Creating and manipulating tuples (immutable lists).
Files and exceptions
- Reading and writing text files.
- Processing files with composite data (records).
- Processing CSV files.
- Introduction to pandas for handling simple tabular data.
- Exception handling.
Sets and dictionaries
- Creating and using sets.
- Basic set operations.
- Creating and using dictionaries.
- Basic dictionary operations.
Introduction to object-oriented programming (OOP)
- Basic concepts: class, object, attributes, methods.
- Simple examples of OOP modeling in mechanical engineering.
- Constructors and encapsulation.
- Brief introduction to inheritance.
Numerical computing and scientific libraries
- Introduction to numpy for vectors and matrices.
- Using matplotlib for data and graph visualization.
- Introduction to scipy for engineering applications (interpolation, fitting, numerical methods).