<?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=List_manipulation</id>
	<title>List manipulation - 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=List_manipulation"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=List_manipulation&amp;action=history"/>
	<updated>2026-04-14T12:49:25Z</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=List_manipulation&amp;diff=263&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=List_manipulation&amp;diff=263&amp;oldid=prev"/>
		<updated>2025-10-03T13:55: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 15:55, 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-l17&quot;&gt;Line 17:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 17:&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 to be handed in ==&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 to be handed in ==&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;# Searching for accession numbers. In the file &#039;&#039;ex5.acc&#039;&#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result. Keep asking and searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&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;# Searching for accession numbers. In the file &#039;&#039;ex5.acc&#039;&#039; there are 6461 unique GenBank accession numbers (taken from HU6800 DNA array chip). An inexperienced bioinformatician unfortunately fouled up the list, so many of the accession numbers appears more than once. Make a program that first reads the file into a list, then ask for an accession number and counts how many times it appears in the list and displays the result. Keep asking and searching for accession numbers until STOP is entered. Hint: this is 2 loops inside one another.&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 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;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. There is room for optimization in the described algorithm and it is in any case not the most efficient method. Strings can be compared directly with each other using the operators &amp;lt;nowiki&amp;gt;==, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=.&amp;lt;/nowiki&amp;gt;&amp;lt;/font&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;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;You need to clean up the &#039;&#039;ex5.acc&#039;&#039; file. The first step is to sort the accession numbers alphabetically. You must program a sorting algorithm. There are many different algorithms for sorting, but let&#039;s pick a simple one - Bubble Sort.&amp;lt;br&amp;gt;It goes like this. Read the accessions into a list like the previous exercises. Go through the list looking at pairs of accessions (at position i &amp;amp; i+1). If a pair is in the wrong order, you switch them. Repeat going through the list until you have gone through the entire list without switching once. Now the list is sorted and you save the list in the &#039;&#039;sorted5.acc&#039;&#039; file.&amp;lt;br&amp;gt;Note: &#039;&#039;&#039;It takes 10-30 sec to run this program&#039;&#039;&#039;. There is room for optimization in the described algorithm and it is in any case not the most efficient method. Strings can be compared directly with each other using the operators &amp;lt;nowiki&amp;gt;==, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=.&amp;lt;/nowiki&amp;gt;&amp;lt;/font&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&lt;/ins&gt;&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;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &#039;&#039;sorted5.acc&#039;&#039; into a list. Since the list is now sorted, the duplicates are &quot;next&quot; to each other, which makes them easy to find. Make a &#039;&#039;&#039;new&#039;&#039;&#039; list with the unique accessions from the old list, and save that list in the file &#039;&#039;clean5.acc&#039;&#039;. Check that you have 6461 accessions, one per line.&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;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &#039;&#039;sorted5.acc&#039;&#039; into a list. Since the list is now sorted, the duplicates are &quot;next&quot; to each other, which makes them easy to find. Make a &#039;&#039;&#039;new&#039;&#039;&#039; list with the unique accessions from the old list, and save that list in the file &#039;&#039;clean5.acc&#039;&#039;. Check that you have 6461 accessions, one per line.&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 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 this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &#039;&#039;&#039;del&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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 this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &#039;&#039;&#039;del&#039;&#039;&#039; or &#039;&#039;&#039;pop&#039;&#039;&#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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 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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &#039;&#039;sums.dat&#039;&#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039;, &#039;&#039;ex1_3.dat&#039;&#039; and &#039;&#039;ex1corrupt.dat&#039;&#039; are good for testing.&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &#039;&#039;sums.dat&#039;&#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039;, &#039;&#039;ex1_3.dat&#039;&#039; and &#039;&#039;ex1corrupt.dat&#039;&#039; are good for testing.&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 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;# After having looked at the cleaned accession numbers in &#039;&#039;clean5.acc&#039;&#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. Make a program that reads the file and repeatedly asks for accessions and searches the list (and tells if it is there or not) using binary search until you enter STOP instead of an accession.&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;# After having looked at the cleaned accession numbers in &#039;&#039;clean5.acc&#039;&#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. Make a program that reads the file and repeatedly asks for accessions and searches the list (and tells if it is there or not) using binary search until you enter STOP instead of an accession.&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 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;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &#039;&#039;ex1.dat&#039;&#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &#039;&#039;ex1.dat&#039;&#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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 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;lt;font color=&amp;quot;#AA00FF&amp;quot;&amp;gt;Make a Python program that can select specific columns from a column based (tab separated) file and save them in a new file. It should select the columns that you specify in the order you specify. Ask for input and output file names and column numbers (3 questions, example &amp;quot;ex1.dat&amp;quot;, &amp;quot;2col.acc&amp;quot; &amp;amp; &amp;quot;3 1&amp;quot;). The program should work with any number of columns in the input file.&amp;lt;/font&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;lt;font color=&amp;quot;#AA00FF&amp;quot;&amp;gt;Make a Python program that can select specific columns from a column based (tab separated) file and save them in a new file. It should select the columns that you specify in the order you specify. Ask for input and output file names and column numbers (3 questions, example &amp;quot;ex1.dat&amp;quot;, &amp;quot;2col.acc&amp;quot; &amp;amp; &amp;quot;3 1&amp;quot;). The program should work with any number of columns in the input file.&amp;lt;/font&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;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=List_manipulation&amp;diff=246&amp;oldid=prev</id>
		<title>WikiSysop: /* Required course material for the lesson */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=List_manipulation&amp;diff=246&amp;oldid=prev"/>
		<updated>2025-10-03T09:54:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Required course material for the lesson&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 11:54, 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-l9&quot;&gt;Line 9:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 9:&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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;Resource: [[Example code - Lists]]&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;Resource: [[Example code - Lists]]&amp;lt;br&amp;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;Resource: [[Example code - Lists and enumerate]]&amp;lt;br&amp;gt;&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;div&gt;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=0d134a6c-ec9b-46d0-8a62-af27012bf0ef Live Coding]&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=0d134a6c-ec9b-46d0-8a62-af27012bf0ef Live Coding]&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=List_manipulation&amp;diff=238&amp;oldid=prev</id>
		<title>WikiSysop: /* Required course material for the lesson */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=List_manipulation&amp;diff=238&amp;oldid=prev"/>
		<updated>2025-09-22T10:02:20Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Required course material for the lesson&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 12:02, 22 September 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-l5&quot;&gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&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;|}&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;|}&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;== Required course material for the lesson ==&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;== Required course material for the lesson ==&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22116/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;22116_7&lt;/del&gt;-Lists.ppt List manipulation] Pretty comprehensive (read long).&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22116/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;22116_07&lt;/ins&gt;-Lists.ppt List manipulation] Pretty comprehensive (read long).&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;&amp;lt;!-- Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&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;lt;!-- Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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=List_manipulation&amp;diff=131&amp;oldid=prev</id>
		<title>WikiSysop: /* Required course material for the lesson */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=List_manipulation&amp;diff=131&amp;oldid=prev"/>
		<updated>2025-08-28T21:43:03Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Required course material for the lesson&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 23:43, 28 August 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-l8&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&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;lt;!-- Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&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;lt;!-- Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&amp;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;Resource: [[Example code - Lists]]&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=0d134a6c-ec9b-46d0-8a62-af27012bf0ef Live Coding]&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;== Subjects covered ==&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;== Subjects covered ==&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=List_manipulation&amp;diff=130&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=List_manipulation&amp;diff=130&amp;oldid=prev"/>
		<updated>2025-08-28T21:32:56Z</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 23:32, 28 August 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;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&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;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&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;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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 this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &#039;&#039;sums.&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;txt&lt;/del&gt;&#039;&#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039;, &#039;&#039;ex1_3.dat&#039;&#039; and &#039;&#039;ex1corrupt.dat&#039;&#039; are good for testing.&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &#039;&#039;sums.&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;dat&lt;/ins&gt;&#039;&#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039;, &#039;&#039;ex1_3.dat&#039;&#039; and &#039;&#039;ex1corrupt.dat&#039;&#039; are good for testing.&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;# After having looked at the cleaned accession numbers in &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. Make a program that reads the file and repeatedly asks for accessions and searches the list (and tells if it is there or not) using binary search until you enter STOP instead of an accession.&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;# After having looked at the cleaned accession numbers in &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. Make a program that reads the file and repeatedly asks for accessions and searches the list (and tells if it is there or not) using binary search until you enter STOP instead of an accession.&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;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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=List_manipulation&amp;diff=129&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=List_manipulation&amp;diff=129&amp;oldid=prev"/>
		<updated>2025-08-28T20:47:08Z</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 22:47, 28 August 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;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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 this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &amp;#039;&amp;#039;sums.txt&amp;#039;&amp;#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;ex1corrupt.dat&amp;#039;&amp;#039; are good for testing.&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &amp;#039;&amp;#039;sums.txt&amp;#039;&amp;#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;ex1corrupt.dat&amp;#039;&amp;#039; are good for testing.&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;# After having looked at the cleaned accession numbers in &#039;&#039;clean5.acc&#039;&#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Repeat exercise 3 from last week, but this time use &lt;/del&gt;binary search instead of &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;the linear search you did then. See what Wikipedia has to say about [http://en.wikipedia.org/wiki/Binary_search binary search]. Binary search as a method is well described in the solution to the &quot;guess a number&quot; exercise&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;# After having looked at the cleaned accession numbers in &#039;&#039;clean5.acc&#039;&#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Make a program that reads the file and repeatedly asks for accessions and searches the list (and tells if it is there or not) using &lt;/ins&gt;binary search &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;until you enter STOP &lt;/ins&gt;instead of &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;an accession&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;div&gt;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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;# &amp;lt;font color=&amp;quot;#AA00FF&amp;quot;&amp;gt;Make a Python program that can select specific columns from a column based (tab separated) file and save them in a new file. It should select the columns that you specify in the order you specify. Ask for input and output file names and column numbers (3 questions, example &amp;quot;ex1.dat&amp;quot;, &amp;quot;2col.acc&amp;quot; &amp;amp; &amp;quot;3 1&amp;quot;). The program should work with any number of columns in the input file.&amp;lt;/font&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;lt;font color=&amp;quot;#AA00FF&amp;quot;&amp;gt;Make a Python program that can select specific columns from a column based (tab separated) file and save them in a new file. It should select the columns that you specify in the order you specify. Ask for input and output file names and column numbers (3 questions, example &amp;quot;ex1.dat&amp;quot;, &amp;quot;2col.acc&amp;quot; &amp;amp; &amp;quot;3 1&amp;quot;). The program should work with any number of columns in the input file.&amp;lt;/font&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=List_manipulation&amp;diff=128&amp;oldid=prev</id>
		<title>WikiSysop: /* Required course material for the lesson */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=List_manipulation&amp;diff=128&amp;oldid=prev"/>
		<updated>2025-08-28T20:40:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Required course material for the lesson&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 22:40, 28 August 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-l5&quot;&gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&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;|}&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;|}&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;== Required course material for the lesson ==&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;== Required course material for the lesson ==&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22116/22116_7-Lists.ppt List manipulation]&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22116/22116_7-Lists.ppt List manipulation] &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Pretty comprehensive (read long).&lt;/ins&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;&amp;lt;!-- Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&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;lt;!-- Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=871af158-9477-47c6-8e89-af27012d6e8d The basics of lists in python]&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=e3b143a8-962c-40ee-bd10-af27012d502c Working with lists, modification]&amp;lt;br&amp;gt; --&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=List_manipulation&amp;diff=127&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=List_manipulation&amp;diff=127&amp;oldid=prev"/>
		<updated>2025-08-28T20:37:24Z</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 22:37, 28 August 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;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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 this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &amp;#039;&amp;#039;sums.txt&amp;#039;&amp;#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;ex1corrupt.dat&amp;#039;&amp;#039; are good for testing.&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &amp;#039;&amp;#039;sums.txt&amp;#039;&amp;#039;. The input files may be corrupted or not the same length. Deal with that by assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; and &amp;#039;&amp;#039;ex1corrupt.dat&amp;#039;&amp;#039; are good for testing.&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;# After having looked at the cleaned accession numbers in &#039;&#039;clean5.acc&#039;&#039;, you will have seen that the accession numbers are sorted. This means that you can use the much more powerful binary search method when searching for accession numbers. Repeat exercise 3 from last week, but this time use binary search instead of the linear search you did then. See what Wikipedia has to say about [http://en.wikipedia.org/wiki/Binary_search binary search]. Binary search as a method is well described in the solution to the &quot;guess a number&quot; exercise.&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;# Make a program that calculates the sum of all columns in an input file, no matter how many columns there are. Each column should be summed individually. You can assume that each row (line) has the same number of columns in the file. In the file &#039;&#039;ex1.dat&#039;&#039;, the sums of the three columns are: -904.4143, 482.8410, 292.0515&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;# &amp;lt;font color=&quot;#AA00FF&quot;&amp;gt;Make a Python program that can select specific columns from a column based (tab separated) file and save them in a new file. It should select the columns that you specify in the order you specify. Ask for input and output file names and column numbers (3 questions, example &quot;ex1.dat&quot;, &quot;2col.acc&quot; &amp;amp; &quot;3 1&quot;). The program should work with any number of columns in the input file.&amp;lt;/font&amp;gt;&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=List_manipulation&amp;diff=126&amp;oldid=prev</id>
		<title>WikiSysop: /* Exercises for extra practice */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22116/index.php?title=List_manipulation&amp;diff=126&amp;oldid=prev"/>
		<updated>2025-08-28T20:32:04Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercises for extra practice&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 22:32, 28 August 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-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&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;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;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Read two files with numbers into two lists. Files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039; &amp;amp; &#039;&#039;ex1_3.dat&#039;&#039; are good to use for this. Now add the numbers together, like the first number in the first file with the first number in the second file, and so forth, i.e. add the column in the file row-wise. You could also consider the numbers in a file to be a vector, and then you add two vectors together. Save the output (a list of numbers, one number per line) in a new file - you decide the name.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&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;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Continuing previous exercise: Corrupt your input files a bit, change some numbers to not-numbers, like words or empty lines. Make your program work on these files too, assuming anything you can not read is ignored - consider any line you can not convert to a number as containing a zero.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&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;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Continuing previous exercise: Make the program work even if the input files do not have the same length, just assume zero for the missing lines in the short file. BTW, you do not know which input is short.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&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 a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&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 a file with numbers into two lists. The first number in the file goes to the first list, the second number to the second list, the third number to the first list, and so forth - alternating numbers to alternating lists. Compute the sum of the two lists and display. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&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;* Now compute the same sums - without the lists :-)&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;* Now compute the same sums - without the lists :-)&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;* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP. Your list of numbers will simply grow with each file you add. Now compute the sum of the numbers in the list and display the result. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&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;* Ask for files names and read the numbers in the file into a list. Continue to ask for file names and add the numbers to the list until you enter STOP. Your list of numbers will simply grow with each file you add. Now compute the sum of the numbers in the list and display the result. Files &amp;#039;&amp;#039;ex1_1.dat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;ex1_2.dat&amp;#039;&amp;#039; &amp;amp; &amp;#039;&amp;#039;ex1_3.dat&amp;#039;&amp;#039; are good to use for this.&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=List_manipulation&amp;diff=125&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=List_manipulation&amp;diff=125&amp;oldid=prev"/>
		<updated>2025-08-28T20:31:13Z</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 22:31, 28 August 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;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&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;# It is now time to find the unique accession numbers, so you only have one of each - no duplicates. Read the accessions from &amp;#039;&amp;#039;sorted5.acc&amp;#039;&amp;#039; into a list. Since the list is now sorted, the duplicates are &amp;quot;next&amp;quot; to each other, which makes them easy to find. Make a &amp;#039;&amp;#039;&amp;#039;new&amp;#039;&amp;#039;&amp;#039; list with the unique accessions from the old list, and save that list in the file &amp;#039;&amp;#039;clean5.acc&amp;#039;&amp;#039;. Check that you have 6461 accessions, one per line.&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;# In this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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 this exercise you have to do the same and achieve the same result in a different way as the previous exercise. Instead of making a new list with the unique accessions, just keep the old list and remove the duplicates. You can use &amp;#039;&amp;#039;&amp;#039;del&amp;#039;&amp;#039;&amp;#039; or &amp;#039;&amp;#039;&amp;#039;pop&amp;#039;&amp;#039;&amp;#039; to remove elements. If you run into trouble imagine your code executed on this list: [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &#039;&#039;sums.txt&#039;&#039;. The input files may be corrupted or not the same length. Deal with that &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;my &lt;/del&gt;assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039;, &#039;&#039;ex1_3.dat&#039;&#039; and &#039;&#039;ex1corrupt.dat&#039;&#039; are good for testing.&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;# First ask for some input file names. Do this a either a loop where you ask for one file name at a time until empty string is entered, or all file names on a space separated string. You must compute the sum of the first number in all files, the sum of the second number in all files and so forth. Save the sums in the output file &#039;&#039;sums.txt&#039;&#039;. The input files may be corrupted or not the same length. Deal with that &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;by &lt;/ins&gt;assuming a corrupted line (a line you can not convert to a number) and missing lines in short files are 0. The files &#039;&#039;ex1_1.dat&#039;&#039;, &#039;&#039;ex1_2.dat&#039;&#039;, &#039;&#039;ex1_3.dat&#039;&#039; and &#039;&#039;ex1corrupt.dat&#039;&#039; are good for testing.&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>
</feed>