Introductive guide to coding, data cleaning and analysis for Python 3, with many worked exercises.

DOWNLOAD:   PDF    EPUB    HTML    Github

Nowadays, more and more decisions are taken upon factual and objective data. All disciplines, from engineering to social sciences, require to elaborate data and extract actionable information by analysing heterogenous sources. This book of practical exercises gives an introduction to coding and data processing using Python, a programming language popular both in the industry and in research environments.

English version status: mostly usable, completion due by December 2021


November 4, 2021: restructured relational data, added challenges

October 29, 2021: restructured pandas intro page

October 28, 2021: substituted graph stuff in visualization intro with other exercises

October 15, 2021: added formats challenges, moved graph formats and binary relations to relational data section

October 14, 2021 added functions, matrix lists challenges and mixed structures challenges

October 8, 2021 added for, while, sequences challenges

October 7, 2021: added sets, dictionary, if challenges

October 1, 2021: added lists and tuples challenges

September 30, 2021: added string challenges

September 22, 2021:

  • major update, added new exercises and pages

  • added worked projects section

October 3, 2020: updated References page

Old news: link

Intended audience

This book can be useful for both novices who never really programmed before, and for students with more techical background, who a desire to know about about data extraction, cleaning, analysis and visualization (among used frameworks there are Pandas, Numpy and Jupyter editor). We will try to process data in a practical way, without delving into more advanced considerations about algorithmic complexity and data structures. To overcome issues and guarantee concrete didactical results, we will present step-by-step tutorials.


A.2 Control flow

  1. If conditionals:   1.intro    2. challenges

  2. For loops:   1. intro   2. strings   3. lists   4. tuples   5. sets   6. dictionaries

                       7. nested for   8. challenges

  1. While loops   1. intro   2. challenges

  2. Sequences and comprehensions:   1. intro   1. challenges

A.3 Algorithms

  1. Functions:   1. intro   2. error handling and testing

                       3. strings   4. lists   5. tuples 6. sets

  2. Matrices - list of lists:   1. intro   2. other exercises    3. challenges

  3. Mixed structures:   1. intro    2. challenges

  4. Matrices - numpy:   1. intro   2. exercises

B - Data analysis

  1. Data formats:   1. line files   2. CSV files   3. JSON files   4. challenges

  2. Visualization:    1. intro    2. challenges    images

  3. Analytics with Pandas: 1. intro    2. exercises    3. challenge

  4. Relational data: 1. intro    2. binary relations    3. simple statistics    4. challenge

C - Applications

D - Worked projects

E - Appendix


David Leoni: Software engineer specialized in data integration and semantic web, has made applications in open data and medical in Italy and abroad. He frequently collaborates with University of Trento for teaching activities in various departments. Since 2019 is president of CoderDolomiti Association, where along with Marco Caresia manages volunteering movement CoderDojo Trento to teach creative coding to kids. Email:   Website:


Marco Caresia (2017 Autumn Edition assistent @DISI, University of Trento): He has been informatics teacher at Scuola Professionale Einaudi of Bolzano. He is president of the Trentino Alto Adige Südtirol delegatioon of the Associazione Italiana Formatori and vicepresident of CoderDolomiti Association.

Alessio Zamboni (2018 March Edition assistent @Sociology Department, University of Trento): Data scientist and software engineer with experience in NLP, GIS and knowledge management. Has collaborated to numerous research projects, collecting experinces in Europe and Asia. He strongly believes that ‘Programming is a work of art’.

Massimiliano Luca (2019 summer edition teacher @Sociology Department, University of Trento): Loves learning new technilogies each day. Particularly interested in knowledge representation, data integration, data modeling and computational social science. Firmly believes it is vital to introduce youngsters to computer science, and has been mentoring at Coder Dojo DISI Master.


The making of this website and related courses was funded mainly by Department of Information Engineering and Computer Science (DISI), University of Trento, and also Sociology and Mathematics departments.



All the material in this website is distributed with license CC-BY 4.0 International Attribution

Basically, you can freely redistribute and modify the content, just remember to cite University of Trento and the authors

Technical notes: all website pages are easily modifiable Jupyter notebooks, that were converted to web pages using NBSphinx using template Jupman. Text sources are on Github at address


We thank in particular professor Alberto Montresor of Department of Information Engineering and Computer Science, University of Trento to have allowed the making of first courses from which this material was born from, and the project Trentino Open Data ( for the numerous datasets provided.


Other numerous intitutions and companies that over time contributed material and ideas are cited in this page