B1703 - Introduction to Programming (LM)

Academic Year 2023/2024

  • Teaching Mode: Traditional lectures
  • Campus: Bologna
  • Corso: Second cycle degree programme (LM) in Data, Methods and Theoretical Models For Linguistics (cod. 5946)

Learning outcomes

At the end of the course, the student has the necessary IT background and an appropriate knowledge of programming languages. He can use the acquired knowledge to autonomously design algorithms and data structures. He knows how to work independently, but also to be part of a work group.

Course contents

Learning outcomes

Introduction to Programming provides students with the foundations of computer programming in Python.

After completing this course, the student is able to:

  • Understand basic computer programming concepts that are general to programming languages.

  • Apply coding skills to tackle a variety of practical tasks.

  • Apply coding skills to build realistic analyses and small applications.

  • Select and reuse existing coding resources for the Python language.

  • Understand and apply foundational coding skills to tasks in linguistics.

Course contents

Coding skills are increasingly in demand: they enable us to develop the appropriate applications for processing and analyzing linguistic data, at scale. This course teaches foundational coding skills using Python, a popular programming language. The skills acquired during the course will enable students to get the most out of several more advanced courses in the program.

The practical goal is to show students 1) when and how it is possible and advisable to automate a task or analyze data programmatically; 2) how to develop custom applications, rather than only relying on ready-made ones. To this end, the course introduces foundational programming concepts (variables, data types, flow control, functions, input/output), specific techniques and resources for linguistics (strings, regular expressions, text files), and useful extensions focused on data analysis and visualization, numerical manipulation, Web crawling, and API querying.

The breakdown of the topics is as follows:

Part I (weeks 1-5): Python fundamentals
  1. Why you need to know how to code. Basic notions on how a computer works, algorithms, computability, and programming languages.

  2. Setting up your environment and first steps with notebooks.

  3. Variables, basic data types, type conversion, standard library.

  4. Basic data structures.

  5. Flow control.

  6. Functions, reading/writing files.

  7. Testing and logging your code, documentation.

Part II (weeks 6-10): Python for linguistics
  1. All about strings.

  2. Regular expressions.

  3. Text files, encodings, and useful file formats.

  4. Arrays and matrices with numpy.

  5. Getting data from the Web and using APIs.

  6. Your first data analysis and visualization pipeline (pandas, matplotlib, seaborn).

  7. Object-oriented programming (hints)

Note that this list of topics is tentative and might still change slightly.


Readings/Bibliography

The following resources are recommended for further reading and doing extra exercises:

  • Peroni, Silvio, et al. 'Computational Thinking and Programming', ongoing. https://comp-think.github.io. Chapters 1-4 + exercises.

  • Walsh, Melanie. 'Introduction to Cultural Analytics & Python', 2021. https://melaniewalsh.github.io/Intro-Cultural-Analytics/welcome.html .

  • Tagliaferri, Lisa. 'How to Code in Python', 2021. https://www.digitalocean.com/community/tutorial-series/how-to-code-in-python-3 .

Teaching methods

Recommended prior knowledge

No prior knowledge is required.

Teaching method and contact hours

Lectures, with a lot of live coding, and laboratories, with a lot of exercises. To the extent possible, the provided examples and exercises will be relevant to students in linguistics. All sessions take place in person.

The students can reach out after class, during office hours (please refer to the lecturer's page), and via email (as a last resort).

Teaching materials

The course materials are made available in a public GitHub repository and can be used online via an application called Binder. Instructions will be provided, at the beginning of the course, on how to use the materials, including doing it locally on one's workstation if preferred.

Assessment methods

  • Mid-term exam (20%): consisting of single-choice, multiple-choice, and open questions. In class, pen and paper, no digital devices. This happens in March, between teaching periods.

  • Final exam (30%): consisting of single-choice, multiple-choice, and open questions. In class, pen and paper, no digital devices. Tentatively, this happens in May.

  • Project (50%): a take-home project in small groups (~3 each, +/-1) either proposed by the students or picked from a provided default option. The take-home project consists primarily of coding and the writing of a technical report or documentation. The students can use any available resource to complete it. Ideally, the project is proposed by the students. For example, it can focus on a linguistic analysis of a corpus or the replication of a published study. Every project must be applied and involve substantial coding tasks. The project guidelines will be shared at the beginning of the second part of the course.

Once submitted and positively assessed, the project grade remains valid for the academic year, until complemented by a successful exam. Similarly, the exam can also be conducted before the submission of the project component, and its grade remains valid for the academic year as well.

Students who missed or failed the mid-term exam will be able to do a more extensive written final exam at a later date (tentatively, this happens in June, before the Summer break). If they miss this opportunity as well, they will have to do an oral exam (50%) alongside their project.

The assessment for non-attending students is the same. They may work individually on their project.

To benefit most from the course, it is highly recommended to attend regularly, and do the exams and the project at the earliest opportunity.

Teaching tools

Slides, code with exercises, demonstrations, readings, and seminar discussions.

Classes are held in a classroom equipped with personal computers connected to the Intranet and Internet.

Office hours

See the website of Giovanni Colavizza