Skip to content

Exercises

Welcome to the exercises! These exercises are designed to help you practice and improve your Python skills. Each exercise includes a description, an example, and a task to complete.

In the following you will find an overview of all exercises, including a brief description and the link to the dedicated Google Colab.

Table of Contents

1. Python Basics

The tasks in this exercise cover basic Python concepts such as variables, data types, and control structures. You will practice working with numbers, strings, lists, and dictionaries. As an additional exercise you will be asked to write and read files.

2. Reading and writing of files

The tasks in this exercise cover reading and writing files. You will practice the concepts of file handling and parsing on the example of FASTA files. Here it is asked to read three FASTA files and collect all sequences in a new FASTA file.

3. Extracting properties and translating sequences

The tasks in this exercise cover the extraction of properties and the translation of sequences. You will practice the concepts of string manipulation and translation of DNA sequences into proteins. Here it is asked to extract the length and GC content of a DNA sequence and to translate it into a protein sequence.

4. Data visualisation

The tasks in this exercise cover data visualisation. You will practice the concepts of data visualisation using the Python library Matplotlib and Seaborn. Here it is asked to visualise the GC content and other features of a DNA sequence using different plots. In addition, you will be asked to use Principal Component Analysis (PCA) to visualise a multidimensional dataset.

5. Data clustering

The tasks in this exercise cover data clustering. You will practice the concepts of data clustering using the Python library Scikit-learn. Here it is asked to cluster a dataset of features extracted from DNA sequences using the K-means algorithm. In addition, you will be asked to implement the K-means algorithm from scratch.

6. Object-oriented programming

The tasks in this exercise cover object-oriented programming. You will practice the concepts of classes and objects in Python. Here it is asked to implement a class for DNA sequences and to create objects of this class to perform different operations.

7. Extending classes by methods

The tasks in this exercise cover extending classes by methods. You will extend your class with several methods to perform different operations on DNA sequences. Here it is asked to implement methods to calculate the length, GC content, compute the reverse complement and to translate a DNA sequence into a protein sequence.

8. Inheritance

The tasks in this exercise cover inheritance. You will practice the concepts of inheritance in Python. Here it is asked to implement a parent class for Protein sequences and DNA sequences to unify common properties and methods. Subsequently, you will be asked to create objects of the child classes and to perform different operations.