<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?action=history&amp;feed=atom&amp;title=Python_object_model</id>
	<title>Python object model - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?action=history&amp;feed=atom&amp;title=Python_object_model"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;action=history"/>
	<updated>2026-04-23T04:38:28Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=281&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=281&amp;oldid=prev"/>
		<updated>2025-10-14T12:37:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:37, 14 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l22&quot;&gt;Line 22:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or perform this process will make you fail the exam, so it is worth spending some time on the procedure.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or perform this process will make you fail the exam, so it is worth spending some time on the procedure.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &#039;&#039;test1.dat&#039;&#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber   Number Number Number ....&#039;&#039;&amp;lt;br&amp;gt;In the files &#039;&#039;test2.dat&#039;&#039; and &#039;&#039;test3.dat&#039;&#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &#039;&#039;combinedresults.txt&#039;&#039; in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber SingleAverageNumberOfAll3Experiments&#039;&#039; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;sorted according to the accession.&lt;/del&gt;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &#039;&#039;test1.dat&#039;&#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber   Number Number Number ....&#039;&#039;&amp;lt;br&amp;gt;In the files &#039;&#039;test2.dat&#039;&#039; and &#039;&#039;test3.dat&#039;&#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, sorted according to the accession, &lt;/ins&gt;in the file &#039;&#039;combinedresults.txt&#039;&#039; in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber SingleAverageNumberOfAll3Experiments&#039;&#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a main function that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;. The output should look like the input, that is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a main function that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;. The output should look like the input, that is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;The output file is this time &amp;#039;&amp;#039;trans2matrix.dat&amp;#039;&amp;#039; which should be identical with &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;The output file is this time &amp;#039;&amp;#039;trans2matrix.dat&amp;#039;&amp;#039; which should be identical with &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=280&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=280&amp;oldid=prev"/>
		<updated>2025-10-14T12:35:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:35, 14 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l22&quot;&gt;Line 22:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or perform this process will make you fail the exam, so it is worth spending some time on the procedure.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or perform this process will make you fail the exam, so it is worth spending some time on the procedure.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &#039;&#039;test1.dat&#039;&#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber   Number Number Number ....&#039;&#039;&amp;lt;br&amp;gt;In the files &#039;&#039;test2.dat&#039;&#039; and &#039;&#039;test3.dat&#039;&#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &#039;&#039;combinedresults.txt&#039;&#039; in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber SingleAverageNumberOfAll3Experiments&#039;&#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &#039;&#039;test1.dat&#039;&#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber   Number Number Number ....&#039;&#039;&amp;lt;br&amp;gt;In the files &#039;&#039;test2.dat&#039;&#039; and &#039;&#039;test3.dat&#039;&#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &#039;&#039;combinedresults.txt&#039;&#039; in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber SingleAverageNumberOfAll3Experiments&#039;&#039; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;sorted according to the accession.&lt;/ins&gt;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a main function that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;. The output should look like the input, that is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a main function that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;. The output should look like the input, that is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;The output file is this time &amp;#039;&amp;#039;trans2matrix.dat&amp;#039;&amp;#039; which should be identical with &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;The output file is this time &amp;#039;&amp;#039;trans2matrix.dat&amp;#039;&amp;#039; which should be identical with &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=278&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=278&amp;oldid=prev"/>
		<updated>2025-10-03T14:40:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:40, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This exercise set will be similar to the format of the exam. The content will obviously be different.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This exercise set will be similar to the format of the exam. The content will obviously be different.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You have to download [https://teaching.healthtech.dtu.dk/material/22116/22116_13.py this python file.] It contains some frame work code, but mostly some unfinished functions.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You have to download [https://teaching.healthtech.dtu.dk/material/22116/22116_13.py this python file.] It contains some frame work code, but mostly some unfinished functions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each exercise is about finishing one of the function groups in the file. You can write the functions directly in the python file, or use VScode or other &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Jupitor &lt;/del&gt;Notebook editor to write it, but then it has to be copied over to the python file. You must hand in the finished python file, &#039;&#039;&#039;not&#039;&#039;&#039; a .ipynb file.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each exercise is about finishing one of the function groups in the file. You can write the functions directly in the python file, or use VScode or other &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Jupyter &lt;/ins&gt;Notebook editor to write it, but then it has to be copied over to the python file. You must hand in the finished python file, &#039;&#039;&#039;not&#039;&#039;&#039; a .ipynb file.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or perform this process will make you fail the exam, so it is worth spending some time on the procedure.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or perform this process will make you fail the exam, so it is worth spending some time on the procedure.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=277&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=277&amp;oldid=prev"/>
		<updated>2025-10-03T14:40:12Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:40, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This exercise set will be similar to the format of the exam. The content will obviously be different.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This exercise set will be similar to the format of the exam. The content will obviously be different.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You have to download [https://teaching.healthtech.dtu.dk/material/22116/22116_13.py this python file.] It contains some frame work code, but mostly some unfinished functions.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You have to download [https://teaching.healthtech.dtu.dk/material/22116/22116_13.py this python file.] It contains some frame work code, but mostly some unfinished functions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each exercise is about finishing one of the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;functions &lt;/del&gt;in the file. You can write the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;function &lt;/del&gt;directly in the python file, or use VScode or other editor to write it, but then it has to be copied over to the python file. You must hand in the finished python file, &#039;&#039;&#039;not&#039;&#039;&#039; a .ipynb file.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each exercise is about finishing one of the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;function groups &lt;/ins&gt;in the file. You can write the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;functions &lt;/ins&gt;directly in the python file, or use VScode or other &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Jupitor Notebook &lt;/ins&gt;editor to write it, but then it has to be copied over to the python file. You must hand in the finished python file, &#039;&#039;&#039;not&#039;&#039;&#039; a .ipynb file.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;do &lt;/del&gt;this will make you fail the exam, so it is worth spending some time on the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;process&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;perform &lt;/ins&gt;this &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;process &lt;/ins&gt;will make you fail the exam, so it is worth spending some time on the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;procedure&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=276&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=276&amp;oldid=prev"/>
		<updated>2025-10-03T14:37:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:37, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l18&quot;&gt;Line 18:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 18:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Important - read this before starting&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Important - read this before starting&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This exercise set will be similar to the format of the exam. The content will obviously be different.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This exercise set will be similar to the format of the exam. The content will obviously be different.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You have to download this python file. It contains some frame work code, but mostly some unfinished functions.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You have to download &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[https://teaching.healthtech.dtu.dk/material/22116/22116_13.py &lt;/ins&gt;this python file.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;] &lt;/ins&gt;It contains some frame work code, but mostly some unfinished functions.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each exercise is about finishing one of the functions in the file. You can write the function directly in the python file, or use VScode or other editor to write it, but then it has to be copied over to the python file. You must hand in the finished python file, &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a .ipynb file.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Each exercise is about finishing one of the functions in the file. You can write the function directly in the python file, or use VScode or other editor to write it, but then it has to be copied over to the python file. You must hand in the finished python file, &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a .ipynb file.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or do this will make you fail the exam, so it is worth spending some time on the process.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or do this will make you fail the exam, so it is worth spending some time on the process.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=275&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=275&amp;oldid=prev"/>
		<updated>2025-10-03T14:33:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:33, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l27&quot;&gt;Line 27:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a main function that extracts data from one file and saves it in another, given the accession number, input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; and output file &amp;#039;&amp;#039;column.tab&amp;#039;&amp;#039;. Search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a main function that extracts data from one file and saves it in another, given the accession number, input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; and output file &amp;#039;&amp;#039;column.tab&amp;#039;&amp;#039;. Search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Read the file &#039;&#039;dna-array-norm.dat&#039;&#039; and transform all the numbers less than 0.5 to 0, and numbers at 0.5 or more to 1. Now for each line/accession calculate the average of the control group numbers and the cancer group numbers. If the two averages are more than 0.4 from each other, this is considered significant and the accession should be &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;printed &lt;/del&gt;along with a message &#039;&#039;&#039;up&#039;&#039;&#039; or &#039;&#039;&#039;down&#039;&#039;&#039; if it is an up regulation or a down regulation of the cancer group compared to the control.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Read the file &#039;&#039;dna-array-norm.dat&#039;&#039; and transform all the numbers less than 0.5 to 0, and numbers at 0.5 or more to 1. Now for each line/accession calculate the average of the control group numbers and the cancer group numbers. If the two averages are more than 0.4 from each other, this is considered significant and the accession should be &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;saved in the file &#039;&#039;regulation.txt&#039;&#039; &lt;/ins&gt;along with a message &#039;&#039;&#039;up&#039;&#039;&#039; or &#039;&#039;&#039;down&#039;&#039;&#039; if it is an up regulation or a down regulation of the cancer group compared to the control&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. That means each output line looks like &quot;H80240 up&quot; or &quot;H34534 down&quot;&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=274&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=274&amp;oldid=prev"/>
		<updated>2025-10-03T14:30:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:30, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l23&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;program &lt;/del&gt;that reads a tab separated file with numbers, &#039;&#039;matrix.dat&#039;&#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &#039;&#039;trans1matrix.dat&#039;&#039;. The output should look like the input, that is &#039;&#039;&#039;not&#039;&#039;&#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;main function &lt;/ins&gt;that reads a tab separated file with numbers, &#039;&#039;matrix.dat&#039;&#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &#039;&#039;trans1matrix.dat&#039;&#039;. The output should look like the input, that is &#039;&#039;&#039;not&#039;&#039;&#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;The output file is this time &amp;#039;&amp;#039;trans2matrix.dat&amp;#039;&amp;#039; which should be identical with &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;The output file is this time &amp;#039;&amp;#039;trans2matrix.dat&amp;#039;&amp;#039; which should be identical with &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &#039;&#039;dna-array.dat&#039;&#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &#039;0&#039; means that values in that column are from a cancer patient and a &#039;1&#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;program &lt;/del&gt;that extracts data from &#039;&#039;dna-array.dat&#039;&#039;. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations&lt;/del&gt;. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Then it shall search &lt;/del&gt;in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &#039;&#039;dna-array.dat&#039;&#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &#039;0&#039; means that values in that column are from a cancer patient and a &#039;1&#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;main function &lt;/ins&gt;that extracts data from &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;one file and saves it in another, given the accession number, input file &lt;/ins&gt;&#039;&#039;dna-array.dat&#039;&#039; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;and output file &#039;&#039;column&lt;/ins&gt;.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;tab&#039;&#039;&lt;/ins&gt;. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Search &lt;/ins&gt;in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Read the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039; and transform all the numbers less than 0.5 to 0, and numbers at 0.5 or more to 1. Now for each line/accession calculate the average of the control group numbers and the cancer group numbers. If the two averages are more than 0.4 from each other, this is considered significant and the accession should be printed along with a message &amp;#039;&amp;#039;&amp;#039;up&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;down&amp;#039;&amp;#039;&amp;#039; if it is an up regulation or a down regulation of the cancer group compared to the control.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Read the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039; and transform all the numbers less than 0.5 to 0, and numbers at 0.5 or more to 1. Now for each line/accession calculate the average of the control group numbers and the cancer group numbers. If the two averages are more than 0.4 from each other, this is considered significant and the accession should be printed along with a message &amp;#039;&amp;#039;&amp;#039;up&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;down&amp;#039;&amp;#039;&amp;#039; if it is an up regulation or a down regulation of the cancer group compared to the control.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Exercises for extra practice ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=273&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=273&amp;oldid=prev"/>
		<updated>2025-10-03T14:22:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:22, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l24&quot;&gt;Line 24:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 24:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a program that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;. The output should look like the input, that is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a program that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and save the transposed matrix in the file &amp;#039;&amp;#039;trans1matrix.dat&amp;#039;&amp;#039;. The output should look like the input, that is &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which gets a matrix as input an returned a transposed matrix - without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;The output file is this time &#039;&#039;trans2matrix.dat&#039;&#039; which should be identical with &#039;&#039;trans1matrix.dat&#039;&#039;&lt;/ins&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a program that extracts data from &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039;. It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations. Then it shall search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a program that extracts data from &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039;. It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations. Then it shall search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=272&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=272&amp;oldid=prev"/>
		<updated>2025-10-03T14:21:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:21, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l23&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &amp;#039;&amp;#039;test1.dat&amp;#039;&amp;#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber   Number Number Number ....&amp;#039;&amp;#039;&amp;lt;br&amp;gt;In the files &amp;#039;&amp;#039;test2.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;test3.dat&amp;#039;&amp;#039; are results from similar experiments but with a slightly different gene set. You want find the average the numbers from all experiments for each accession number. Save your results in the file &amp;#039;&amp;#039;combinedresults.txt&amp;#039;&amp;#039; in the form:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;AccessionNumber SingleAverageNumberOfAll3Experiments&amp;#039;&amp;#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a program that reads a tab separated file with numbers, &#039;&#039;matrix.dat&#039;&#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in the end print &lt;/del&gt;the transposed matrix &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;to &lt;/del&gt;the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;screen&lt;/del&gt;. The output should look like the input, not a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;transpose the matix &lt;/del&gt;without using any global variables&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. This can be done in two ways&lt;/del&gt;.&amp;lt;br&amp;gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;a)&#039;&#039;&#039; &lt;/del&gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.&amp;lt;br&amp;gt;&#039;&#039;&#039;b)&#039;&#039;&#039; transpose(matrix)&amp;lt;br&amp;gt;Here the matrix is transposed in-line, no returned matrix, i.e. the original data structure is changed.&amp;lt;br&amp;gt;You have implement at least one of the two ways. Hint: Make a function that prints a given matrix. That will be useful underway&lt;/del&gt;.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a program that reads a tab separated file with numbers, &#039;&#039;matrix.dat&#039;&#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;save &lt;/ins&gt;the transposed matrix &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in &lt;/ins&gt;the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;file &#039;&#039;trans1matrix.dat&#039;&#039;&lt;/ins&gt;. The output should look like the input, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;that is &#039;&#039;&#039;&lt;/ins&gt;not&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039; &lt;/ins&gt;a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;gets a matrix as input an returned a transposed matrix - &lt;/ins&gt;without using any global variables.&amp;lt;br&amp;gt;matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&#039;s entry on transposing a matrix.]&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;# This is the same problem as the previous exercise, except your transpose function have to transpose the matrix in-line, no returned matrix, i.e. the original matrix data structure is changed.&amp;lt;br&amp;gt;transpose(matrix)&lt;/ins&gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a program that extracts data from &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039;. It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations. Then it shall search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a program that extracts data from &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039;. It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations. Then it shall search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# The numbers in the input file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; should be normalized between 0 and 1 for each line with an accession number, i.e. normalization only for the individual line - not across the data set. Write the result out in the file &amp;#039;&amp;#039;dna-array-norm.dat&amp;#039;&amp;#039;, but NOT the control lines, i.e. lines where the annotation says &amp;#039;control&amp;#039;. The resulting file will be similar to the original, but control lines are removed and the numbers are different. The problem can (and should) be solved one line at a time.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=271&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises to be handed in */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=Python_object_model&amp;diff=271&amp;oldid=prev"/>
		<updated>2025-10-03T14:10:55Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises to be handed in&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:10, 3 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l22&quot;&gt;Line 22:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 22:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or do this will make you fail the exam, so it is worth spending some time on the process.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Inability to understand or do this will make you fail the exam, so it is worth spending some time on the process.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &#039;&#039;test1.dat&#039;&#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber   Number Number Number ....&#039;&#039;&amp;lt;br&amp;gt;In the files &#039;&#039;test2.dat&#039;&#039; and &#039;&#039;test3.dat&#039;&#039; are results from similar experiments but with a slightly different gene set. You want &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;to &lt;/del&gt;average the numbers from all experiments for each accession number. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The output this therefore on &lt;/del&gt;the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber SingleAverageNumberOfAll3Experiments&#039;&#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# In the file &#039;&#039;test1.dat&#039;&#039; is results from an experiment where every line is in the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber   Number Number Number ....&#039;&#039;&amp;lt;br&amp;gt;In the files &#039;&#039;test2.dat&#039;&#039; and &#039;&#039;test3.dat&#039;&#039; are results from similar experiments but with a slightly different gene set. You want &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;find the &lt;/ins&gt;average the numbers from all experiments for each accession number. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Save your results in the file &#039;&#039;combinedresults.txt&#039;&#039; in &lt;/ins&gt;the form:&amp;lt;br&amp;gt;&#039;&#039;AccessionNumber SingleAverageNumberOfAll3Experiments&#039;&#039;&amp;lt;br&amp;gt;Of course it might happen that a certain gene is only in one or two experiments and in that case you calculate the average for those. You must use a one of complex data structures to store this data, hint hint -  a dict of lists.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a program that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and in the end print the transposed matrix to the screen. The output should look like the input, not a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which transpose the matix without using any global variables. This can be done in two ways.&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;a)&amp;#039;&amp;#039;&amp;#039; matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;b)&amp;#039;&amp;#039;&amp;#039; transpose(matrix)&amp;lt;br&amp;gt;Here the matrix is transposed in-line, no returned matrix, i.e. the original data structure is changed.&amp;lt;br&amp;gt;You have implement at least one of the two ways. Hint: Make a function that prints a given matrix. That will be useful underway.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Create a program that reads a tab separated file with numbers, &amp;#039;&amp;#039;matrix.dat&amp;#039;&amp;#039;, (to be understood as a matrix) and stores the numbers in a matrix (list of lists). Having read the matrix from file it should now transpose it (rows to columns and columns to rows) and in the end print the transposed matrix to the screen. The output should look like the input, not a python data structure.&amp;lt;br&amp;gt;You must construct a function like transpose(matrix), which transpose the matix without using any global variables. This can be done in two ways.&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;a)&amp;#039;&amp;#039;&amp;#039; matrix = transpose(matrix)&amp;lt;br&amp;gt;This is the easiest, but momentarily most memory consuming method, you just return the transposed matrix, i.e. a new data structure.&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;b)&amp;#039;&amp;#039;&amp;#039; transpose(matrix)&amp;lt;br&amp;gt;Here the matrix is transposed in-line, no returned matrix, i.e. the original data structure is changed.&amp;lt;br&amp;gt;You have implement at least one of the two ways. Hint: Make a function that prints a given matrix. That will be useful underway.&amp;lt;br&amp;gt;How do you easily check if it works? Well, transposing twice yields the original matrix. [http://en.wikipedia.org/wiki/Transpose Check out Wikipedia&amp;#039;s entry on transposing a matrix.]&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a program that extracts data from &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039;. It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations. Then it shall search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# Study the file &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039; a bit. This is real DNA array data taken from a number of persons, some controls and some suffering from colon cancer. If you look at the second line there is a lot of 0 and 1. A &amp;#039;0&amp;#039; means that values in that column are from a cancer patient and a &amp;#039;1&amp;#039; means data are from a control (healthy person). The data are all log(intensity), i.e. the logarithm of the measured intensity of the relevant spot on the dna-chip. The data in this file will be used in coming exercises. The data/columns are tab separated. The second item on each line is the accession number for that particular gene.&amp;lt;br&amp;gt;Now make a program that extracts data from &amp;#039;&amp;#039;dna-array.dat&amp;#039;&amp;#039;. It shall ask for an accession number (unless you have given it on the command line). Make sure your program handles both situations. Then it shall search in the file for the data concerning that accession number. If it does not find it (you gave a wrong accession no), complain and stop. Otherwise it shall display the data in two tab separated columns. First column shall be the data from the cancer patients, second column for the controls. There are not the same number of sick and healthy people - be able to handle that.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
</feed>