- Docente: Paolo Perrotta
- Credits: 3
- Language: English
- Teaching Mode: Traditional lectures
- Campus: Bologna
- Corso: Second cycle degree programme (LM) in Law, Economics and Governance (cod. 5811)
-
from Feb 14, 2025 to Mar 14, 2025
Learning outcomes
The course aims to provide basic proficiency in the following topics: - Why Python: static and dynamic languages, compiled and interpreted languages. - Programming environments: "lightweight" environments, embedded development environments, computational notebooks. - Basic programming constructs: variables, types, operators, expressions - Flow control: conditional, iteration - Data structures: lists and dictionaries - Operations on data: list comprehension, selection, mapping - Organizing code: functions, arguments, and return values - Using existing code: libraries and modules - Programming in the real world: debugging, exception handling, integration
Course contents
The course covers the basics of procedural programming in Python.
1. Programming languages
1.1. What "programming" is about
1.2. Static and dynamic languages
1.3. Compiled and interpreted languages
2. Running Python programs
2.1. The Python interpreter
2.2. Text editors
2.3. IDEs
2.4. Computational notebooks
3. Numeric types
3.1. Ints and floats
3.2. Arithmetic operators
3.3. Random numbers
4. Strings
4.1. Basic string operations
4.2. Numbers vs. digits
4.3. Escaping characters
4.4. String embedding
4.5. Handling user input
5. Variables
5.1. Variable assignment
5.2. String interpolation
5.3. Introducing variables in context
5.4. Naming variables
6. Types and conversions
6.1. Types
6.2. Converting numbers and strings
6.3. Implicit conversions
7. Calling functions and methods
7.1. Functions
7.2. Methods
7.3. Return values
7.4. Arguments
8. Conditionals
8.1. Comparisons
8.2. "if" and "else" constructs
8.3 Nested "if"s
8.4. Logic operators
9. Loops
9.1. "while" loops
9.2. "for" loops
10. Lists
10.1. Accessing and modifying list elements
10.2. Iterating through lists
10.3. Indexing within lists
10.4. Optional topic: List comprehension
11. Libraries
11.1. Optional topic: Importing libraries
Readings/Bibliography
You will find the information that you need to follow the course on Python's official documentation page.
Recommended bibliography for further reading:
If you're looking for a reference textbook, the recommended one is the second edition of "Think Python," by Allen B. Downey. It can be downloaded for free or purchased in print from the author's site .
The structure of the course is adapted (with permission) from the book "Learn to Program" by Chris Pine. However, Pine's book teaches Ruby, a programming language that is similar to, but not the same as, Python. You are still encouraged to check out this book if your goal is to learn programming from scratch and you are not focusing specifically on Python.
Teaching methods
This is a 15-hour in-person, hands-on course. Each lesson includes explanations from the teacher and exercises on the computer.
Students are expected to be proficient in using a personal computer. No prior programming knowledge is required.
Assessment methods
The exam consists of a series of multiple choice written questions.
Teaching tools
The course consists of interactive lessons that combine direct explanations with hands-on programming.
Check out virtuale.unibo.it for resources.
Office hours
See the website of Paolo Perrotta