<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk:443/22118/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=WikiSysop</id>
	<title>22118 - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk:443/22118/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=WikiSysop"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php/Special:Contributions/WikiSysop"/>
	<updated>2026-06-19T03:35:38Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Data_analysis&amp;diff=339</id>
		<title>Data analysis</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Data_analysis&amp;diff=339"/>
		<updated>2026-05-27T07:43:06Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
===Description===&lt;br /&gt;
This project is about analyzing specific data and answer various questions about it. The data file is a flat file database constructed in year 2000 with various information about people, and can be seen here as&lt;br /&gt;
[https://teaching.healthtech.dtu.dk/material/22118/people.db people.db].&lt;br /&gt;
The program must read this file ONCE - line by line - not storing the actual lines for future reference, but entering the data in an appropriate data structure of your own devising. The questions are sometimes asking if some distribution is &amp;quot;normal&amp;quot;. &amp;quot;Normal&amp;quot; here does &#039;&#039;&#039;not&#039;&#039;&#039; mean&lt;br /&gt;
fit the bell curve (standard normal distribution). It means reasonable or natural, what you would expect.&amp;lt;br&amp;gt;&lt;br /&gt;
The program must now answer the following questions:&lt;br /&gt;
&lt;br /&gt;
# Is the age and gender distribution normal/sensible in the database? A yes/no answer is not good enough.&lt;br /&gt;
# At what age does the men become fathers first time (max age, min age, average age)?&lt;br /&gt;
# Is the distribution of first-time fatherhood age normal/sensible? A yes/no answer is not good enough.&lt;br /&gt;
# At what age does the women become mothers first time (max age, min age, average age)?&lt;br /&gt;
# Is the distribution of first-time motherhood age normal/sensible? A yes/no answer is not good enough.&lt;br /&gt;
# How many men and women do not have children (in percent)?&lt;br /&gt;
# What is the average age difference between the parents (with a child in common obviously)?&lt;br /&gt;
# How many people has at least one grandparent that is still alive? A person is living if he/she is in the database. State the number both in percent and as a real number.&lt;br /&gt;
# How many has at least one cousin in the data set? What is the average number of cousins based on those who have cousins?&amp;lt;br&amp;gt;Note: This number is historically difficult to compute right, but here are some thoughts to help you out in verifying your count.&amp;lt;br&amp;gt;You have to construct a method for finding cousin pairs. Any cousin pair you identify, can be written as a tuple (cpr1, cpr2) in a list.&amp;lt;br&amp;gt; a) There should be no duplicate tuples in the list - you are not cousins with the same person more than once.&amp;lt;br&amp;gt; b) There should be no tuple with the same cpr on position 1 and 2 - you are not cousins with yourself.&amp;lt;br&amp;gt; c) Because of symmetry, it is expected that for any (cpr1, cpr2) tuple there is a (cpr2, cpr1) tuple - when you are cousins with somebody, somebody is cousins with you. This has natural consequences: Set(cpr1) == Set(cpr2), Sorted_list(cpr1) == Sorted_list(cpr2).&amp;lt;br&amp;gt; d) This list does NOT discover sibling pairs inserted as cousins, however there should be no overlap of this list and a similar list covering sibling pairs.&amp;lt;br&amp;gt; e) The length of the list of cousin tuples is the number of cousin pairs, and the size of the set of cpr&#039;s is the number of people who have cousins.&lt;br /&gt;
# Is the firstborn likely to be male or female?&lt;br /&gt;
# How many men/women (percentage) have children with more than one woman/man?&lt;br /&gt;
# Do tall people marry (or at least get children together)? To answer that, calculate the percentages of tall/tall, tall/normal, tall/short, normal/normal, normal/short, and short/short couples. Decide your own limits for tall, normal and short, and if they are the same for men and women.&lt;br /&gt;
# Do tall parents get tall children?&lt;br /&gt;
# Do fat people marry (or at least get children together)? To answer that, calculate the percentages of fat/fat, fat/normal, fat/slim, normal/normal, normal/slim, and slim/slim couples. Decide your own limits for fat, normal and slim. Calculate the BMI, and let that be the fatness indicator.&lt;br /&gt;
# Using the knowledge of [https://en.wikipedia.org/wiki/Blood_type#ABO_blood_group_system blood group type inheritance], are there any children in the database where you can safely say that at least one of the parents are not the real parent. If such children exists, make a list of them. In the report you must discuss how you determine that the parent(s) of the child are not the &amp;quot;true&amp;quot; parents.&lt;br /&gt;
# Make a list of fathers who can donate blood to their sons. The list must identify the father and the son(s) and their blood type. You must write the length of the list in the report, together with the number of fathers and the number of sons.&lt;br /&gt;
# Make a list of persons who can donate blood to at least one of their grandparents. The list must identify must the person, the grandparent(s) and their blood type. You must write the length of the list in the report, together with the number of grandchildren and the number of grandparents.&lt;br /&gt;
&lt;br /&gt;
All questions has to answered in one run of the program, but not necessarily in that order. You are welcome to answer other interesting questions, that can be posed from the data. Many questions are about distributions and if the distributions are &amp;quot;normal&amp;quot;. The program can calculate the distributions, but the analysis of the result (evaluating normalcy) is to be in the report.&lt;br /&gt;
I will come with an example: &amp;quot;Is the distribution of first-time fatherhood age normal? A yes/no answer is not good enough.&amp;quot; You must at least calculate and print something like:&lt;br /&gt;
 Age       Percentage&lt;br /&gt;
 16-20:    5%&lt;br /&gt;
 21-25:    10%&lt;br /&gt;
 26-30:    40%&lt;br /&gt;
 31-35:    30%&lt;br /&gt;
 36-40:    15%&lt;br /&gt;
 41-45:	  0%&lt;br /&gt;
From that you simply evaluate if it is normal and put it in the report. I think above numbers are rather normal, but below are very strange. If you want to, you can support your opinions with references to [https://www.dst.dk/en/ Statistics Denmark].&lt;br /&gt;
 Age       Percentage&lt;br /&gt;
 16-20:    0%&lt;br /&gt;
 21-25:    0%&lt;br /&gt;
 26-30:    10%&lt;br /&gt;
 31-35:    20%&lt;br /&gt;
 36-40:    50%&lt;br /&gt;
 41-45:	  20%&lt;br /&gt;
&lt;br /&gt;
The problem you should solve in the project is not &amp;quot;how to make good statistics&amp;quot;, but &amp;quot;how to collect the data from the database&amp;quot;. If you feel you can do better statistics than above, you are welcome.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tip&#039;&#039;&#039;: For the sanity of the questions you should assume/pretend you are doing this analysis primo 2000.&amp;lt;br&amp;gt; &lt;br /&gt;
&#039;&#039;&#039;Tip&#039;&#039;&#039;: The CPR consists of a date part (first 6 numbers as DDMMYY) which is the birthday, and a 4 digit number. There are rules about how CPR should be constructed, and they are not followed since it is illegal to publish CPR numbers. What you need to know is that the date part is a date in 1900-1999, and the last digit is significant; odd - male, even - female.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Tip&#039;&#039;&#039;: The data are somewhat randomly constructed, so you can find &#039;facts&#039; that seem very unlikely, like 6 year old kids with a height of 2 m. Just accept it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Tip&#039;&#039;&#039;: In the database the children of a person is clear. This means you can follow a thread &#039;&#039;down&#039;&#039; the generations. As can be seen from some of the questions, it can nice to find the parents directly from a child, i.e follow a thread &#039;&#039;up&#039;&#039; the generations. Can you find a way to do this easily?&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Fun fact&#039;&#039;&#039;: A journalist once called me to know more about the database, smelling a privacy leak scandal in the making, This is the reason why the data set is strange in various ways. There should be no suspicion of a leak - expect maybe to journalists who would rather create sensational news than do a proper fact finding job.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Searching_for_motifs_in_sequences&amp;diff=338</id>
		<title>Searching for motifs in sequences</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Searching_for_motifs_in_sequences&amp;diff=338"/>
		<updated>2026-05-21T16:39:27Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Input and output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
===Description===&lt;br /&gt;
A sequence motif is typically a short sequence pattern of DNA or amino acid sequence that is conserved across various gene families or organisms. Sequence motifs are recognizable and could be a promoter, a binding site or a domain that folds into a specific structure. The mechanism for finding motifs is often Hidden Markov Models or Neural Networks, which both require a lot of examples of the motif to work, but here you will explore a different method, which just needs a consensus sequence (or what you think the consensus sequence is). It uses a model where sites in the sequence are weighted after importance and finds those matches which are close.&amp;lt;br&amp;gt;&lt;br /&gt;
The program is given a fasta file with DNA or amino acid sequences and a file containing a description of the signal to search for. It will then display all occurrences of a match in each fasta entry.&lt;br /&gt;
&lt;br /&gt;
===Input and output===&lt;br /&gt;
The program is given a fasta file, a signal description file and a deviation (a number) as input on the command line. Deviation is the deviation allowed from the original signal description.&lt;br /&gt;
The fasta file can contain more than one sequence/entry.&lt;br /&gt;
The signal description file is a tab separated file. Each line consists of either&lt;br /&gt;
1) one or more allowed letters at this position and a penalty for having a mismatch at that position.&lt;br /&gt;
2) the star character * denoting unimportant characters in the sequence and an interval where these unimportant characters are allowed.&lt;br /&gt;
3) the hash character # meaning this line is a comment, and should be ignored by the program.&lt;br /&gt;
&lt;br /&gt;
As an example of a signal description file, here is a prokaryotic promoter, which is a 2-parts signal that can be described as:&lt;br /&gt;
&lt;br /&gt;
 # -35 element&lt;br /&gt;
 T	7&lt;br /&gt;
 T	8&lt;br /&gt;
 G	6&lt;br /&gt;
 A	5&lt;br /&gt;
 C	5&lt;br /&gt;
 A	5&lt;br /&gt;
 # intervening unimportant bases&lt;br /&gt;
 *	15-21&lt;br /&gt;
 # -10 element&lt;br /&gt;
 T	8&lt;br /&gt;
 A	8&lt;br /&gt;
 T	6&lt;br /&gt;
 A	6&lt;br /&gt;
 AT	5&lt;br /&gt;
 T	8&lt;br /&gt;
&lt;br /&gt;
The output should list all matches in each fasta entry, clearly stating the location of the match.&amp;lt;br&amp;gt;&lt;br /&gt;
Note that a description file can describe a simple 1-part signal, a 2-part signal as shown here, a 3-part signal by adding another *-line plus bases, and so forth. It is strongly preferred that the program can handle all such cases.&lt;br /&gt;
&lt;br /&gt;
===Details===&lt;br /&gt;
The deviation is an important factor. If the deviation is set to 0, then search for the signal is reduced to an exact match. If the deviation is set to 16 in the above example, then mismatches with the combined penalty of 16 or less are allowed. In the promoter example the following signals would match (ignoring intervening bases, not complete list):&lt;br /&gt;
 TTGXXX*TATAAT&lt;br /&gt;
 TTGACA*XXTAAT&lt;br /&gt;
 TTGXXA*TAXAAT&lt;br /&gt;
&lt;br /&gt;
Note: I do not consider an approach based heavily on regular expression as a good idea, but you are free to do as you like. Due to the flexibility in the signal caused by the gaps, several different matches can be found from a specific position in the sequence. You should find all matches, not just the first one.&lt;br /&gt;
It needs to be understood that the program/algorithm is completely general and can search for any kind of signal in any kind of text sequences. It is not limited to life science.&lt;br /&gt;
&lt;br /&gt;
Fasta file to use as example in the projects: [https://teaching.healthtech.dtu.dk/material/22118/motif.fsa motif.fsa]&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Aligning_expectations&amp;diff=337</id>
		<title>Aligning expectations</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Aligning_expectations&amp;diff=337"/>
		<updated>2026-05-12T08:43:17Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* The project work */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is expected from you ==&lt;br /&gt;
=== Fulfilling prerequisites ===&lt;br /&gt;
A course like [https://kurser.dtu.dk/course/22116 22116/22166 Python programming in Life Science] should enable you for this course.&amp;lt;br&amp;gt;&lt;br /&gt;
Generally speaking, you must know simple Python well, which means you know the basic syntactical structure of Python (assignment, expressions, if, for while, some functions/methods), some data types (integer, float, string, lists, sets, dicts), and trivial file reading and writing, such that you relatively easy can solve minor programming tasks without any use of libraries. You can check if your abilities are up to par by solving some of the exercises in 22116/22166 above.&amp;lt;br&amp;gt;&lt;br /&gt;
You must have your own computer (Windows, Mac, Linux) and you must understand it&#039;s file system structure - the folder hierarchy, file types, and file organization.&lt;br /&gt;
&lt;br /&gt;
=== Special expectations ===&lt;br /&gt;
In the first weeks you learn Unix. You must work in this environment for the rest of the course. Unix is used in a number of (bioinformatic) courses, and being able to navigate in  Unix is not only a survival skill, but also a skill sought in industry. All major bioinformatic efforts take place on big Unix servers/clusters.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In hand-ins you follow the skills taught in 22116, specifically how to write comments, using spacing to modularize the code, proper variable (object) naming, proper use of variables, error handling and code clarity, see [[Code construction]].&lt;br /&gt;
&lt;br /&gt;
=== Standard expectations ===&lt;br /&gt;
* You follow the course every week and hand in the required weekly exercises on DTU Learn.&lt;br /&gt;
* You peer-evaluate every week on DTU Learn. A hand-in is required for evaluation to be allowed.&lt;br /&gt;
* You do a project with a peer (i.e. a two person group project) at the end of the course.&lt;br /&gt;
* When getting help, understand that many students need help. You can not expect us to sit an hour with you. If time actually allows for it, we do not mind doing it.&lt;br /&gt;
&lt;br /&gt;
=== Knowing the roles at the university ===&lt;br /&gt;
By knowing the roles of the various entities, you know where to direct your question.&lt;br /&gt;
* &#039;&#039;&#039;The teacher&#039;&#039;&#039; is responsible for the content of the course, the curriculum, the teaching, the project evaluation, the making and evaluation of the exam, and the reporting of cheating. In short - any content.&lt;br /&gt;
* &#039;&#039;&#039;The study office&#039;&#039;&#039; - and by extension - the exam office, the study guidance, and the legal office (cheating) deal with everything that is not course content. A lot of information is available on [https://student.dtu.dk/en/ Student DTU] among that exam dates and what to do when having problems with the studies. They also process and publish the grades handed in by the teacher.&lt;br /&gt;
&lt;br /&gt;
== Course structure ==&lt;br /&gt;
The course is week-based, meaning new subjects are introduced Monday, and we work with them during the week. Sometimes smaller subjects are introduced Thursdays.&lt;br /&gt;
In the last month of the course a programming project will be made in 2-person groups.&lt;br /&gt;
&lt;br /&gt;
=== Exercises ===&lt;br /&gt;
* Weekly exercises are given every Monday. This constitutes an exercise set. There will be 12 of those. Exercises are mandatory.&lt;br /&gt;
* Exercises have to be uploaded to [https://learn.dtu.dk DTU Learn] latest Sunday in the same week as the exercises were given.&lt;br /&gt;
* Peer evaluation of exercises are done in the following week on [https://learn.dtu.dk DTU Learn] to be handed in Friday. The evaluations are mandatory.&lt;br /&gt;
* At least 10 of 12 evaluations must be handed in on DTU Learn for you to be allowed to take the exam. You can only evaluate if you have handed in exercises.&lt;br /&gt;
* Word or pdf documents are NOT accepted as hand-in - use only simple &#039;&#039;&#039;.txt&#039;&#039;&#039; or &#039;&#039;&#039;.py&#039;&#039;&#039; files. Sometimes, like with unit test, an entire folder structure should be zipped and uploaded.&amp;lt;br&amp;gt;&lt;br /&gt;
* Solutions to each week&#039;s exercises are published before the next week&#039;s lesson on DTU Learn (under Discussions). Can be used as reference for peer evaluation.&lt;br /&gt;
* Exercises which are handed in after the solutions are published, are voided and will not count, no matter the reason for being late.&lt;br /&gt;
* Do not read ahead and start using functions/methods/libraries which will be covered later in the course.&lt;br /&gt;
* &amp;lt;font color=&amp;quot;AA00FF&amp;quot;&amp;gt;&#039;&#039;&#039;Purple exercises&#039;&#039;&#039; has to be done in pseudo code before you start implementing them in Python. The pseudo code is part of the hand-in for these exercises.&amp;lt;br&amp;gt;So - make the pseudocode FIRST, then the real python programs AFTERWARDS for the purple exercises.&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Why &amp;amp; How to peer-evaluate exercises ===&lt;br /&gt;
The peer evaluation is a central part of the learning process, using formative feedback. You can get input from your peers on how you can solve an exercise. &amp;lt;!--The evaluation scheme has a lot of targeted questions about various aspects of the code you will have to evaluate, which will help you understand how you should develop your programs. Initially, it can seem overwhelming, but since the questions repeat week after week, and you mostly have to check boxes, it will get easier during the course.--&amp;gt; You learn both by doing the evaluation and by receiving (reading) it.&lt;br /&gt;
&lt;br /&gt;
You must use the criteria in [[Code construction]] in your own programs and the evaluation.&lt;br /&gt;
&lt;br /&gt;
=== Projects, general information ===&lt;br /&gt;
* A project is done with two students in each group, no exceptions unless there is an odd number of students, in which case a one (wo)man group is formed. The teacher will form the groups, but will accept already formed groups, if informed in time, see the google sheet found via the Course Overview in Content at DTU Learn.&lt;br /&gt;
* Each group will choose a project from the [[Project list]] in the last part of the course. If a group has an idea for a different project, this must be discussed with the teacher to see if it is feasible. Such a &amp;quot;home made&amp;quot; project must be of sufficient complexity, but not too complex either, and have clear goals, so it can be measured if it was failed or not.&lt;br /&gt;
* A project is estimated to be doable in 50 hours of work - people often use more time.&lt;br /&gt;
* The group must work together using git and GitHub when developing the program. If the report is written in LateX, or other pure text-based format, git could also be used here.&lt;br /&gt;
* The project work consists of two phases; 1) Doing a project - making code and writing report. 2) Individual (not in the group) peer evaluation of another groups project. Thus every project is peer evaluated twice. Both phases are mandatory.&lt;br /&gt;
* The teacher will evaluate all projects and peer evaluations. Understand that YOUR evaluation of another groups project is part of YOUR project work, and as such it will be part of YOUR grade.&lt;br /&gt;
* The project work will count for 50% of the final grade. The project grade is thus combined from the group effort of doing a project and the individual effort of peer grading a project.&lt;br /&gt;
* The project will be handed in through DTU Learn at the time written in the [[Programme]].&lt;br /&gt;
* The teacher will distribute the projects per mail for peer evaluation with the intention of NOT evaluation the same type of project you made. &lt;br /&gt;
* The evaluation of another groups project will be handed in 1 week later on DTU Learn.&lt;br /&gt;
&lt;br /&gt;
=== Getting help with the project ===&lt;br /&gt;
* The groups can consult the teacher and the TA&#039;s on problems with the projects. The teacher has the best overview, while TA&#039;s often can only help with actual problems in the code.&lt;br /&gt;
* Groups can talk to each other on their project, but actual cooperation between groups with the same project is not allowed. Here is a simple and clear rule:&amp;lt;br&amp;gt;&#039;&#039;&#039;Groups must not show any written material (typically code or report) to any other group&#039;&#039;&#039;.&lt;br /&gt;
* Consulting Google on programming issues is fine, but understand what is being said/written and why it works.&lt;br /&gt;
* Nothing but Python libraries which have been taught in the course can be used in projects. Consult the teacher if in doubt.&lt;br /&gt;
* The teacher should be informed if a group is dysfunctional. We will work something out.&lt;br /&gt;
&lt;br /&gt;
=== Content of the project ===&lt;br /&gt;
Each project consists of:&lt;br /&gt;
* A report, preferably in PDF. &lt;br /&gt;
* The program code.&lt;br /&gt;
* Any data files of relevance &#039;&#039;&#039;not&#039;&#039;&#039; supplied through the course.&lt;br /&gt;
* A signed version of this [https://teaching.healthtech.dtu.dk/material/22118/ProjectStatement22118.pdf statement]. &amp;lt;div style=&amp;quot;color:red;display:inline;&amp;quot;&amp;gt;DO NOT FORGET&amp;lt;/div&amp;gt; It is unfortunate when students fail because they forget a mandatory element.&lt;br /&gt;
* The teacher must have access to the project repo. Make sure to invite &#039;&#039;peterwadsackett&#039;&#039; or attach a zipped repo when handing in.&lt;br /&gt;
&lt;br /&gt;
==== The report itself ====&lt;br /&gt;
The report should be written is such a way that it can be understood by your peer (fellow student), who have no knowledge of the specifics of your project. I have provided some sources of help, for writing reports, etc. at university level.&amp;lt;br&amp;gt;&lt;br /&gt;
* PDF: [https://teaching.healthtech.dtu.dk/material/22113/Vejledning_i_opbygning_og_skrivning_af_rapporter_v.2013.3.pdf Vejledning i opbygning og skrivning af rapporter]&lt;br /&gt;
* PDF: [https://teaching.healthtech.dtu.dk/material/22113/how_to_write_reports.pdf Guide on how to write a report]&lt;br /&gt;
* Online: [https://www.elsevier.com/connect/11-steps-to-structuring-a-science-paper-editors-will-take-seriously How to structure a science paper]&lt;br /&gt;
* PDF: [https://www.imm.dtu.dk/~janba/MastersThesisAdvice.pdf Master Thesis Advice]&lt;br /&gt;
* Online: [https://thereader.mitpress.mit.edu/umberto-eco-how-to-write-a-thesis/ How to write a thesis]&lt;br /&gt;
&lt;br /&gt;
It is considered unlikely that that the report is less than 4 pages, but there is no set limitation.&lt;br /&gt;
The report is evaluated by quality, not by length. Some projects are naturally heavy in theory,&lt;br /&gt;
others have a more practical approach, and the report is expected to reflect that to some extent.&lt;br /&gt;
&lt;br /&gt;
The following sections can/should be in the report in approximately this order:&amp;lt;br&amp;gt;&lt;br /&gt;
* Introduction - mandatory&lt;br /&gt;
* Contribution - mandatory&lt;br /&gt;
* Theory - mandatory&lt;br /&gt;
* Algorithm design - mandatory&lt;br /&gt;
* Program design - mandatory&lt;br /&gt;
* Program manual - mandatory&lt;br /&gt;
* Results - optional, depends a bit on the project if it is natural to include&lt;br /&gt;
* Runtime analysis - mandatory&lt;br /&gt;
* Unit Testing - mandatory&lt;br /&gt;
* Conclusion - mandatory&lt;br /&gt;
* References - mandatory if any references&lt;br /&gt;
&lt;br /&gt;
The sections are explained in detail below. It is important that the report reads naturally with easy flow from one subject to the next. It should also be a coherent logical structure. As an example you must explain a concept/system/method before you use it - not use it first and later tell what it means. Nor should you write the same thing twice. The report must cover all sections in some form, but as the projects are different, different emphasis will be placed on the different sections. An example is that the Theory section is important for project 9-11, but much less important and &amp;quot;theoretical&amp;quot; for project 1,3,4,5. Results are really important in project 5 and 6, but much less in the rest. The sections on &amp;quot;Theory&amp;quot;, &amp;quot;Algorithm design&amp;quot; and &amp;quot;Program design&amp;quot; can sometimes content-wise overlap each other depending on the nature of the project - it can be a question of simply drawing a line.&lt;br /&gt;
&lt;br /&gt;
==== The code ====&lt;br /&gt;
* The program code as &#039;&#039;&#039;.py&#039;&#039;&#039; or &#039;&#039;&#039;.txt&#039;&#039;&#039; files. It is a separate file from the report.&lt;br /&gt;
* The code should be clearly structured and well commented so it is possible to follow your thinking.&lt;br /&gt;
* The major data structures should also be explained with structure and purpose.&lt;br /&gt;
* The code should obviously follow the guidelines that has been given during the course in exercises.&lt;br /&gt;
* Unit testing of at least part of the code should be included. This can be done as a separate folder with test and test data.&lt;br /&gt;
&lt;br /&gt;
==== Report sections ====&lt;br /&gt;
* &#039;&#039;&#039;Introduction&#039;&#039;&#039; - A short section explaining why your project and program is important and useful and in which context it should be used. Can also be used to introduce some background.&lt;br /&gt;
* &#039;&#039;&#039;Contribution&#039;&#039;&#039; - The should be made clear, who contributed to which parts of the project, if the contributions are uneven or clearly split up. For a group that worked closely together (the best), it is completely fine to write &amp;quot;equal contribution&amp;quot; from all members, if such is the case and it is not clear who has the main contribution. &amp;quot;Equal contribution&amp;quot; is also fine for situations where the main author of pieces of code and sections of reports changes in the group such that both members have roughly contributed evenly on both programming and writing. Caveat: If you write &amp;quot;equal contribution&amp;quot; you will pass or fail together.&lt;br /&gt;
* &#039;&#039;&#039;Theory&#039;&#039;&#039; - If you have math, equations, systems, ideas that lies behind the code you do, then it should be described and explained here. Any &amp;quot;facts&amp;quot; that you are using in the code or programming against should be described in this section. High-level decisions you make, that affects how the code will work, could be described - could be using a specific library.&lt;br /&gt;
* &#039;&#039;&#039;Algorithm design&#039;&#039;&#039; -  Every project has at least one &amp;quot;core&amp;quot; algorithm or method that the project revolves about. In this section you explain &#039;&#039;how&#039;&#039; the core algorithm(s) works. Pseudo code is great for making a structure you can explain it from. Some people use diagrams.&lt;br /&gt;
* &#039;&#039;&#039;Program design&#039;&#039;&#039; - This is where you give an overview of your program: &#039;&#039;where&#039;&#039; are your functions, &#039;&#039;where&#039;&#039; is your input and output, &#039;&#039;where&#039;&#039; is the main core. To show the structural overview of your program, pseudo code is again a great method.&lt;br /&gt;
* &#039;&#039;&#039;Program manual&#039;&#039;&#039; - Describe how to use the program(s), input format, various program options, expected output, example runs. Some screenshots works great here.&lt;br /&gt;
* &#039;&#039;&#039;Results&#039;&#039;&#039; -  Show/describe/list your results of the program runs in this section.&lt;br /&gt;
* &#039;&#039;&#039;Runtime analysis&#039;&#039;&#039; -  In this section you analyze the performance of the program in Big O terms, see [[Runtime evaluation of algorithms]]. You must present calculations supported by arguments, not just results.&lt;br /&gt;
* &#039;&#039;&#039;Unit Testing&#039;&#039;&#039; - Write a small section about what unit test you made on what sections of the code. Disclose if you found errors by writing the tests.&lt;br /&gt;
* &#039;&#039;&#039;Conclusion&#039;&#039;&#039; -  Talk about the results you achieved, if you have not done so already. Discuss strength and weaknesses of the program/algorithm. Future goals or improvements.&lt;br /&gt;
* &#039;&#039;&#039;References&#039;&#039;&#039; - If you used articles, web resources, or other information sources during the project, these need to be stated here.&lt;br /&gt;
Some people thinks the algorithm design overlaps a lot with program design, and while there is some truth to that, then algorithm design is detailed about the central algorithm/part, while program design gives an overview of the code, so a reader can easily find the section of interest.&lt;br /&gt;
&lt;br /&gt;
=== How to evaluate the project ===&lt;br /&gt;
The projects consists of two very different parts: The report and the program/code. They must be evaluated in different ways, but both evaluations must result in some written text.&amp;lt;br&amp;gt;&lt;br /&gt;
Here is a [https://teaching.healthtech.dtu.dk/material/22118/projectevaltemplate.docx template evaluation document], which you can use if you wish.&lt;br /&gt;
==== The report ====&lt;br /&gt;
The report should be evaluated on form and content. It should be understood that the report must be well structured and argued, so somebody not familiar with the subject can understand it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Form:&#039;&#039;&#039; This consists of spelling, meaningful sentences, good language. Importantly, the sections as described above must be present. The sections: &amp;quot;Theory&amp;quot;, &amp;quot;Algorithm design&amp;quot; and &amp;quot;Program design&amp;quot; should be appropriate for the project type and some flexibility is allowed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Content:&#039;&#039;&#039; The content should obviously be correct and be evaluated in the light of the descriptions of the different report sections above.&lt;br /&gt;
&lt;br /&gt;
==== The program(s) ====&lt;br /&gt;
The code is evaluated on our usual criteria for exercises as can be seen on [[Code construction]] and in peer evaluation for the exercises. I will shortly mention correctness, structure, readability as the main focus.&lt;br /&gt;
&lt;br /&gt;
== Passing the course ==&lt;br /&gt;
The grade in the course is pass/fail. You have to do satisfactory (pass) in the project work.&amp;lt;br&amp;gt;&lt;br /&gt;
Furthermore, the weekly exercises + peer evaluations are mandatory. At least 10 out of 12 exercise sets + peer evaluations must be handed in to get your project evaluated for passing.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The project work ===&lt;br /&gt;
In the project all aids are allowed, like books, powerpoints, google, teachers, or knowledge sources. Being overly dependent on AI for your solution is not accepted. Make sure you understand what you are told/read. Uncritical copy/paste is not going to help you or the project. Make references when relevant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;&#039;&#039;&#039;All aids&#039;&#039;&#039;&amp;quot; does not cover what normally constitutes cheating, like copying other students work or copying from solutions found on the internet or using libraries that solves substantial parts of the problem for you.&lt;br /&gt;
&lt;br /&gt;
The teacher will grade the project work. It consists of 3 parts. The report, the code and the peer evaluation.&amp;lt;br&amp;gt;&lt;br /&gt;
The project work addresses the following &#039;&#039;&#039;learning objectives&#039;&#039;&#039;, some only partly:&lt;br /&gt;
* Use the command line of Unix with 10-15 common Unix commands, inclusive file system navigation, pipelines, process and file system control.&lt;br /&gt;
* Demonstrate and explain the python syntax, object mode, data structures, classes and 65-70 Python methods/functions.&lt;br /&gt;
* Exercise pattern recognition in (bioinformatic) data files in order to extract information.&lt;br /&gt;
* Apply methods/programming techniques demonstrated in the course to similar problems.&lt;br /&gt;
* Analyze a (programming) problem and ascertain its components, and create an efficient solution by applying the right components in the right order.&lt;br /&gt;
* Analyze a program and based on its behavior, locate and eradicate errors.&lt;br /&gt;
* Evaluate the quality of the code, based on criteria shown in the course, and ensuring the code meets quality standards by employing the unit test technique.&lt;br /&gt;
* Write clear, precise and well documented code, which is suitable for greater collaborative efforts.&lt;br /&gt;
* Evaluate the performance and efficiency of code with respect to speed and memory consumption using Big O notation.&lt;br /&gt;
* Utilize code libraries, both scientific and other, for fast and good solution of programming tasks.&lt;br /&gt;
The project will be evaluated on a overall view of how well it answers the problems stated in the project description. Below are various elements specified.&lt;br /&gt;
&lt;br /&gt;
==== General engineering competences relevant for the project work ====&lt;br /&gt;
Ability to write coherent text, to form proper sentences in English, to finish a consistent quality product (head lines, TOC, no missing words or figures, using same words for concepts, using the right scientific word/concept, etc.). Ability to collaborate both in writing text and programming code with other people.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the report, which will form the foundation of the evaluation ====&lt;br /&gt;
* Analyze the project formulation and develop a method/algorithm for solving the problem.&lt;br /&gt;
* Clearly describe theoretical aspects of the project and/or algorithm; this could be mathematical foundation, input file data formats, categories used, prerequisites and assumptions, data structure elements or clever ideas.&lt;br /&gt;
* Clearly and coherently describe the algorithm and relevant data structures.&lt;br /&gt;
* When designing an algorithm, it can suffer from performance problems, which can be related to both speed and excessive use of memory. Can you recognize the shortcomings in your own algorithm? &lt;br /&gt;
* Show the proper use of pseudo code.&lt;br /&gt;
* Appropriate use of figures, graphs, illustrations and screenshots.&lt;br /&gt;
* Demonstrate the actual structure of the finished program, so the reader can understand what is going on where when seeing the code.&lt;br /&gt;
* Evaluate what is trivial and what is not, and focus on explaining the non-trivial things in the program.&lt;br /&gt;
* Understand and clearly describe a runtime evaluation of your code in Big O notation.&lt;br /&gt;
* Present results from the project in a relevant and clear fashion.&lt;br /&gt;
* See the perspective of your project. Where can it be used? What can be improved? What did you learn?&lt;br /&gt;
* Building a project is a creative process. Let that creativity shine through.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the code, which will form the foundation of the evaluation ====&lt;br /&gt;
During the course you have been presented for many skills and competences in the peer evaluation and through that gained a good grasp of the easier coding skills.&lt;br /&gt;
* Correct commenting in code, placement and content&lt;br /&gt;
* Spacing and modularization&lt;br /&gt;
* Object naming&lt;br /&gt;
* Using appropriate amount and type of variables for the task.&lt;br /&gt;
* Error handling &lt;br /&gt;
The project demands more of the in-depth coding skills.&lt;br /&gt;
* Avoiding simple structural flaws&lt;br /&gt;
* Ability to write clear and precise code.&lt;br /&gt;
* Writing concise code.&lt;br /&gt;
* Writing sensible and meaningful code. This is not included by above points.&lt;br /&gt;
* This point is about significant performance problems not related to an inherent problem with the algorithm (which is covered in the report).&lt;br /&gt;
# Recognizing and avoiding unnecessary loops or methods which slow the speed of the program. &lt;br /&gt;
# Recognizing and avoiding unnecessary use of computer memory.&lt;br /&gt;
* Reach for beauty and elegance. That happens when it all comes together in a clear and obvious chain of events that leads to the result.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the peer evaluation ====&lt;br /&gt;
* You will use many of the competences used in your own report and code.&lt;br /&gt;
* Ability to critically read and evaluate text and foreign code (see through bullshit).&lt;br /&gt;
&lt;br /&gt;
== Failing the course ==&lt;br /&gt;
The exercises are mandatory. You must hand-in minimum 10 of the 12. Likewise you must peer-evaluate 10 out of 12 times. You can&#039;t peer-evaluate if you do not hand in. Failing to achieve this will make you fail the course - no matter the state of your project.&amp;lt;br&amp;gt;&lt;br /&gt;
The exercises do not count in passing the course, but consistently doing poorly in exercises is not going to aid the project.&lt;br /&gt;
&lt;br /&gt;
=== Failing the project ===&lt;br /&gt;
The reasons for failing the project are usually:&lt;br /&gt;
* more than one severe, game changing mistake has been made in the code.&lt;br /&gt;
* severe misunderstandings about the content/purpose of the project.&lt;br /&gt;
* too low quality in the report.&lt;br /&gt;
* too low quality in the code.&lt;br /&gt;
* insufficient contribution in either code or report.&lt;br /&gt;
The first two could somewhat easily be avoided by consulting the teacher.&amp;lt;br&amp;gt;&lt;br /&gt;
For the last reasons... you need to up your game; Take the time to write a decent report - there are resources available on how to do that.&amp;lt;br&amp;gt;&lt;br /&gt;
Insufficient contribution often has an underlying course in insufficient coding skills.&amp;lt;br&amp;gt;&lt;br /&gt;
The code can/must be improved by learning more during the course - study the exercises and the solutions.&lt;br /&gt;
&lt;br /&gt;
The 4 challenges for failing students are:&lt;br /&gt;
* difficulty in analyzing the problem - understanding what has to be done.&lt;br /&gt;
* difficulty in formulating a strategy for solving the problem - designing the method/algorithm.&lt;br /&gt;
* difficulty in executing the strategy - transforming the method/idea into working code.&lt;br /&gt;
* difficulty in making the code coherent - having the grand overview of the method/code.&lt;br /&gt;
&lt;br /&gt;
There are lots of mistakes a student can do; insufficient knowledge of python (syntax and functions), bad performance, repetitive code, missing variables, wrongly iterating loops, missing the right position of sequences etc., but they are not disastrous on the individual level - although they reflect your skill. The problem is when many mistakes/omissions come together and form a mix of the 4 challenges.&lt;br /&gt;
&lt;br /&gt;
How to improve: Practice, practice, and then some practice. You can not read it in a book or powerpoint. That helps in knowing the syntax and functions of python, but that is not the issue. The issue is training your brain in the analyzing, formulating and executing phases of coherent programming.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Aligning_expectations&amp;diff=336</id>
		<title>Aligning expectations</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Aligning_expectations&amp;diff=336"/>
		<updated>2026-05-12T08:42:09Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* How to evaluate the project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is expected from you ==&lt;br /&gt;
=== Fulfilling prerequisites ===&lt;br /&gt;
A course like [https://kurser.dtu.dk/course/22116 22116/22166 Python programming in Life Science] should enable you for this course.&amp;lt;br&amp;gt;&lt;br /&gt;
Generally speaking, you must know simple Python well, which means you know the basic syntactical structure of Python (assignment, expressions, if, for while, some functions/methods), some data types (integer, float, string, lists, sets, dicts), and trivial file reading and writing, such that you relatively easy can solve minor programming tasks without any use of libraries. You can check if your abilities are up to par by solving some of the exercises in 22116/22166 above.&amp;lt;br&amp;gt;&lt;br /&gt;
You must have your own computer (Windows, Mac, Linux) and you must understand it&#039;s file system structure - the folder hierarchy, file types, and file organization.&lt;br /&gt;
&lt;br /&gt;
=== Special expectations ===&lt;br /&gt;
In the first weeks you learn Unix. You must work in this environment for the rest of the course. Unix is used in a number of (bioinformatic) courses, and being able to navigate in  Unix is not only a survival skill, but also a skill sought in industry. All major bioinformatic efforts take place on big Unix servers/clusters.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In hand-ins you follow the skills taught in 22116, specifically how to write comments, using spacing to modularize the code, proper variable (object) naming, proper use of variables, error handling and code clarity, see [[Code construction]].&lt;br /&gt;
&lt;br /&gt;
=== Standard expectations ===&lt;br /&gt;
* You follow the course every week and hand in the required weekly exercises on DTU Learn.&lt;br /&gt;
* You peer-evaluate every week on DTU Learn. A hand-in is required for evaluation to be allowed.&lt;br /&gt;
* You do a project with a peer (i.e. a two person group project) at the end of the course.&lt;br /&gt;
* When getting help, understand that many students need help. You can not expect us to sit an hour with you. If time actually allows for it, we do not mind doing it.&lt;br /&gt;
&lt;br /&gt;
=== Knowing the roles at the university ===&lt;br /&gt;
By knowing the roles of the various entities, you know where to direct your question.&lt;br /&gt;
* &#039;&#039;&#039;The teacher&#039;&#039;&#039; is responsible for the content of the course, the curriculum, the teaching, the project evaluation, the making and evaluation of the exam, and the reporting of cheating. In short - any content.&lt;br /&gt;
* &#039;&#039;&#039;The study office&#039;&#039;&#039; - and by extension - the exam office, the study guidance, and the legal office (cheating) deal with everything that is not course content. A lot of information is available on [https://student.dtu.dk/en/ Student DTU] among that exam dates and what to do when having problems with the studies. They also process and publish the grades handed in by the teacher.&lt;br /&gt;
&lt;br /&gt;
== Course structure ==&lt;br /&gt;
The course is week-based, meaning new subjects are introduced Monday, and we work with them during the week. Sometimes smaller subjects are introduced Thursdays.&lt;br /&gt;
In the last month of the course a programming project will be made in 2-person groups.&lt;br /&gt;
&lt;br /&gt;
=== Exercises ===&lt;br /&gt;
* Weekly exercises are given every Monday. This constitutes an exercise set. There will be 12 of those. Exercises are mandatory.&lt;br /&gt;
* Exercises have to be uploaded to [https://learn.dtu.dk DTU Learn] latest Sunday in the same week as the exercises were given.&lt;br /&gt;
* Peer evaluation of exercises are done in the following week on [https://learn.dtu.dk DTU Learn] to be handed in Friday. The evaluations are mandatory.&lt;br /&gt;
* At least 10 of 12 evaluations must be handed in on DTU Learn for you to be allowed to take the exam. You can only evaluate if you have handed in exercises.&lt;br /&gt;
* Word or pdf documents are NOT accepted as hand-in - use only simple &#039;&#039;&#039;.txt&#039;&#039;&#039; or &#039;&#039;&#039;.py&#039;&#039;&#039; files. Sometimes, like with unit test, an entire folder structure should be zipped and uploaded.&amp;lt;br&amp;gt;&lt;br /&gt;
* Solutions to each week&#039;s exercises are published before the next week&#039;s lesson on DTU Learn (under Discussions). Can be used as reference for peer evaluation.&lt;br /&gt;
* Exercises which are handed in after the solutions are published, are voided and will not count, no matter the reason for being late.&lt;br /&gt;
* Do not read ahead and start using functions/methods/libraries which will be covered later in the course.&lt;br /&gt;
* &amp;lt;font color=&amp;quot;AA00FF&amp;quot;&amp;gt;&#039;&#039;&#039;Purple exercises&#039;&#039;&#039; has to be done in pseudo code before you start implementing them in Python. The pseudo code is part of the hand-in for these exercises.&amp;lt;br&amp;gt;So - make the pseudocode FIRST, then the real python programs AFTERWARDS for the purple exercises.&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Why &amp;amp; How to peer-evaluate exercises ===&lt;br /&gt;
The peer evaluation is a central part of the learning process, using formative feedback. You can get input from your peers on how you can solve an exercise. &amp;lt;!--The evaluation scheme has a lot of targeted questions about various aspects of the code you will have to evaluate, which will help you understand how you should develop your programs. Initially, it can seem overwhelming, but since the questions repeat week after week, and you mostly have to check boxes, it will get easier during the course.--&amp;gt; You learn both by doing the evaluation and by receiving (reading) it.&lt;br /&gt;
&lt;br /&gt;
You must use the criteria in [[Code construction]] in your own programs and the evaluation.&lt;br /&gt;
&lt;br /&gt;
=== Projects, general information ===&lt;br /&gt;
* A project is done with two students in each group, no exceptions unless there is an odd number of students, in which case a one (wo)man group is formed. The teacher will form the groups, but will accept already formed groups, if informed in time, see the google sheet found via the Course Overview in Content at DTU Learn.&lt;br /&gt;
* Each group will choose a project from the [[Project list]] in the last part of the course. If a group has an idea for a different project, this must be discussed with the teacher to see if it is feasible. Such a &amp;quot;home made&amp;quot; project must be of sufficient complexity, but not too complex either, and have clear goals, so it can be measured if it was failed or not.&lt;br /&gt;
* A project is estimated to be doable in 50 hours of work - people often use more time.&lt;br /&gt;
* The group must work together using git and GitHub when developing the program. If the report is written in LateX, or other pure text-based format, git could also be used here.&lt;br /&gt;
* The project work consists of two phases; 1) Doing a project - making code and writing report. 2) Individual (not in the group) peer evaluation of another groups project. Thus every project is peer evaluated twice. Both phases are mandatory.&lt;br /&gt;
* The teacher will evaluate all projects and peer evaluations. Understand that YOUR evaluation of another groups project is part of YOUR project work, and as such it will be part of YOUR grade.&lt;br /&gt;
* The project work will count for 50% of the final grade. The project grade is thus combined from the group effort of doing a project and the individual effort of peer grading a project.&lt;br /&gt;
* The project will be handed in through DTU Learn at the time written in the [[Programme]].&lt;br /&gt;
* The teacher will distribute the projects per mail for peer evaluation with the intention of NOT evaluation the same type of project you made. &lt;br /&gt;
* The evaluation of another groups project will be handed in 1 week later on DTU Learn.&lt;br /&gt;
&lt;br /&gt;
=== Getting help with the project ===&lt;br /&gt;
* The groups can consult the teacher and the TA&#039;s on problems with the projects. The teacher has the best overview, while TA&#039;s often can only help with actual problems in the code.&lt;br /&gt;
* Groups can talk to each other on their project, but actual cooperation between groups with the same project is not allowed. Here is a simple and clear rule:&amp;lt;br&amp;gt;&#039;&#039;&#039;Groups must not show any written material (typically code or report) to any other group&#039;&#039;&#039;.&lt;br /&gt;
* Consulting Google on programming issues is fine, but understand what is being said/written and why it works.&lt;br /&gt;
* Nothing but Python libraries which have been taught in the course can be used in projects. Consult the teacher if in doubt.&lt;br /&gt;
* The teacher should be informed if a group is dysfunctional. We will work something out.&lt;br /&gt;
&lt;br /&gt;
=== Content of the project ===&lt;br /&gt;
Each project consists of:&lt;br /&gt;
* A report, preferably in PDF. &lt;br /&gt;
* The program code.&lt;br /&gt;
* Any data files of relevance &#039;&#039;&#039;not&#039;&#039;&#039; supplied through the course.&lt;br /&gt;
* A signed version of this [https://teaching.healthtech.dtu.dk/material/22118/ProjectStatement22118.pdf statement]. &amp;lt;div style=&amp;quot;color:red;display:inline;&amp;quot;&amp;gt;DO NOT FORGET&amp;lt;/div&amp;gt; It is unfortunate when students fail because they forget a mandatory element.&lt;br /&gt;
* The teacher must have access to the project repo. Make sure to invite &#039;&#039;peterwadsackett&#039;&#039; or attach a zipped repo when handing in.&lt;br /&gt;
&lt;br /&gt;
==== The report itself ====&lt;br /&gt;
The report should be written is such a way that it can be understood by your peer (fellow student), who have no knowledge of the specifics of your project. I have provided some sources of help, for writing reports, etc. at university level.&amp;lt;br&amp;gt;&lt;br /&gt;
* PDF: [https://teaching.healthtech.dtu.dk/material/22113/Vejledning_i_opbygning_og_skrivning_af_rapporter_v.2013.3.pdf Vejledning i opbygning og skrivning af rapporter]&lt;br /&gt;
* PDF: [https://teaching.healthtech.dtu.dk/material/22113/how_to_write_reports.pdf Guide on how to write a report]&lt;br /&gt;
* Online: [https://www.elsevier.com/connect/11-steps-to-structuring-a-science-paper-editors-will-take-seriously How to structure a science paper]&lt;br /&gt;
* PDF: [https://www.imm.dtu.dk/~janba/MastersThesisAdvice.pdf Master Thesis Advice]&lt;br /&gt;
* Online: [https://thereader.mitpress.mit.edu/umberto-eco-how-to-write-a-thesis/ How to write a thesis]&lt;br /&gt;
&lt;br /&gt;
It is considered unlikely that that the report is less than 4 pages, but there is no set limitation.&lt;br /&gt;
The report is evaluated by quality, not by length. Some projects are naturally heavy in theory,&lt;br /&gt;
others have a more practical approach, and the report is expected to reflect that to some extent.&lt;br /&gt;
&lt;br /&gt;
The following sections can/should be in the report in approximately this order:&amp;lt;br&amp;gt;&lt;br /&gt;
* Introduction - mandatory&lt;br /&gt;
* Contribution - mandatory&lt;br /&gt;
* Theory - mandatory&lt;br /&gt;
* Algorithm design - mandatory&lt;br /&gt;
* Program design - mandatory&lt;br /&gt;
* Program manual - mandatory&lt;br /&gt;
* Results - optional, depends a bit on the project if it is natural to include&lt;br /&gt;
* Runtime analysis - mandatory&lt;br /&gt;
* Unit Testing - mandatory&lt;br /&gt;
* Conclusion - mandatory&lt;br /&gt;
* References - mandatory if any references&lt;br /&gt;
&lt;br /&gt;
The sections are explained in detail below. It is important that the report reads naturally with easy flow from one subject to the next. It should also be a coherent logical structure. As an example you must explain a concept/system/method before you use it - not use it first and later tell what it means. Nor should you write the same thing twice. The report must cover all sections in some form, but as the projects are different, different emphasis will be placed on the different sections. An example is that the Theory section is important for project 9-11, but much less important and &amp;quot;theoretical&amp;quot; for project 1,3,4,5. Results are really important in project 5 and 6, but much less in the rest. The sections on &amp;quot;Theory&amp;quot;, &amp;quot;Algorithm design&amp;quot; and &amp;quot;Program design&amp;quot; can sometimes content-wise overlap each other depending on the nature of the project - it can be a question of simply drawing a line.&lt;br /&gt;
&lt;br /&gt;
==== The code ====&lt;br /&gt;
* The program code as &#039;&#039;&#039;.py&#039;&#039;&#039; or &#039;&#039;&#039;.txt&#039;&#039;&#039; files. It is a separate file from the report.&lt;br /&gt;
* The code should be clearly structured and well commented so it is possible to follow your thinking.&lt;br /&gt;
* The major data structures should also be explained with structure and purpose.&lt;br /&gt;
* The code should obviously follow the guidelines that has been given during the course in exercises.&lt;br /&gt;
* Unit testing of at least part of the code should be included. This can be done as a separate folder with test and test data.&lt;br /&gt;
&lt;br /&gt;
==== Report sections ====&lt;br /&gt;
* &#039;&#039;&#039;Introduction&#039;&#039;&#039; - A short section explaining why your project and program is important and useful and in which context it should be used. Can also be used to introduce some background.&lt;br /&gt;
* &#039;&#039;&#039;Contribution&#039;&#039;&#039; - The should be made clear, who contributed to which parts of the project, if the contributions are uneven or clearly split up. For a group that worked closely together (the best), it is completely fine to write &amp;quot;equal contribution&amp;quot; from all members, if such is the case and it is not clear who has the main contribution. &amp;quot;Equal contribution&amp;quot; is also fine for situations where the main author of pieces of code and sections of reports changes in the group such that both members have roughly contributed evenly on both programming and writing. Caveat: If you write &amp;quot;equal contribution&amp;quot; you will pass or fail together.&lt;br /&gt;
* &#039;&#039;&#039;Theory&#039;&#039;&#039; - If you have math, equations, systems, ideas that lies behind the code you do, then it should be described and explained here. Any &amp;quot;facts&amp;quot; that you are using in the code or programming against should be described in this section. High-level decisions you make, that affects how the code will work, could be described - could be using a specific library.&lt;br /&gt;
* &#039;&#039;&#039;Algorithm design&#039;&#039;&#039; -  Every project has at least one &amp;quot;core&amp;quot; algorithm or method that the project revolves about. In this section you explain &#039;&#039;how&#039;&#039; the core algorithm(s) works. Pseudo code is great for making a structure you can explain it from. Some people use diagrams.&lt;br /&gt;
* &#039;&#039;&#039;Program design&#039;&#039;&#039; - This is where you give an overview of your program: &#039;&#039;where&#039;&#039; are your functions, &#039;&#039;where&#039;&#039; is your input and output, &#039;&#039;where&#039;&#039; is the main core. To show the structural overview of your program, pseudo code is again a great method.&lt;br /&gt;
* &#039;&#039;&#039;Program manual&#039;&#039;&#039; - Describe how to use the program(s), input format, various program options, expected output, example runs. Some screenshots works great here.&lt;br /&gt;
* &#039;&#039;&#039;Results&#039;&#039;&#039; -  Show/describe/list your results of the program runs in this section.&lt;br /&gt;
* &#039;&#039;&#039;Runtime analysis&#039;&#039;&#039; -  In this section you analyze the performance of the program in Big O terms, see [[Runtime evaluation of algorithms]]. You must present calculations supported by arguments, not just results.&lt;br /&gt;
* &#039;&#039;&#039;Unit Testing&#039;&#039;&#039; - Write a small section about what unit test you made on what sections of the code. Disclose if you found errors by writing the tests.&lt;br /&gt;
* &#039;&#039;&#039;Conclusion&#039;&#039;&#039; -  Talk about the results you achieved, if you have not done so already. Discuss strength and weaknesses of the program/algorithm. Future goals or improvements.&lt;br /&gt;
* &#039;&#039;&#039;References&#039;&#039;&#039; - If you used articles, web resources, or other information sources during the project, these need to be stated here.&lt;br /&gt;
Some people thinks the algorithm design overlaps a lot with program design, and while there is some truth to that, then algorithm design is detailed about the central algorithm/part, while program design gives an overview of the code, so a reader can easily find the section of interest.&lt;br /&gt;
&lt;br /&gt;
=== How to evaluate the project ===&lt;br /&gt;
The projects consists of two very different parts: The report and the program/code. They must be evaluated in different ways, but both evaluations must result in some written text.&amp;lt;br&amp;gt;&lt;br /&gt;
Here is a [https://teaching.healthtech.dtu.dk/material/22118/projectevaltemplate.docx template evaluation document], which you can use if you wish.&lt;br /&gt;
==== The report ====&lt;br /&gt;
The report should be evaluated on form and content. It should be understood that the report must be well structured and argued, so somebody not familiar with the subject can understand it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Form:&#039;&#039;&#039; This consists of spelling, meaningful sentences, good language. Importantly, the sections as described above must be present. The sections: &amp;quot;Theory&amp;quot;, &amp;quot;Algorithm design&amp;quot; and &amp;quot;Program design&amp;quot; should be appropriate for the project type and some flexibility is allowed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Content:&#039;&#039;&#039; The content should obviously be correct and be evaluated in the light of the descriptions of the different report sections above.&lt;br /&gt;
&lt;br /&gt;
==== The program(s) ====&lt;br /&gt;
The code is evaluated on our usual criteria for exercises as can be seen on [[Code construction]] and in peer evaluation for the exercises. I will shortly mention correctness, structure, readability as the main focus.&lt;br /&gt;
&lt;br /&gt;
== Passing the course ==&lt;br /&gt;
The grade in the course is pass/fail. You have to do satisfactory (pass) in the project work.&amp;lt;br&amp;gt;&lt;br /&gt;
Furthermore, the weekly exercises + peer evaluations are mandatory. At least 10 out of 12 exercise sets + peer evaluations must be handed in to get your project evaluated for passing.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The project work ===&lt;br /&gt;
In the project all aids are allowed, like books, powerpoints, google, teachers, or knowledge sources. Being overly dependent on AI for your solution is not accepted. Make sure you understand what you are told/read. Uncritical copy/paste is not going to help you or the project. Make references when relevant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;&#039;&#039;&#039;All aids&#039;&#039;&#039;&amp;quot; does not cover what normally constitutes cheating, like copying other students work or copying from solutions found on the internet or using libraries that solves the entire problem for you.&lt;br /&gt;
&lt;br /&gt;
The teacher will grade the project work. It consists of 3 parts. The report, the code and the peer evaluation.&amp;lt;br&amp;gt;&lt;br /&gt;
The project work addresses the following &#039;&#039;&#039;learning objectives&#039;&#039;&#039;, some only partly:&lt;br /&gt;
* Use the command line of Unix with 10-15 common Unix commands, inclusive file system navigation, pipelines, process and file system control.&lt;br /&gt;
* Demonstrate and explain the python syntax, object mode, data structures, classes and 65-70 Python methods/functions.&lt;br /&gt;
* Exercise pattern recognition in (bioinformatic) data files in order to extract information.&lt;br /&gt;
* Apply methods/programming techniques demonstrated in the course to similar problems.&lt;br /&gt;
* Analyze a (programming) problem and ascertain its components, and create an efficient solution by applying the right components in the right order.&lt;br /&gt;
* Analyze a program and based on its behavior, locate and eradicate errors.&lt;br /&gt;
* Evaluate the quality of the code, based on criteria shown in the course, and ensuring the code meets quality standards by employing the unit test technique.&lt;br /&gt;
* Write clear, precise and well documented code, which is suitable for greater collaborative efforts.&lt;br /&gt;
* Evaluate the performance and efficiency of code with respect to speed and memory consumption using Big O notation.&lt;br /&gt;
* Utilize code libraries, both scientific and other, for fast and good solution of programming tasks.&lt;br /&gt;
The project will be evaluated on a overall view of how well it answers the problems stated in the project description. Below are various elements specified.&lt;br /&gt;
&lt;br /&gt;
==== General engineering competences relevant for the project work ====&lt;br /&gt;
Ability to write coherent text, to form proper sentences in English, to finish a consistent quality product (head lines, TOC, no missing words or figures, using same words for concepts, using the right scientific word/concept, etc.). Ability to collaborate both in writing text and programming code with other people.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the report, which will form the foundation of the evaluation ====&lt;br /&gt;
* Analyze the project formulation and develop a method/algorithm for solving the problem.&lt;br /&gt;
* Clearly describe theoretical aspects of the project and/or algorithm; this could be mathematical foundation, input file data formats, categories used, prerequisites and assumptions, data structure elements or clever ideas.&lt;br /&gt;
* Clearly and coherently describe the algorithm and relevant data structures.&lt;br /&gt;
* When designing an algorithm, it can suffer from performance problems, which can be related to both speed and excessive use of memory. Can you recognize the shortcomings in your own algorithm? &lt;br /&gt;
* Show the proper use of pseudo code.&lt;br /&gt;
* Appropriate use of figures, graphs, illustrations and screenshots.&lt;br /&gt;
* Demonstrate the actual structure of the finished program, so the reader can understand what is going on where when seeing the code.&lt;br /&gt;
* Evaluate what is trivial and what is not, and focus on explaining the non-trivial things in the program.&lt;br /&gt;
* Understand and clearly describe a runtime evaluation of your code in Big O notation.&lt;br /&gt;
* Present results from the project in a relevant and clear fashion.&lt;br /&gt;
* See the perspective of your project. Where can it be used? What can be improved? What did you learn?&lt;br /&gt;
* Building a project is a creative process. Let that creativity shine through.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the code, which will form the foundation of the evaluation ====&lt;br /&gt;
During the course you have been presented for many skills and competences in the peer evaluation and through that gained a good grasp of the easier coding skills.&lt;br /&gt;
* Correct commenting in code, placement and content&lt;br /&gt;
* Spacing and modularization&lt;br /&gt;
* Object naming&lt;br /&gt;
* Using appropriate amount and type of variables for the task.&lt;br /&gt;
* Error handling &lt;br /&gt;
The project demands more of the in-depth coding skills.&lt;br /&gt;
* Avoiding simple structural flaws&lt;br /&gt;
* Ability to write clear and precise code.&lt;br /&gt;
* Writing concise code.&lt;br /&gt;
* Writing sensible and meaningful code. This is not included by above points.&lt;br /&gt;
* This point is about significant performance problems not related to an inherent problem with the algorithm (which is covered in the report).&lt;br /&gt;
# Recognizing and avoiding unnecessary loops or methods which slow the speed of the program. &lt;br /&gt;
# Recognizing and avoiding unnecessary use of computer memory.&lt;br /&gt;
* Reach for beauty and elegance. That happens when it all comes together in a clear and obvious chain of events that leads to the result.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the peer evaluation ====&lt;br /&gt;
* You will use many of the competences used in your own report and code.&lt;br /&gt;
* Ability to critically read and evaluate text and foreign code (see through bullshit).&lt;br /&gt;
&lt;br /&gt;
== Failing the course ==&lt;br /&gt;
The exercises are mandatory. You must hand-in minimum 10 of the 12. Likewise you must peer-evaluate 10 out of 12 times. You can&#039;t peer-evaluate if you do not hand in. Failing to achieve this will make you fail the course - no matter the state of your project.&amp;lt;br&amp;gt;&lt;br /&gt;
The exercises do not count in passing the course, but consistently doing poorly in exercises is not going to aid the project.&lt;br /&gt;
&lt;br /&gt;
=== Failing the project ===&lt;br /&gt;
The reasons for failing the project are usually:&lt;br /&gt;
* more than one severe, game changing mistake has been made in the code.&lt;br /&gt;
* severe misunderstandings about the content/purpose of the project.&lt;br /&gt;
* too low quality in the report.&lt;br /&gt;
* too low quality in the code.&lt;br /&gt;
* insufficient contribution in either code or report.&lt;br /&gt;
The first two could somewhat easily be avoided by consulting the teacher.&amp;lt;br&amp;gt;&lt;br /&gt;
For the last reasons... you need to up your game; Take the time to write a decent report - there are resources available on how to do that.&amp;lt;br&amp;gt;&lt;br /&gt;
Insufficient contribution often has an underlying course in insufficient coding skills.&amp;lt;br&amp;gt;&lt;br /&gt;
The code can/must be improved by learning more during the course - study the exercises and the solutions.&lt;br /&gt;
&lt;br /&gt;
The 4 challenges for failing students are:&lt;br /&gt;
* difficulty in analyzing the problem - understanding what has to be done.&lt;br /&gt;
* difficulty in formulating a strategy for solving the problem - designing the method/algorithm.&lt;br /&gt;
* difficulty in executing the strategy - transforming the method/idea into working code.&lt;br /&gt;
* difficulty in making the code coherent - having the grand overview of the method/code.&lt;br /&gt;
&lt;br /&gt;
There are lots of mistakes a student can do; insufficient knowledge of python (syntax and functions), bad performance, repetitive code, missing variables, wrongly iterating loops, missing the right position of sequences etc., but they are not disastrous on the individual level - although they reflect your skill. The problem is when many mistakes/omissions come together and form a mix of the 4 challenges.&lt;br /&gt;
&lt;br /&gt;
How to improve: Practice, practice, and then some practice. You can not read it in a book or powerpoint. That helps in knowing the syntax and functions of python, but that is not the issue. The issue is training your brain in the analyzing, formulating and executing phases of coherent programming.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Aligning_expectations&amp;diff=335</id>
		<title>Aligning expectations</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Aligning_expectations&amp;diff=335"/>
		<updated>2026-05-11T15:36:54Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Content of the project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is expected from you ==&lt;br /&gt;
=== Fulfilling prerequisites ===&lt;br /&gt;
A course like [https://kurser.dtu.dk/course/22116 22116/22166 Python programming in Life Science] should enable you for this course.&amp;lt;br&amp;gt;&lt;br /&gt;
Generally speaking, you must know simple Python well, which means you know the basic syntactical structure of Python (assignment, expressions, if, for while, some functions/methods), some data types (integer, float, string, lists, sets, dicts), and trivial file reading and writing, such that you relatively easy can solve minor programming tasks without any use of libraries. You can check if your abilities are up to par by solving some of the exercises in 22116/22166 above.&amp;lt;br&amp;gt;&lt;br /&gt;
You must have your own computer (Windows, Mac, Linux) and you must understand it&#039;s file system structure - the folder hierarchy, file types, and file organization.&lt;br /&gt;
&lt;br /&gt;
=== Special expectations ===&lt;br /&gt;
In the first weeks you learn Unix. You must work in this environment for the rest of the course. Unix is used in a number of (bioinformatic) courses, and being able to navigate in  Unix is not only a survival skill, but also a skill sought in industry. All major bioinformatic efforts take place on big Unix servers/clusters.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In hand-ins you follow the skills taught in 22116, specifically how to write comments, using spacing to modularize the code, proper variable (object) naming, proper use of variables, error handling and code clarity, see [[Code construction]].&lt;br /&gt;
&lt;br /&gt;
=== Standard expectations ===&lt;br /&gt;
* You follow the course every week and hand in the required weekly exercises on DTU Learn.&lt;br /&gt;
* You peer-evaluate every week on DTU Learn. A hand-in is required for evaluation to be allowed.&lt;br /&gt;
* You do a project with a peer (i.e. a two person group project) at the end of the course.&lt;br /&gt;
* When getting help, understand that many students need help. You can not expect us to sit an hour with you. If time actually allows for it, we do not mind doing it.&lt;br /&gt;
&lt;br /&gt;
=== Knowing the roles at the university ===&lt;br /&gt;
By knowing the roles of the various entities, you know where to direct your question.&lt;br /&gt;
* &#039;&#039;&#039;The teacher&#039;&#039;&#039; is responsible for the content of the course, the curriculum, the teaching, the project evaluation, the making and evaluation of the exam, and the reporting of cheating. In short - any content.&lt;br /&gt;
* &#039;&#039;&#039;The study office&#039;&#039;&#039; - and by extension - the exam office, the study guidance, and the legal office (cheating) deal with everything that is not course content. A lot of information is available on [https://student.dtu.dk/en/ Student DTU] among that exam dates and what to do when having problems with the studies. They also process and publish the grades handed in by the teacher.&lt;br /&gt;
&lt;br /&gt;
== Course structure ==&lt;br /&gt;
The course is week-based, meaning new subjects are introduced Monday, and we work with them during the week. Sometimes smaller subjects are introduced Thursdays.&lt;br /&gt;
In the last month of the course a programming project will be made in 2-person groups.&lt;br /&gt;
&lt;br /&gt;
=== Exercises ===&lt;br /&gt;
* Weekly exercises are given every Monday. This constitutes an exercise set. There will be 12 of those. Exercises are mandatory.&lt;br /&gt;
* Exercises have to be uploaded to [https://learn.dtu.dk DTU Learn] latest Sunday in the same week as the exercises were given.&lt;br /&gt;
* Peer evaluation of exercises are done in the following week on [https://learn.dtu.dk DTU Learn] to be handed in Friday. The evaluations are mandatory.&lt;br /&gt;
* At least 10 of 12 evaluations must be handed in on DTU Learn for you to be allowed to take the exam. You can only evaluate if you have handed in exercises.&lt;br /&gt;
* Word or pdf documents are NOT accepted as hand-in - use only simple &#039;&#039;&#039;.txt&#039;&#039;&#039; or &#039;&#039;&#039;.py&#039;&#039;&#039; files. Sometimes, like with unit test, an entire folder structure should be zipped and uploaded.&amp;lt;br&amp;gt;&lt;br /&gt;
* Solutions to each week&#039;s exercises are published before the next week&#039;s lesson on DTU Learn (under Discussions). Can be used as reference for peer evaluation.&lt;br /&gt;
* Exercises which are handed in after the solutions are published, are voided and will not count, no matter the reason for being late.&lt;br /&gt;
* Do not read ahead and start using functions/methods/libraries which will be covered later in the course.&lt;br /&gt;
* &amp;lt;font color=&amp;quot;AA00FF&amp;quot;&amp;gt;&#039;&#039;&#039;Purple exercises&#039;&#039;&#039; has to be done in pseudo code before you start implementing them in Python. The pseudo code is part of the hand-in for these exercises.&amp;lt;br&amp;gt;So - make the pseudocode FIRST, then the real python programs AFTERWARDS for the purple exercises.&amp;lt;/font&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Why &amp;amp; How to peer-evaluate exercises ===&lt;br /&gt;
The peer evaluation is a central part of the learning process, using formative feedback. You can get input from your peers on how you can solve an exercise. &amp;lt;!--The evaluation scheme has a lot of targeted questions about various aspects of the code you will have to evaluate, which will help you understand how you should develop your programs. Initially, it can seem overwhelming, but since the questions repeat week after week, and you mostly have to check boxes, it will get easier during the course.--&amp;gt; You learn both by doing the evaluation and by receiving (reading) it.&lt;br /&gt;
&lt;br /&gt;
You must use the criteria in [[Code construction]] in your own programs and the evaluation.&lt;br /&gt;
&lt;br /&gt;
=== Projects, general information ===&lt;br /&gt;
* A project is done with two students in each group, no exceptions unless there is an odd number of students, in which case a one (wo)man group is formed. The teacher will form the groups, but will accept already formed groups, if informed in time, see the google sheet found via the Course Overview in Content at DTU Learn.&lt;br /&gt;
* Each group will choose a project from the [[Project list]] in the last part of the course. If a group has an idea for a different project, this must be discussed with the teacher to see if it is feasible. Such a &amp;quot;home made&amp;quot; project must be of sufficient complexity, but not too complex either, and have clear goals, so it can be measured if it was failed or not.&lt;br /&gt;
* A project is estimated to be doable in 50 hours of work - people often use more time.&lt;br /&gt;
* The group must work together using git and GitHub when developing the program. If the report is written in LateX, or other pure text-based format, git could also be used here.&lt;br /&gt;
* The project work consists of two phases; 1) Doing a project - making code and writing report. 2) Individual (not in the group) peer evaluation of another groups project. Thus every project is peer evaluated twice. Both phases are mandatory.&lt;br /&gt;
* The teacher will evaluate all projects and peer evaluations. Understand that YOUR evaluation of another groups project is part of YOUR project work, and as such it will be part of YOUR grade.&lt;br /&gt;
* The project work will count for 50% of the final grade. The project grade is thus combined from the group effort of doing a project and the individual effort of peer grading a project.&lt;br /&gt;
* The project will be handed in through DTU Learn at the time written in the [[Programme]].&lt;br /&gt;
* The teacher will distribute the projects per mail for peer evaluation with the intention of NOT evaluation the same type of project you made. &lt;br /&gt;
* The evaluation of another groups project will be handed in 1 week later on DTU Learn.&lt;br /&gt;
&lt;br /&gt;
=== Getting help with the project ===&lt;br /&gt;
* The groups can consult the teacher and the TA&#039;s on problems with the projects. The teacher has the best overview, while TA&#039;s often can only help with actual problems in the code.&lt;br /&gt;
* Groups can talk to each other on their project, but actual cooperation between groups with the same project is not allowed. Here is a simple and clear rule:&amp;lt;br&amp;gt;&#039;&#039;&#039;Groups must not show any written material (typically code or report) to any other group&#039;&#039;&#039;.&lt;br /&gt;
* Consulting Google on programming issues is fine, but understand what is being said/written and why it works.&lt;br /&gt;
* Nothing but Python libraries which have been taught in the course can be used in projects. Consult the teacher if in doubt.&lt;br /&gt;
* The teacher should be informed if a group is dysfunctional. We will work something out.&lt;br /&gt;
&lt;br /&gt;
=== Content of the project ===&lt;br /&gt;
Each project consists of:&lt;br /&gt;
* A report, preferably in PDF. &lt;br /&gt;
* The program code.&lt;br /&gt;
* Any data files of relevance &#039;&#039;&#039;not&#039;&#039;&#039; supplied through the course.&lt;br /&gt;
* A signed version of this [https://teaching.healthtech.dtu.dk/material/22118/ProjectStatement22118.pdf statement]. &amp;lt;div style=&amp;quot;color:red;display:inline;&amp;quot;&amp;gt;DO NOT FORGET&amp;lt;/div&amp;gt; It is unfortunate when students fail because they forget a mandatory element.&lt;br /&gt;
* The teacher must have access to the project repo. Make sure to invite &#039;&#039;peterwadsackett&#039;&#039; or attach a zipped repo when handing in.&lt;br /&gt;
&lt;br /&gt;
==== The report itself ====&lt;br /&gt;
The report should be written is such a way that it can be understood by your peer (fellow student), who have no knowledge of the specifics of your project. I have provided some sources of help, for writing reports, etc. at university level.&amp;lt;br&amp;gt;&lt;br /&gt;
* PDF: [https://teaching.healthtech.dtu.dk/material/22113/Vejledning_i_opbygning_og_skrivning_af_rapporter_v.2013.3.pdf Vejledning i opbygning og skrivning af rapporter]&lt;br /&gt;
* PDF: [https://teaching.healthtech.dtu.dk/material/22113/how_to_write_reports.pdf Guide on how to write a report]&lt;br /&gt;
* Online: [https://www.elsevier.com/connect/11-steps-to-structuring-a-science-paper-editors-will-take-seriously How to structure a science paper]&lt;br /&gt;
* PDF: [https://www.imm.dtu.dk/~janba/MastersThesisAdvice.pdf Master Thesis Advice]&lt;br /&gt;
* Online: [https://thereader.mitpress.mit.edu/umberto-eco-how-to-write-a-thesis/ How to write a thesis]&lt;br /&gt;
&lt;br /&gt;
It is considered unlikely that that the report is less than 4 pages, but there is no set limitation.&lt;br /&gt;
The report is evaluated by quality, not by length. Some projects are naturally heavy in theory,&lt;br /&gt;
others have a more practical approach, and the report is expected to reflect that to some extent.&lt;br /&gt;
&lt;br /&gt;
The following sections can/should be in the report in approximately this order:&amp;lt;br&amp;gt;&lt;br /&gt;
* Introduction - mandatory&lt;br /&gt;
* Contribution - mandatory&lt;br /&gt;
* Theory - mandatory&lt;br /&gt;
* Algorithm design - mandatory&lt;br /&gt;
* Program design - mandatory&lt;br /&gt;
* Program manual - mandatory&lt;br /&gt;
* Results - optional, depends a bit on the project if it is natural to include&lt;br /&gt;
* Runtime analysis - mandatory&lt;br /&gt;
* Unit Testing - mandatory&lt;br /&gt;
* Conclusion - mandatory&lt;br /&gt;
* References - mandatory if any references&lt;br /&gt;
&lt;br /&gt;
The sections are explained in detail below. It is important that the report reads naturally with easy flow from one subject to the next. It should also be a coherent logical structure. As an example you must explain a concept/system/method before you use it - not use it first and later tell what it means. Nor should you write the same thing twice. The report must cover all sections in some form, but as the projects are different, different emphasis will be placed on the different sections. An example is that the Theory section is important for project 9-11, but much less important and &amp;quot;theoretical&amp;quot; for project 1,3,4,5. Results are really important in project 5 and 6, but much less in the rest. The sections on &amp;quot;Theory&amp;quot;, &amp;quot;Algorithm design&amp;quot; and &amp;quot;Program design&amp;quot; can sometimes content-wise overlap each other depending on the nature of the project - it can be a question of simply drawing a line.&lt;br /&gt;
&lt;br /&gt;
==== The code ====&lt;br /&gt;
* The program code as &#039;&#039;&#039;.py&#039;&#039;&#039; or &#039;&#039;&#039;.txt&#039;&#039;&#039; files. It is a separate file from the report.&lt;br /&gt;
* The code should be clearly structured and well commented so it is possible to follow your thinking.&lt;br /&gt;
* The major data structures should also be explained with structure and purpose.&lt;br /&gt;
* The code should obviously follow the guidelines that has been given during the course in exercises.&lt;br /&gt;
* Unit testing of at least part of the code should be included. This can be done as a separate folder with test and test data.&lt;br /&gt;
&lt;br /&gt;
==== Report sections ====&lt;br /&gt;
* &#039;&#039;&#039;Introduction&#039;&#039;&#039; - A short section explaining why your project and program is important and useful and in which context it should be used. Can also be used to introduce some background.&lt;br /&gt;
* &#039;&#039;&#039;Contribution&#039;&#039;&#039; - The should be made clear, who contributed to which parts of the project, if the contributions are uneven or clearly split up. For a group that worked closely together (the best), it is completely fine to write &amp;quot;equal contribution&amp;quot; from all members, if such is the case and it is not clear who has the main contribution. &amp;quot;Equal contribution&amp;quot; is also fine for situations where the main author of pieces of code and sections of reports changes in the group such that both members have roughly contributed evenly on both programming and writing. Caveat: If you write &amp;quot;equal contribution&amp;quot; you will pass or fail together.&lt;br /&gt;
* &#039;&#039;&#039;Theory&#039;&#039;&#039; - If you have math, equations, systems, ideas that lies behind the code you do, then it should be described and explained here. Any &amp;quot;facts&amp;quot; that you are using in the code or programming against should be described in this section. High-level decisions you make, that affects how the code will work, could be described - could be using a specific library.&lt;br /&gt;
* &#039;&#039;&#039;Algorithm design&#039;&#039;&#039; -  Every project has at least one &amp;quot;core&amp;quot; algorithm or method that the project revolves about. In this section you explain &#039;&#039;how&#039;&#039; the core algorithm(s) works. Pseudo code is great for making a structure you can explain it from. Some people use diagrams.&lt;br /&gt;
* &#039;&#039;&#039;Program design&#039;&#039;&#039; - This is where you give an overview of your program: &#039;&#039;where&#039;&#039; are your functions, &#039;&#039;where&#039;&#039; is your input and output, &#039;&#039;where&#039;&#039; is the main core. To show the structural overview of your program, pseudo code is again a great method.&lt;br /&gt;
* &#039;&#039;&#039;Program manual&#039;&#039;&#039; - Describe how to use the program(s), input format, various program options, expected output, example runs. Some screenshots works great here.&lt;br /&gt;
* &#039;&#039;&#039;Results&#039;&#039;&#039; -  Show/describe/list your results of the program runs in this section.&lt;br /&gt;
* &#039;&#039;&#039;Runtime analysis&#039;&#039;&#039; -  In this section you analyze the performance of the program in Big O terms, see [[Runtime evaluation of algorithms]]. You must present calculations supported by arguments, not just results.&lt;br /&gt;
* &#039;&#039;&#039;Unit Testing&#039;&#039;&#039; - Write a small section about what unit test you made on what sections of the code. Disclose if you found errors by writing the tests.&lt;br /&gt;
* &#039;&#039;&#039;Conclusion&#039;&#039;&#039; -  Talk about the results you achieved, if you have not done so already. Discuss strength and weaknesses of the program/algorithm. Future goals or improvements.&lt;br /&gt;
* &#039;&#039;&#039;References&#039;&#039;&#039; - If you used articles, web resources, or other information sources during the project, these need to be stated here.&lt;br /&gt;
Some people thinks the algorithm design overlaps a lot with program design, and while there is some truth to that, then algorithm design is detailed about the central algorithm/part, while program design gives an overview of the code, so a reader can easily find the section of interest.&lt;br /&gt;
&lt;br /&gt;
=== How to evaluate the project ===&lt;br /&gt;
The projects consists of two very different parts: The report and the program/code. They must be evaluated in different ways, but both evaluations must result in some written text.&amp;lt;br&amp;gt;&lt;br /&gt;
Here is a [https://teaching.healthtech.dtu.dk/material/22113/projectevaltemplate.docx template evaluation document], which you can use if you wish.&lt;br /&gt;
==== The report ====&lt;br /&gt;
The report should be evaluated on form and content. It should be understood that the report must be well structured and argued, so somebody not familiar with the subject can understand it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Form:&#039;&#039;&#039; This consists of spelling, meaningful sentences, good language. Importantly, the sections as described above must be present. The sections: &amp;quot;Theory&amp;quot;, &amp;quot;Algorithm design&amp;quot; and &amp;quot;Program design&amp;quot; should be appropriate for the project type and some flexibility is allowed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Content:&#039;&#039;&#039; The content should obviously be correct and be evaluated in the light of the descriptions of the different report sections above.&lt;br /&gt;
&lt;br /&gt;
==== The program(s) ====&lt;br /&gt;
The code is evaluated on our usual criteria for exercises as can be seen on [[Code construction]] and in peer evaluation for the exercises. I will shortly mention correctness, structure, readability as the main focus.&lt;br /&gt;
&lt;br /&gt;
== Passing the course ==&lt;br /&gt;
The grade in the course is pass/fail. You have to do satisfactory (pass) in the project work.&amp;lt;br&amp;gt;&lt;br /&gt;
Furthermore, the weekly exercises + peer evaluations are mandatory. At least 10 out of 12 exercise sets + peer evaluations must be handed in to get your project evaluated for passing.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The project work ===&lt;br /&gt;
In the project all aids are allowed, like books, powerpoints, google, teachers, or knowledge sources. Being overly dependent on AI for your solution is not accepted. Make sure you understand what you are told/read. Uncritical copy/paste is not going to help you or the project. Make references when relevant.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;&#039;&#039;&#039;All aids&#039;&#039;&#039;&amp;quot; does not cover what normally constitutes cheating, like copying other students work or copying from solutions found on the internet or using libraries that solves the entire problem for you.&lt;br /&gt;
&lt;br /&gt;
The teacher will grade the project work. It consists of 3 parts. The report, the code and the peer evaluation.&amp;lt;br&amp;gt;&lt;br /&gt;
The project work addresses the following &#039;&#039;&#039;learning objectives&#039;&#039;&#039;, some only partly:&lt;br /&gt;
* Use the command line of Unix with 10-15 common Unix commands, inclusive file system navigation, pipelines, process and file system control.&lt;br /&gt;
* Demonstrate and explain the python syntax, object mode, data structures, classes and 65-70 Python methods/functions.&lt;br /&gt;
* Exercise pattern recognition in (bioinformatic) data files in order to extract information.&lt;br /&gt;
* Apply methods/programming techniques demonstrated in the course to similar problems.&lt;br /&gt;
* Analyze a (programming) problem and ascertain its components, and create an efficient solution by applying the right components in the right order.&lt;br /&gt;
* Analyze a program and based on its behavior, locate and eradicate errors.&lt;br /&gt;
* Evaluate the quality of the code, based on criteria shown in the course, and ensuring the code meets quality standards by employing the unit test technique.&lt;br /&gt;
* Write clear, precise and well documented code, which is suitable for greater collaborative efforts.&lt;br /&gt;
* Evaluate the performance and efficiency of code with respect to speed and memory consumption using Big O notation.&lt;br /&gt;
* Utilize code libraries, both scientific and other, for fast and good solution of programming tasks.&lt;br /&gt;
The project will be evaluated on a overall view of how well it answers the problems stated in the project description. Below are various elements specified.&lt;br /&gt;
&lt;br /&gt;
==== General engineering competences relevant for the project work ====&lt;br /&gt;
Ability to write coherent text, to form proper sentences in English, to finish a consistent quality product (head lines, TOC, no missing words or figures, using same words for concepts, using the right scientific word/concept, etc.). Ability to collaborate both in writing text and programming code with other people.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the report, which will form the foundation of the evaluation ====&lt;br /&gt;
* Analyze the project formulation and develop a method/algorithm for solving the problem.&lt;br /&gt;
* Clearly describe theoretical aspects of the project and/or algorithm; this could be mathematical foundation, input file data formats, categories used, prerequisites and assumptions, data structure elements or clever ideas.&lt;br /&gt;
* Clearly and coherently describe the algorithm and relevant data structures.&lt;br /&gt;
* When designing an algorithm, it can suffer from performance problems, which can be related to both speed and excessive use of memory. Can you recognize the shortcomings in your own algorithm? &lt;br /&gt;
* Show the proper use of pseudo code.&lt;br /&gt;
* Appropriate use of figures, graphs, illustrations and screenshots.&lt;br /&gt;
* Demonstrate the actual structure of the finished program, so the reader can understand what is going on where when seeing the code.&lt;br /&gt;
* Evaluate what is trivial and what is not, and focus on explaining the non-trivial things in the program.&lt;br /&gt;
* Understand and clearly describe a runtime evaluation of your code in Big O notation.&lt;br /&gt;
* Present results from the project in a relevant and clear fashion.&lt;br /&gt;
* See the perspective of your project. Where can it be used? What can be improved? What did you learn?&lt;br /&gt;
* Building a project is a creative process. Let that creativity shine through.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the code, which will form the foundation of the evaluation ====&lt;br /&gt;
During the course you have been presented for many skills and competences in the peer evaluation and through that gained a good grasp of the easier coding skills.&lt;br /&gt;
* Correct commenting in code, placement and content&lt;br /&gt;
* Spacing and modularization&lt;br /&gt;
* Object naming&lt;br /&gt;
* Using appropriate amount and type of variables for the task.&lt;br /&gt;
* Error handling &lt;br /&gt;
The project demands more of the in-depth coding skills.&lt;br /&gt;
* Avoiding simple structural flaws&lt;br /&gt;
* Ability to write clear and precise code.&lt;br /&gt;
* Writing concise code.&lt;br /&gt;
* Writing sensible and meaningful code. This is not included by above points.&lt;br /&gt;
* This point is about significant performance problems not related to an inherent problem with the algorithm (which is covered in the report).&lt;br /&gt;
# Recognizing and avoiding unnecessary loops or methods which slow the speed of the program. &lt;br /&gt;
# Recognizing and avoiding unnecessary use of computer memory.&lt;br /&gt;
* Reach for beauty and elegance. That happens when it all comes together in a clear and obvious chain of events that leads to the result.&lt;br /&gt;
&lt;br /&gt;
==== Skills and competences relevant for the peer evaluation ====&lt;br /&gt;
* You will use many of the competences used in your own report and code.&lt;br /&gt;
* Ability to critically read and evaluate text and foreign code (see through bullshit).&lt;br /&gt;
&lt;br /&gt;
== Failing the course ==&lt;br /&gt;
The exercises are mandatory. You must hand-in minimum 10 of the 12. Likewise you must peer-evaluate 10 out of 12 times. You can&#039;t peer-evaluate if you do not hand in. Failing to achieve this will make you fail the course - no matter the state of your project.&amp;lt;br&amp;gt;&lt;br /&gt;
The exercises do not count in passing the course, but consistently doing poorly in exercises is not going to aid the project.&lt;br /&gt;
&lt;br /&gt;
=== Failing the project ===&lt;br /&gt;
The reasons for failing the project are usually:&lt;br /&gt;
* more than one severe, game changing mistake has been made in the code.&lt;br /&gt;
* severe misunderstandings about the content/purpose of the project.&lt;br /&gt;
* too low quality in the report.&lt;br /&gt;
* too low quality in the code.&lt;br /&gt;
* insufficient contribution in either code or report.&lt;br /&gt;
The first two could somewhat easily be avoided by consulting the teacher.&amp;lt;br&amp;gt;&lt;br /&gt;
For the last reasons... you need to up your game; Take the time to write a decent report - there are resources available on how to do that.&amp;lt;br&amp;gt;&lt;br /&gt;
Insufficient contribution often has an underlying course in insufficient coding skills.&amp;lt;br&amp;gt;&lt;br /&gt;
The code can/must be improved by learning more during the course - study the exercises and the solutions.&lt;br /&gt;
&lt;br /&gt;
The 4 challenges for failing students are:&lt;br /&gt;
* difficulty in analyzing the problem - understanding what has to be done.&lt;br /&gt;
* difficulty in formulating a strategy for solving the problem - designing the method/algorithm.&lt;br /&gt;
* difficulty in executing the strategy - transforming the method/idea into working code.&lt;br /&gt;
* difficulty in making the code coherent - having the grand overview of the method/code.&lt;br /&gt;
&lt;br /&gt;
There are lots of mistakes a student can do; insufficient knowledge of python (syntax and functions), bad performance, repetitive code, missing variables, wrongly iterating loops, missing the right position of sequences etc., but they are not disastrous on the individual level - although they reflect your skill. The problem is when many mistakes/omissions come together and form a mix of the 4 challenges.&lt;br /&gt;
&lt;br /&gt;
How to improve: Practice, practice, and then some practice. You can not read it in a book or powerpoint. That helps in knowing the syntax and functions of python, but that is not the issue. The issue is training your brain in the analyzing, formulating and executing phases of coherent programming.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=334</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=334"/>
		<updated>2026-05-08T11:24:44Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Opportunity ==&lt;br /&gt;
PDF: [https://teaching.healthtech.dtu.dk/material/22118/RNA-editing_Masterproject.pdf RNA Editing] A Master project. Contact Greg, grinos@dtu.dk&lt;br /&gt;
&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well. Most likely other stuff.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere (f.ex. do not implement reading from stdin) or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory.&amp;lt;br&amp;gt;&lt;br /&gt;
FASTQ are often gzipped - it is nice to read them directly from the gzip file, but it makes the entire improvement harder.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&amp;lt;br&amp;gt;&lt;br /&gt;
[https://teaching.healthtech.dtu.dk/material/22118/BRISCOE_0069_BD18RUACXX_L2_1_pf.fastq Example of an uncompressed FASTQ file]&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=333</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=333"/>
		<updated>2026-05-08T11:10:16Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Opportunity ==&lt;br /&gt;
PDF: [https://teaching.healthtech.dtu.dk/material/22118/RNA-editing_Masterproject.pdf RNA Editing] A Master project. Contact Greg, grinos@dtu.dk&lt;br /&gt;
&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well. Most likely other stuff.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere (f.ex. do not implement reading from stdin) or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory.&amp;lt;br&amp;gt;&lt;br /&gt;
FASTQ are often gzipped - it is nice to read them directly from the gzip file, but it makes the entire improvement harder.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=332</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=332"/>
		<updated>2026-05-07T09:56:10Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Opportunity ==&lt;br /&gt;
PDF: [https://teaching.healthtech.dtu.dk/material/22118/RNA-editing_Masterproject.pdf RNA Editing] A Master project. Contact Greg, grinos@dtu.dk&lt;br /&gt;
&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well. Most likely other stuff.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere (f.ex. do not implement reading from stdin) or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory. Also, FASTQ are often gzipped - it is nice to read them directly from the gzip file.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=331</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=331"/>
		<updated>2026-05-07T09:55:58Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Opportunity ==&lt;br /&gt;
PDF: [https://teaching.healthtech.dtu.dk/material/22118/RNA-editing_Masterproject.pdf RNA Editing] A Master project. Contact Greg, grinos@dtu.dk&lt;br /&gt;
&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well. Most likely other stuff.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere (f.ex. do not implement reading form stdin) or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory. Also, FASTQ are often gzipped - it is nice to read them directly from the gzip file.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=330</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=330"/>
		<updated>2026-05-04T10:57:17Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Opportunity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Opportunity ==&lt;br /&gt;
PDF: [https://teaching.healthtech.dtu.dk/material/22118/RNA-editing_Masterproject.pdf RNA Editing] A Master project. Contact Greg, grinos@dtu.dk&lt;br /&gt;
&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory. Also, FASTQ are often gzipped - it is nice to read them directly from the gzip file.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=329</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=329"/>
		<updated>2026-05-04T09:52:21Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Opportunity ==&lt;br /&gt;
PDF: [https://teaching.healthtech.dtu.dk/material/22118/RNA-editing_Masterproject.pdf RNA Editing] A Master project.&lt;br /&gt;
&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory. Also, FASTQ are often gzipped - it is nice to read them directly from the gzip file.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=328</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=328"/>
		<updated>2026-04-30T13:48:14Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Required course material for the lesson */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo. They are looking for help/contributers&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory. Also, FASTQ are often gzipped - it is nice to read them directly from the gzip file.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=327</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=327"/>
		<updated>2026-04-30T13:42:41Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Make it able to read FASTQ files.&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
This includes changing the Seqfile class, adding a new Fastqfilehandle class, and understanding the Sequence class really well.&amp;lt;br&amp;gt;&lt;br /&gt;
Of course, you are using Git to handle your changes. You might make some kind of limitation somewhere or maybe generator,&lt;br /&gt;
as FASTQ files get really big and can&#039;t all be in memory. Also, FASTQ are often gzipped - it is nice to read them directly from the gzip file.&amp;lt;br&amp;gt;&lt;br /&gt;
You don&#039;t know FASTQ format? - look it up - this is supposed to be a &amp;quot;real world problem&amp;quot;. You don&#039;t get much help.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=326</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=326"/>
		<updated>2026-04-30T12:28:58Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are going to be only one exercise. You have the project, and the exercise will be big.&amp;lt;br&amp;gt;&lt;br /&gt;
Clone Anders Gorm&#039;s repo: &#039;&#039;sequencelib&#039;&#039; and study it.&amp;lt;br&amp;gt;&lt;br /&gt;
Make it able to read FASTQ files.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=325</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=325"/>
		<updated>2026-04-30T12:22:09Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evaluation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are no exercises for this lecture - or the rest of the course&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=324</id>
		<title>Changing existing code base</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Changing_existing_code_base&amp;diff=324"/>
		<updated>2026-04-30T12:20:58Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: Created page with &amp;quot;__NOTOC__ {| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot; |Previous: Runtime evauation |Next: Last words |} == Required course material for the lesson == GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&amp;#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt; GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo.&amp;lt;br&amp;gt; GitHub: [https://github.com/bioinform Th...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Runtime evauation]]&lt;br /&gt;
|Next: [[Last words]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
GitHub: [https://github.com/agormp Professor Anders Gorm Pedersen&#039;s repositories.] Used in teaching this week.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/genenetwork/ Gene network.] A much larger and thus more complicated/confusing repo.&amp;lt;br&amp;gt;&lt;br /&gt;
GitHub: [https://github.com/bioinform The Bioinformatics Repository.] Different repos, various languages.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Hands-on addition to a code base,&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are no exercises for this lecture - or the rest of the course&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=323</id>
		<title>Last words</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=323"/>
		<updated>2026-04-30T12:05:31Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Required course material for the lesson */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Changing existing code base]]&lt;br /&gt;
|Next: [[Programme]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-MemoryManagement.ppt Memory management].&amp;lt;br&amp;gt;&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_13-LastWords.ppt Last words]&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/evanpeikon/Bioinformatics_Toolkit Bioinformatics Toolkit by Evan Peikon.] Strong recommendation for anyone who want to up their skills.&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/harvardinformatics/learning-bioinformatics-at-home Learning Bioinformatics at Home by Harvard Informatics Group.] A bit of a mixed bag.&amp;lt;br&amp;gt;&lt;br /&gt;
Projects: [https://github.com/zamirmehdi/Bioinformatics-Course Bioinformatics Course by Amirmehdi Zarrinnezhad.] Looking for more coding projects?&amp;lt;br&amp;gt;&lt;br /&gt;
Future: [https://www.biotecnika.org/2025/09/how-to-build-a-github-portfolio-in-bioinformatics-a-step-by-step-guide-for-beginners/ Build your Portfolio on GitHub.] A step by step guide.&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Python Memory Management&amp;lt;br&amp;gt;&lt;br /&gt;
Course summery&amp;lt;br&amp;gt;&lt;br /&gt;
Standard libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Third party libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Optimization&amp;lt;br&amp;gt;&lt;br /&gt;
Further courses&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are no exercises for this lecture - or the rest of the course&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=322</id>
		<title>Last words</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=322"/>
		<updated>2026-04-30T09:28:55Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Required course material for the lesson */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Changing existing code base]]&lt;br /&gt;
|Next: [[Programme]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-MemoryManagement.ppt Memory management].&amp;lt;br&amp;gt;&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_13-LastWords.ppt Last words]&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/evanpeikon/Bioinformatics_Toolkit Bioinformatics Toolkit by Evan Peikon.] Strong recommendation for anyone who want to up their skills.&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/harvardinformatics/learning-bioinformatics-at-home Learning Bioinformatics at Home by Harvard Informatics Group.] A bit of a mixed bag.&amp;lt;br&amp;gt;&lt;br /&gt;
Projects: [https://github.com/zamirmehdi/Bioinformatics-Course Bioinformatics Course by Amirmehdi Zarrinnezhad.] Looking for more coding projects?&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Python Memory Management&amp;lt;br&amp;gt;&lt;br /&gt;
Course summery&amp;lt;br&amp;gt;&lt;br /&gt;
Standard libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Third party libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Optimization&amp;lt;br&amp;gt;&lt;br /&gt;
Further courses&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are no exercises for this lecture - or the rest of the course&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=321</id>
		<title>Last words</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=321"/>
		<updated>2026-04-30T09:24:21Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Required course material for the lesson */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Changing existing code base]]&lt;br /&gt;
|Next: [[Programme]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-MemoryManagement.ppt Memory management].&amp;lt;br&amp;gt;&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_13-LastWords.ppt Last words]&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/evanpeikon/Bioinformatics_Toolkit Bioinformatics Toolkit by Evan Peikon.] Strong recommendation for anyone who want to up their skills.&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/harvardinformatics/learning-bioinformatics-at-home Learning Bioinformatics at Home by Harvard Informatics Group.] A bit of a mixed bag.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Python Memory Management&amp;lt;br&amp;gt;&lt;br /&gt;
Course summery&amp;lt;br&amp;gt;&lt;br /&gt;
Standard libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Third party libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Optimization&amp;lt;br&amp;gt;&lt;br /&gt;
Further courses&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are no exercises for this lecture - or the rest of the course&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=320</id>
		<title>Last words</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Last_words&amp;diff=320"/>
		<updated>2026-04-30T09:13:00Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Required course material for the lesson */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Changing existing code base]]&lt;br /&gt;
|Next: [[Programme]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-MemoryManagement.ppt Memory management].&amp;lt;br&amp;gt;&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_13-LastWords.ppt Last words]&amp;lt;br&amp;gt;&lt;br /&gt;
Guides: [https://github.com/evanpeikon/Bioinformatics_Toolkit Bioinformatics Toolkit by Evan Peikon.] Strong recommendation for anyone who want to up their skills.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- Resource: [[Example code - File Reading]]&amp;lt;br&amp;gt; --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Python Memory Management&amp;lt;br&amp;gt;&lt;br /&gt;
Course summery&amp;lt;br&amp;gt;&lt;br /&gt;
Standard libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Third party libraries&amp;lt;br&amp;gt;&lt;br /&gt;
Optimization&amp;lt;br&amp;gt;&lt;br /&gt;
Further courses&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
There are no exercises for this lecture - or the rest of the course&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=319</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=319"/>
		<updated>2026-04-27T12:21:05Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* How to calculate Big O in the project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in range(i+1, len(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in range(i+1, len(numbers):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in range(i+1, len(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Analyze the algorithm of [[QT clustering]] (see Details). Make an argument for what is the worst case running time in the described form. This will be hard. The &amp;quot;Add one point from your data set at a time in such a way that you extend the candidate cluster diameter the least&amp;quot; covers an algorithm that you must think up. You might benefit from making some simple pseudo code of the entire QT clustering algorithm.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=318</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=318"/>
		<updated>2026-04-24T09:06:07Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Analyze the algorithm of [[QT clustering]] (see Details). Make an argument for what is the worst case running time in the described form. This will be hard. The &amp;quot;Add one point from your data set at a time in such a way that you extend the candidate cluster diameter the least&amp;quot; covers an algorithm that you must think up. You might benefit from making some simple pseudo code of the entire QT clustering algorithm.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=317</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=317"/>
		<updated>2026-04-24T09:03:48Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Analyze the algorithm of [[QT clustering]] (see Details). Make an argument for what is the worst case running time in the described form. This will be hard. The &amp;quot;Add one point from your data set at a time in such a way that you extend the candidate cluster diameter the least&amp;quot; covers an algorithm that you must think up.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=316</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=316"/>
		<updated>2026-04-24T08:57:41Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Analyze the algorithm of [[QT clustering]] (see Details). Make an argument for why it is worst case O(x^5) in the described form.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=315</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=315"/>
		<updated>2026-04-24T08:56:44Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Analyze the algorithm of [[QT clustering]] (see Details). Make an argument for why it is worst case O(x^7) in the described form.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=314</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=314"/>
		<updated>2026-04-24T08:55:29Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Analyze the algorithm of [[QT clustering]] (see Details). Make an argument for why it is worst case O(x^7).&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=313</id>
		<title>Runtime evaluation</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Runtime_evaluation&amp;diff=313"/>
		<updated>2026-04-24T08:48:59Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate unit test]]&lt;br /&gt;
|Next: [[Changing existing code base]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/Python10-Runtime.pptx Runtime evaluation of algorithms] Old ppt, not so important&amp;lt;br&amp;gt;&lt;br /&gt;
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=41edc89b-61a5-475d-84d0-af2701271b5d Runtime Analysis] See this first&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Runtime evaluation of algorithms&amp;lt;br&amp;gt;&lt;br /&gt;
Big O notation&lt;br /&gt;
&lt;br /&gt;
== Big O notation ==&lt;br /&gt;
When you &amp;quot;calculate&amp;quot; the running time of a program or an algorithm you write your result in the &#039;&#039;&#039;Big O&#039;&#039;&#039; notation. The running time is the complexity of the algorithm. The hardest part about Big O is understanding the concept - performing the actual calculation is rather easy in most cases. Especially since there is no real calculation to do, but mostly just analysis of the code.&lt;br /&gt;
&lt;br /&gt;
== Some loosely explained theory ==&lt;br /&gt;
Any program is performing some operations when it is running. This could be addition of a number to a variable. It could be asking which number is the biggest or if two strings are identical. You have been programming; every statement is an operation.&lt;br /&gt;
&lt;br /&gt;
Calculating Big O is estimating the number of operations. This is &#039;&#039;&#039;not&#039;&#039;&#039; the number of statements. Some statements are executed several times in loops. Big O is more similar to the accumulated number of times each statement has been executed during the run of the program. While it is possible to calculate this number exactly, given an input and given that randomness is not part of the program, then this is not necessary and very uninteresting and possibly difficult.&lt;br /&gt;
&lt;br /&gt;
What is needed is an estimate that explains how the program&#039;s running time scales with the size of the input; Big O.&lt;br /&gt;
Very often - almost always - a program contains loops that loop over data. Let&#039;s take the program that calculates the average of a list/file of numbers as an example.&lt;br /&gt;
&lt;br /&gt;
 # pseudo code&lt;br /&gt;
 open file&lt;br /&gt;
 for each line in file&lt;br /&gt;
     sum = sum + number(line)&lt;br /&gt;
     increment(line_counter)&lt;br /&gt;
 close file&lt;br /&gt;
 print sum/line_counter&lt;br /&gt;
&lt;br /&gt;
The opening and closing of the file is done once, likewise the printing of the sum. The summing is done once per number/line. This means the more numbers there are in the file, the more additions are made. It scales with the number of numbers. The line_counter is also incremented once per line, so that obviously also scale in the same way as the summing.&amp;lt;br&amp;gt;&lt;br /&gt;
To put this in Big O notation: O(1 + n + n + 1 + 1) = O(2n + 3).&amp;lt;br&amp;gt;&lt;br /&gt;
This expression is still too complex. The &amp;quot;small stuff&amp;quot; is eliminated, this means remove the constants. They don&#039;t tell much about how running time scales anyway.&amp;lt;br&amp;gt;&lt;br /&gt;
The final Big O notation: O(n), where n is the number of numbers.&amp;lt;br&amp;gt;&lt;br /&gt;
If you have a more complex Big O like: O(n*n + n), then the single n is thrown away as that is not important compared to n*n, so O(n*n) is the final result.&lt;br /&gt;
&lt;br /&gt;
== A collecting of internet resources on Big O ==&lt;br /&gt;
[http://stackoverflow.com/questions/487258/what-is-a-plain-english-explanation-of-big-o-notation Big O in plain English]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/ A Beginner&#039;s Guide to Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.interviewcake.com/big-o-notation-time-and-space-complexity Big O Notation]&amp;lt;br&amp;gt;&lt;br /&gt;
[http://bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/big-o-notation-explained.html Big O notation explained]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://justin.abrah.ms/computer-science/how-to-calculate-big-o.html How to calculate Big O]&amp;lt;br&amp;gt;&lt;br /&gt;
[https://www.youtube.com/watch?v=V6mKVRU1evU Big O notations - a youtube video]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Big_O_notation Wikipedia&#039;s entry on Big O] is particular useless. It is most likely correct, but impossible to understand. Don&#039;t go there for information unless you like pain.&lt;br /&gt;
&lt;br /&gt;
If all you want to do is to measure how long your program takes to run in real time (seconds and minutes), then you should just use the &#039;&#039;&#039;time&#039;&#039;&#039; command in unix. Simply put it in front of your program.&lt;br /&gt;
&lt;br /&gt;
 # Normally you call your program like&lt;br /&gt;
 ./mypythonprogram.py fastafile&lt;br /&gt;
 # To see how long it takes to execute, use&lt;br /&gt;
 time ./mypythonprogram.py fastafile&lt;br /&gt;
&lt;br /&gt;
== How to calculate Big O in the project ==&lt;br /&gt;
When a program or algorithm is small, then it is often trivial to perform this &amp;quot;calculation&amp;quot;. In bigger pieces of software, you often need to be more systematic about it. Since we know that the loops are what matters in Big O, then keeping track of the loops in the software as comments is a great way of starting a system. In this example, I have a list of numbers where all must be multiplied in pairs and then summed.&amp;lt;br&amp;gt;&lt;br /&gt;
The code:&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
I start adding a comment about Big O in the inner loop. I discard the minor issues, like in essence the loop is at most n-1 long, and minimum 1 long. The worst case is what we use in these situations.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Then I add a Big O comment to the outer loop. Since I already have the Big O for the inner loop, it is easy.&lt;br /&gt;
 numbers = [2,3,5,7,11,13]&lt;br /&gt;
 sum = 0&lt;br /&gt;
 # O(n*n), where n is the number of numbers&lt;br /&gt;
 for i in range(len(numbers)-1):&lt;br /&gt;
     # O(n), where n is the number of numbers, worst case&lt;br /&gt;
     for j in (j+1, range(numbers)):&lt;br /&gt;
         sum += numbers[i] * numbers[j]&lt;br /&gt;
 print(&amp;quot;Result:&amp;quot;, sum)&lt;br /&gt;
Now I have the result, O(n*n), easily argued and explainable. Shown directly in the code. I should add some logical reasoning, but I have a strong analysis in the code, which can support me.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
&amp;quot;Calculate&amp;quot; can mean many things here; Analyze, argue, explain, show, or even demonstrate. For some algorithms (not these) it even means &amp;quot;do a lot of math&amp;quot;. The calculation must be convincingly explained based on reasoning. Just showing the result is insufficient.&amp;lt;br&amp;gt;&lt;br /&gt;
# Calculate Big O of exercise 2 in [[Solo git]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Functions, namespace, memory management]]&lt;br /&gt;
# Calculate Big O of exercise 1 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 3 in [[Comprehension, generators, iteration]]&lt;br /&gt;
# Calculate Big O of exercise 6 in [[Comprehension, generators, iteration]]&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=312</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=312"/>
		<updated>2026-04-19T18:15:44Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Unit test using pytest framework.&amp;lt;br&amp;gt;&lt;br /&gt;
Files, test data&amp;lt;br&amp;gt;&lt;br /&gt;
Setting up real projects&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Use a fixture for setting up a test set for you deletion tests. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Change your unit test setup of your fasta class to the package structure. That includes the correct folder structure, pyproject.toml and __init__.py file.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=311</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=311"/>
		<updated>2026-04-19T18:15:36Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Unit test using pytest framework.&amp;lt;br&amp;gt;&lt;br /&gt;
Files, test data&amp;lt;br&amp;gt;&lt;br /&gt;
Setting up real projects&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Use a fixture for setting up a test set for you deletion tests. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Change your unit test setup of your fasta class to the package structure. That includes the correct folder structure, pyproject.toml and __init__.py file.&amp;lt;br&amp;gt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=310</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=310"/>
		<updated>2026-04-19T17:58:41Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Unit test using pytest framework.&amp;lt;br&amp;gt;&lt;br /&gt;
Files, test data&amp;lt;br&amp;gt;&lt;br /&gt;
Setting up real projects&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Use a fixture for setting up a test set for you deletion tests. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Change your unit test setup of your fasta class to the package structure. That includes the correct folder structure, pyproject.toml and __init__.py file.&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=309</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=309"/>
		<updated>2026-04-14T16:37:28Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive for how the search path works. Try to run the test from a different folder (unittest), like &amp;quot;pytest test/normalize_test.py&amp;quot; to see how vulnerable just using the path is.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# &#039;&#039;MyMath&#039;&#039; class also contains the &#039;&#039;supply&#039;&#039; method. Make unit tests for that method in the file &#039;&#039;unittest/test/MyMath_supply_test.py&#039;&#039;. Make the &amp;quot;usual&amp;quot; tests, which are the same as you did in the first exercise.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now make unit tests for the &#039;&#039;average&#039;&#039; method in &#039;&#039;&#039;MyMath&#039;&#039;&#039;. Make the tests in the file &#039;&#039;unittest/test/MyMath_average_test.py&#039;&#039;. Notice how that interacts with the &#039;&#039;supply&#039;&#039; unit tests because &#039;&#039;average&#039;&#039; depends on correct working of &#039;&#039;supply&#039;&#039;. Sometimes you won&#039;t even find the flaw in one method before you test another that depends on it. I am not going to tell you this time what unit tests you should make. You should know by now.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=308</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=308"/>
		<updated>2026-04-14T16:36:12Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive for how the search path works. Try to run the test from a different folder, like &amp;quot;pytest test/normalize_test.py&amp;quot; to see how vulnerable just using the path is.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# &#039;&#039;MyMath&#039;&#039; class also contains the &#039;&#039;supply&#039;&#039; method. Make unit tests for that method in the file &#039;&#039;unittest/test/MyMath_supply_test.py&#039;&#039;. Make the &amp;quot;usual&amp;quot; tests, which are the same as you did in the first exercise.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now make unit tests for the &#039;&#039;average&#039;&#039; method in &#039;&#039;&#039;MyMath&#039;&#039;&#039;. Make the tests in the file &#039;&#039;unittest/test/MyMath_average_test.py&#039;&#039;. Notice how that interacts with the &#039;&#039;supply&#039;&#039; unit tests because &#039;&#039;average&#039;&#039; depends on correct working of &#039;&#039;supply&#039;&#039;. Sometimes you won&#039;t even find the flaw in one method before you test another that depends on it. I am not going to tell you this time what unit tests you should make. You should know by now.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=307</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=307"/>
		<updated>2026-04-14T14:54:42Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# &#039;&#039;MyMath&#039;&#039; class also contains the &#039;&#039;supply&#039;&#039; method. Make unit tests for that method in the file &#039;&#039;unittest/test/MyMath_supply_test.py&#039;&#039;. Make the &amp;quot;usual&amp;quot; tests, which are the same as you did in the first exercise.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now make unit tests for the &#039;&#039;average&#039;&#039; method in &#039;&#039;&#039;MyMath&#039;&#039;&#039;. Make the tests in the file &#039;&#039;unittest/test/MyMath_average_test.py&#039;&#039;. Notice how that interacts with the &#039;&#039;supply&#039;&#039; unit tests because &#039;&#039;average&#039;&#039; depends on correct working of &#039;&#039;supply&#039;&#039;. Sometimes you won&#039;t even find the flaw in one method before you test another that depends on it. I am not going to tell you this time what unit tests you should make. You should know by now.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=306</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=306"/>
		<updated>2026-04-14T14:52:37Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# &#039;&#039;MyMath&#039;&#039; class also contains the &#039;&#039;supply&#039;&#039; method. Make unit tests for that method in the file &#039;&#039;unittest/test/MyMath_supply_test.py&#039;&#039;. Make the &amp;quot;usual&amp;quot; tests, which are the same as you did in the first exercise.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now make unit tests for the &#039;&#039;average&#039;&#039; method in &#039;&#039;&#039;MyMath&#039;&#039;&#039;. Use the file &#039;&#039;unittest/test/MyMath_average_test.py&#039;&#039;. Notice how that interacts with the &#039;&#039;supply&#039;&#039; unit tests because &#039;&#039;average&#039;&#039; depends on correct working of &#039;&#039;supply&#039;&#039;. Sometimes you won&#039;t even find the flaw in one method before you test another that depends on it.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=305</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=305"/>
		<updated>2026-04-14T14:50:46Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# &#039;&#039;MyMath&#039;&#039; class also contains the &#039;&#039;supply&#039;&#039; method. Make unit tests for that method in the file &#039;&#039;unittest/test/MyMath_supply_test.py&#039;&#039;. Make the &amp;quot;usual&amp;quot; tests, which are the same as you did in the first exercise.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now make unit tests for the &#039;&#039;average&#039;&#039; method in &#039;&#039;MyMath&#039;&#039;. Use the file &#039;&#039;unittest/test/MyMath_average_test.py&#039;&#039;. Notice how that interacts with the &#039;&#039;supply&#039;&#039; unit tests because &#039;&#039;average&#039;&#039; depends on correct working of &#039;&#039;supply&#039;&#039;. Sometimes you won&#039;t even find the flaw in one method before you test another dependency.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=304</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=304"/>
		<updated>2026-04-14T14:50:20Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&lt;br /&gt;
# &#039;&#039;MyMath&#039;&#039; class also contains the &#039;&#039;supply&#039;&#039; method. Make unit tests for that method in the file &#039;&#039;unittest/test/MyMath_supply_test.py&#039;&#039;. Make the &amp;quot;usual&amp;quot; tests, which are the same as you did in the first exercise.&lt;br /&gt;
# Now make unit tests for the &#039;&#039;average&#039;&#039; method in &#039;&#039;MyMath&#039;&#039;. Use the file &#039;&#039;unittest/test/MyMath_average_test.py&#039;&#039;. Notice how that interacts with the &#039;&#039;supply&#039;&#039; unit tests because &#039;&#039;average&#039;&#039; depends on correct working of &#039;&#039;supply&#039;&#039;. Sometimes you won&#039;t even find the flaw in one method before you test another dependency.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=303</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=303"/>
		<updated>2026-04-14T14:39:24Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Installation of pytest */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 # An install on a basic system&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
 # Using ubuntu, which is also WSL in this situation, there is a package&lt;br /&gt;
 apt install python3-pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=302</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=302"/>
		<updated>2026-04-14T14:35:42Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises for extra practice */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Unit test using pytest framework.&amp;lt;br&amp;gt;&lt;br /&gt;
Files, test data&amp;lt;br&amp;gt;&lt;br /&gt;
Setting up real projects&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=301</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=301"/>
		<updated>2026-04-14T14:35:31Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises for extra practice */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=300</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=300"/>
		<updated>2026-04-14T14:32:23Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;&#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=299</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=299"/>
		<updated>2026-04-14T14:32:02Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039;&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method. Test it with at least these input: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. Parametrize at least the tests that should succeed. Bonus for parametrizing the exceptions.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=298</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=298"/>
		<updated>2026-04-14T14:26:39Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# You hopefully remember the &#039;&#039;&#039;MyMath&#039;&#039;&#039; class you made in exercise 1 &amp;amp; 2 in [[Beginning classes]]. Make a folder &#039;&#039;classes&#039; in your &#039;&#039;unittest/src&#039;&#039; folder and put the &#039;&#039;MyMath&#039;&#039; class in a file &#039;&#039;MyMath.py&#039;&#039; in &#039;unittest/src/classes&#039;&#039;. Now make a unit test file &#039;&#039;MyMath_factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039; that - surprise - tests your factorial method.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=297</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=297"/>
		<updated>2026-04-14T14:16:24Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Unit test using pytest framework.&amp;lt;br&amp;gt;&lt;br /&gt;
Files, test data&amp;lt;br&amp;gt;&lt;br /&gt;
Setting up real projects&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=296</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=296"/>
		<updated>2026-04-14T14:15:55Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=295</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=295"/>
		<updated>2026-04-13T10:06:00Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Required course material for the lesson */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installation of pytest ===&lt;br /&gt;
If you are using an anaconda python installation pytest is included. You can test in your python has pytest.&lt;br /&gt;
 # On command line both should work or none&lt;br /&gt;
 python3 -c &amp;quot;import pytest&amp;quot;&lt;br /&gt;
 which pytest&lt;br /&gt;
 # It is pretty clear if you fail. Success can be more obscure.&lt;br /&gt;
 # Here is a fail test, so you can compare&lt;br /&gt;
 python3 -c &amp;quot;import yptest&amp;quot;&lt;br /&gt;
 which yptest&lt;br /&gt;
To install pytest, you need to be root/administrator.&lt;br /&gt;
 pip install -U pytest&lt;br /&gt;
 # or maybe (depending on your system)&lt;br /&gt;
 sudo pip install -U pytest&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=294</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=294"/>
		<updated>2026-04-13T09:52:42Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set containing numbers, and a dict where the keys are numbers. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=293</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=293"/>
		<updated>2026-04-13T09:50:54Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your &#039;&#039;&#039;normalize&#039;&#039;&#039; function from exercise 3 in [[Functions, namespace, memory management]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: a list of positive numbers, a list of negative numbers, a list of integers, a list of mixed floats and integers, a single number in the list, empty list, a list with at least one non-number (string, list, set), a set and a dict. Get other ideas if you can. The &#039;&#039;&#039;normalize&#039;&#039;&#039; function and all test functions must be in one single file (&#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the &#039;&#039;&#039;normalize&#039;&#039;&#039; function from &#039;&#039;normalize_test.py&#039;&#039; and put it in its own file &#039;&#039;normalize.py&#039;&#039;. Import it from the &#039;&#039;normalize_test.py&#039;&#039; like &#039;&#039;&#039;from normalize import normalize&#039;&#039;&#039;. The first &#039;&#039;normalize&#039;&#039; is the name of the .py file, the second &#039;&#039;normalize&#039;&#039; is the name of your normalize function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;normalize.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;normalize_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=292</id>
		<title>Beginning unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Beginning_unit_test&amp;diff=292"/>
		<updated>2026-04-13T09:40:22Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises to be handed in */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Intermediate classes]]&lt;br /&gt;
|Next: [[Intermediate unit test]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Example code - Unit test]]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&amp;lt;br&amp;gt;&lt;br /&gt;
In some of these exercise you need to hand in not just a single file, but multiple files in a folder hierarchy. Zip the folder structure for your entire solution folder. Make sure it is clear to see what exercise your code/data is solving. And learn to zip :-)&lt;br /&gt;
# Use your factorial function from exercise 2 in [[Making Functions]]. If you did not do so already, change it to use exceptions instead of &#039;&#039;&#039;sys.exit()&#039;&#039;&#039;, when an error occurs. Now make simple unit tests for the following test cases: 12, 2, 1, 0, -1, 3.0, 3.4, &amp;quot;3&amp;quot;, &amp;quot;3.1.&amp;quot;, &amp;quot;ABC&amp;quot;. The factorial function and all test functions must be in one single file (&#039;&#039;factorial_test.py&#039;&#039; in &#039;&#039;unittest&#039;&#039;), which you can run &#039;&#039;pytest&#039;&#039; on.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Now remove the factorial function from &#039;&#039;factorial_test.py&#039;&#039; and put it in its own file &#039;&#039;factorial.py&#039;&#039;. Import it from the &#039;&#039;factorial_test.py&#039;&#039; like &#039;&#039;&#039;from factorial import factorial&#039;&#039;&#039;. The first factorial is the name of the .py file, the second factorial is the name of your factorial function. Just run &#039;&#039;pytest&#039;&#039; (no file name) in the folder to check it works. It is more normal to have test and function separated.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Above we removed test code from function code by creating two files. Next, put the files in their own folder in &#039;&#039;unittest&#039;&#039;. I would put my &#039;&#039;factorial.py&#039;&#039; in &#039;&#039;unittest/src&#039;&#039; and &#039;&#039;factorial_test.py&#039;&#039; in &#039;&#039;unittest/test&#039;&#039;. This way there is a very clear separation between function and test. The problem is making sure the test code loads the function code. Do it wrong a couple of times - it is very instructive.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Follow the file structure of having a &#039;&#039;code&#039;&#039; (or &#039;&#039;src&#039;&#039;) folder for programs, a &#039;&#039;test&#039;&#039; folder for tests, and now a &#039;&#039;testdata&#039;&#039; folder for files containing test data. Now make unit tests and appropriate test data files for your &#039;&#039;&#039;fasta&#039;&#039;&#039; class from last week. In this exercise you just need to make unit test for the method &#039;&#039;&#039;load&#039;&#039;&#039;. You need to hand in both tests and test data.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;save&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
# Add unit tests for the method &#039;&#039;&#039;delete&#039;&#039;&#039; in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. Hand in same way as above.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
I would not be surprised if you find errors in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class based on these tests. I found flaws in my code.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;br /&gt;
# Add unit tests for all methods in your &#039;&#039;&#039;fasta&#039;&#039;&#039; class. That will be a bit of work.&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=291</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=291"/>
		<updated>2026-04-10T12:07:43Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Subjects covered */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Unit test using pytest framework.&amp;lt;br&amp;gt;&lt;br /&gt;
Files, test data&amp;lt;br&amp;gt;&lt;br /&gt;
Setting up real projects&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=290</id>
		<title>Intermediate unit test</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Intermediate_unit_test&amp;diff=290"/>
		<updated>2026-04-10T12:05:47Z</updated>

		<summary type="html">&lt;p&gt;WikiSysop: /* Exercises for extra practice */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| width=500  style=&amp;quot;font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;&amp;quot;&lt;br /&gt;
|Previous: [[Beginning unit test]]&lt;br /&gt;
|Next: [[Runtime evaluation]]&lt;br /&gt;
|}&lt;br /&gt;
== Required course material for the lesson ==&lt;br /&gt;
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_09-Testing.ppt Testing]&amp;lt;br&amp;gt;&lt;br /&gt;
Online: [https://docs.pytest.org/ pytest documentation]&amp;lt;br&amp;gt;&lt;br /&gt;
Resource: [[Unit test - start of reverse polish notation class]]&amp;lt;br&amp;gt;&lt;br /&gt;
Blog: [https://www.joelonsoftware.com/2000/04/30/top-five-wrong-reasons-you-dont-have-testers/ On testing], by the founder of StackExchange.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subjects covered ==&lt;br /&gt;
Overview of test methods&amp;lt;br&amp;gt;&lt;br /&gt;
Unit test using pytest framework.&lt;br /&gt;
&lt;br /&gt;
== Exercises to be handed in ==&lt;br /&gt;
You should make a special folder for the exercises. I will refer to my special folder as &#039;&#039;unittest&#039;&#039; in these exercises. You will also see some &#039;&#039;__pycache__&#039;&#039; folders appear in places. This is Pythons cache for &amp;quot;compiled&amp;quot; programs. It is safe to ignore and also to delete, because it may become outdated.&lt;br /&gt;
&lt;br /&gt;
== Exercises for extra practice ==&lt;/div&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>