<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?action=history&amp;feed=atom&amp;title=Functions%2C_namespace%2C_memory_management</id>
	<title>Functions, namespace, memory management - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?action=history&amp;feed=atom&amp;title=Functions%2C_namespace%2C_memory_management"/>
	<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Functions,_namespace,_memory_management&amp;action=history"/>
	<updated>2026-04-14T20:26:57Z</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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=224&amp;oldid=prev</id>
		<title>WikiSysop: /* Subjects covered */</title>
		<link rel="alternate" type="text/html" href="https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=224&amp;oldid=prev"/>
		<updated>2026-03-16T11:10:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Subjects covered&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 13:10, 16 March 2026&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-l16&quot;&gt;Line 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&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;* Short about 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;* Short about 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;* Namespace in Python&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;* Namespace in Python&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;Memory management&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;* &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Function decorators&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 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;/table&gt;</summary>
		<author><name>WikiSysop</name></author>
	</entry>
	<entry>
		<id>https://teaching.healthtech.dtu.dk:443/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=223&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=223&amp;oldid=prev"/>
		<updated>2026-03-16T11:09:53Z</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 13:09, 16 March 2026&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-l7&quot;&gt;Line 7:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 7:&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-Functions.ppt Functions] - this will be short as it is a reminder.&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-Functions.ppt Functions] - this will be short as it is a reminder.&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-Namespace.ppt Namespace].&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_05-Namespace.ppt Namespace].&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;22118_05&lt;/del&gt;-&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;MemoryManagement&lt;/del&gt;.ppt &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Memory management&lt;/del&gt;]&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.&lt;/del&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;Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;22118_07&lt;/ins&gt;-&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Decorators&lt;/ins&gt;.ppt &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Decorators&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=f509116f-48e5-445b-bf6e-af27012ba23f Functions 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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=f509116f-48e5-445b-bf6e-af27012ba23f Functions 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=21e9d4d0-2ba5-465c-9939-af27012b7a7e Examples and identifying data types]&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;Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=21e9d4d0-2ba5-465c-9939-af27012b7a7e Examples and identifying data types]&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=192&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=192&amp;oldid=prev"/>
		<updated>2026-03-03T17:34: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 19:34, 3 March 2026&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-l30&quot;&gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 fourth and final part. Use your 3 functions to make a program &#039;&#039;&#039;namedcut.py&#039;&#039;&#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &#039;&#039;employee-data.csv&#039;&#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &#039;&#039;&#039;usage&#039;&#039;&#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &#039;&#039;ex1.dat&#039;&#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;404 &lt;/del&gt;in &#039;&#039;employee-data.csv&#039;&#039;&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 fourth and final part. Use your 3 functions to make a program &#039;&#039;&#039;namedcut.py&#039;&#039;&#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &#039;&#039;employee-data.csv&#039;&#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &#039;&#039;&#039;usage&#039;&#039;&#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &#039;&#039;ex1.dat&#039;&#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;403 &lt;/ins&gt;in &#039;&#039;employee-data.csv&#039;&#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;&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is no headline strip. Also, I have uploaded an new version of the employee-data.csv file, as there were some charset coding errors in it.&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is no headline strip. Also, I have uploaded an new version of the employee-data.csv file, as there were some charset coding errors in it.&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=191&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=191&amp;oldid=prev"/>
		<updated>2026-03-03T17:32:02Z</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 19:32, 3 March 2026&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-l32&quot;&gt;Line 32:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 32:&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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;&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is no headline strip.&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is no headline strip&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;. Also, I have uploaded an new version of the employee-data.csv file, as there were some charset coding errors in it&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=190&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=190&amp;oldid=prev"/>
		<updated>2026-03-03T17:03:02Z</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 19:03, 3 March 2026&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-l30&quot;&gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 fourth and final part. Use your 3 functions to make a program &#039;&#039;&#039;namedcut.py&#039;&#039;&#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &#039;&#039;employee-data.csv&#039;&#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &#039;&#039;&#039;usage&#039;&#039;&#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;not removing any headline&lt;/del&gt;. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &#039;&#039;ex1.dat&#039;&#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &#039;&#039;employee-data.csv&#039;&#039;&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 fourth and final part. Use your 3 functions to make a program &#039;&#039;&#039;namedcut.py&#039;&#039;&#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &#039;&#039;employee-data.csv&#039;&#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &#039;&#039;&#039;usage&#039;&#039;&#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &#039;&#039;ex1.dat&#039;&#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &#039;&#039;employee-data.csv&#039;&#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;&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is no headline strip.&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is no headline strip.&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=189&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=189&amp;oldid=prev"/>
		<updated>2026-03-03T17:02:20Z</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 19:02, 3 March 2026&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-l32&quot;&gt;Line 32:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 32:&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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;&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;not &lt;/del&gt;headline strip.&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;no &lt;/ins&gt;headline strip.&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=188&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=188&amp;oldid=prev"/>
		<updated>2026-03-03T17:02:02Z</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 19:02, 3 March 2026&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-l31&quot;&gt;Line 31:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 31:&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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 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;&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;Note that I added a description of the output in exercise 8, and changed the wording of 9, so there is not headline strip.&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=187&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=187&amp;oldid=prev"/>
		<updated>2026-03-03T17:00: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 19:00, 3 March 2026&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-l30&quot;&gt;Line 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 30:&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 the the third part. You learned about input from command line and options last week. Now make a function &amp;#039;&amp;#039;&amp;#039;parseCommand&amp;#039;&amp;#039;&amp;#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&amp;#039;&amp;#039;&amp;#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&amp;#039;&amp;#039;&amp;#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&amp;#039;file&amp;#039;:filename, &amp;#039;-c&amp;#039;: positiveIntegerList, &amp;#039;-n&amp;#039;: nameList}&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 fourth and final part. Use your 3 functions to make a program &#039;&#039;&#039;namedcut.py&#039;&#039;&#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &#039;&#039;employee-data.csv&#039;&#039; file. If you use the -c option, it will display the columns in the list in the given order&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, but stripped of the headline&lt;/del&gt;. If you use the -n option it will display the named columns in the list in the given order &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;- no headline strip&lt;/del&gt;. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &#039;&#039;&#039;usage&#039;&#039;&#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &#039;&#039;ex1.dat&#039;&#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &#039;&#039;employee-data.csv&#039;&#039;&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 fourth and final part. Use your 3 functions to make a program &#039;&#039;&#039;namedcut.py&#039;&#039;&#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &#039;&#039;employee-data.csv&#039;&#039; file. If you use the -c option, it will display the columns in the list in the given order. If you use the -n option it will display the named columns in the list in the given order. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &#039;&#039;&#039;usage&#039;&#039;&#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &#039;&#039;ex1.dat&#039;&#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &#039;&#039;employee-data.csv&#039;&#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;&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=186&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=186&amp;oldid=prev"/>
		<updated>2026-03-03T16:04:19Z</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 18:04, 3 March 2026&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-l29&quot;&gt;Line 29:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 29:&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 first part of a larger program - you might want to also read the next 3 exercises to get the full picture. You know that column based files can use different delimiters. The typical example of this is a tab-separated file, where the tab separates the columns. Other classic delimiters can be comma, colon, semicolon or the pipe sign. Now make a function, &amp;#039;&amp;#039;&amp;#039;determineDelimiter&amp;#039;&amp;#039;&amp;#039;, that as argument takes a line, investigates the line and determines if the delimiter is tab, comma, colon, semicolon or pipe sign in the preferred order, and return a single char which is the delimiter. It is required that the delimiter is present at least once in the line. If no delimiter can be found, return None.&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 first part of a larger program - you might want to also read the next 3 exercises to get the full picture. You know that column based files can use different delimiters. The typical example of this is a tab-separated file, where the tab separates the columns. Other classic delimiters can be comma, colon, semicolon or the pipe sign. Now make a function, &amp;#039;&amp;#039;&amp;#039;determineDelimiter&amp;#039;&amp;#039;&amp;#039;, that as argument takes a line, investigates the line and determines if the delimiter is tab, comma, colon, semicolon or pipe sign in the preferred order, and return a single char which is the delimiter. It is required that the delimiter is present at least once in the line. If no delimiter can be found, return None.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 the the third part. You learned about input from command line and options last week. Now make a function &#039;&#039;&#039;parseCommand&#039;&#039;&#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&#039;&#039;&#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&#039;&#039;&#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&#039;file&#039;:filename, &#039;-c&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-&lt;/del&gt;: positiveIntegerList, &#039;-n&#039;: nameList}&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 the the third part. You learned about input from command line and options last week. Now make a function &#039;&#039;&#039;parseCommand&#039;&#039;&#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&#039;&#039;&#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&#039;&#039;&#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. The function should return a dict with this content {&#039;file&#039;:filename, &#039;-c&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&lt;/ins&gt;: positiveIntegerList, &#039;-n&#039;: nameList}&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order, but stripped of the headline. If you use the -n option it will display the named columns in the list in the given order - no headline strip. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order, but stripped of the headline. If you use the -n option it will display the named columns in the list in the given order - no headline strip. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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;&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=185&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/22118/index.php?title=Functions,_namespace,_memory_management&amp;diff=185&amp;oldid=prev"/>
		<updated>2026-03-03T16:03: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 18:03, 3 March 2026&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-l29&quot;&gt;Line 29:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 29:&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 first part of a larger program - you might want to also read the next 3 exercises to get the full picture. You know that column based files can use different delimiters. The typical example of this is a tab-separated file, where the tab separates the columns. Other classic delimiters can be comma, colon, semicolon or the pipe sign. Now make a function, &amp;#039;&amp;#039;&amp;#039;determineDelimiter&amp;#039;&amp;#039;&amp;#039;, that as argument takes a line, investigates the line and determines if the delimiter is tab, comma, colon, semicolon or pipe sign in the preferred order, and return a single char which is the delimiter. It is required that the delimiter is present at least once in the line. If no delimiter can be found, return None.&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 first part of a larger program - you might want to also read the next 3 exercises to get the full picture. You know that column based files can use different delimiters. The typical example of this is a tab-separated file, where the tab separates the columns. Other classic delimiters can be comma, colon, semicolon or the pipe sign. Now make a function, &amp;#039;&amp;#039;&amp;#039;determineDelimiter&amp;#039;&amp;#039;&amp;#039;, that as argument takes a line, investigates the line and determines if the delimiter is tab, comma, colon, semicolon or pipe sign in the preferred order, and return a single char which is the delimiter. It is required that the delimiter is present at least once in the line. If no delimiter can be found, return None.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 second part. Sometimes column based files uses the first line as an identifying headline where each column gets a name that describes the data in the column. See the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file as an example. Make a function &amp;#039;&amp;#039;&amp;#039;identifyColumn&amp;#039;&amp;#039;&amp;#039;, that takes three arguments, a delimiter, a headline and a column name and return which column number the column name belongs to. Return None if a column can not be identified.&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 the the third part. You learned about input from command line and options last week. Now make a function &#039;&#039;&#039;parseCommand&#039;&#039;&#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&#039;&#039;&#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&#039;&#039;&#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both.&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 the the third part. You learned about input from command line and options last week. Now make a function &#039;&#039;&#039;parseCommand&#039;&#039;&#039; that analyzes the command line for input. Specifically the function should parse a command line that look like this:&amp;lt;br&amp;gt;&#039;&#039;&#039;someprog.py [-c &amp;lt;positiveIntegerList&amp;gt;] [-n &amp;lt;nameList&amp;gt;] &amp;lt;filename&amp;gt;&#039;&#039;&#039;&amp;lt;br&amp;gt; The two lists are comma-separated with no spaces. It must return a (possibly empty) list of numbers and a (possibly empty) list of names and a file name. The two options are mutually exclusive, which means it is an error to use both. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;The function should return a dict with this content {&#039;file&#039;:filename, &#039;-c-: positiveIntegerList, &#039;-n&#039;: nameList}&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;# This is the fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order, but stripped of the headline. If you use the -n option it will display the named columns in the list in the given order - no headline strip. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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 fourth and final part. Use your 3 functions to make a program &amp;#039;&amp;#039;&amp;#039;namedcut.py&amp;#039;&amp;#039;&amp;#039;, that works a bit like the Unix cut command in the sense that it selects the columns to display. The program will use as input the &amp;#039;&amp;#039;employee-data.csv&amp;#039;&amp;#039; file. If you use the -c option, it will display the columns in the list in the given order, but stripped of the headline. If you use the -n option it will display the named columns in the list in the given order - no headline strip. No matter the original delimiter the output should always be tab-separated. If a column based file is missing a headline then using the -n option is an error. Note that you would benefit from making a &amp;#039;&amp;#039;&amp;#039;usage&amp;#039;&amp;#039;&amp;#039; function for easy error handling. If neither option -c nor option -n are used, then the program displays all columns not removing any headline. This effectively means you can use the program to change the delimiter from comma/colon/semicolon to tab. If you have trouble using the functions in your program, think about the tasks/steps that are required to successfully make the program. Also, test your program on the &amp;#039;&amp;#039;ex1.dat&amp;#039;&amp;#039; file as the program is (should be) designed to work on that too. The number of Asians in the Ethnicity column is 404 in &amp;#039;&amp;#039;employee-data.csv&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;&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>