<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Eroman</id>
	<title>ICO wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Eroman"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php/Special:Contributions/Eroman"/>
	<updated>2026-06-16T01:42:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=128879</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=128879"/>
		<updated>2018-01-11T11:53:08Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a README that explains how to run it.&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline will be Monday January 15, 2018.&lt;br /&gt;
&lt;br /&gt;
=== Don&#039;t have a project idea? ===&lt;br /&gt;
&lt;br /&gt;
You may do the following task. You submit it like a project and will follow the same requirements. So it must have a relevant unittest, and a readme, and be in version control (i.e. github, bitbucket). &lt;br /&gt;
&lt;br /&gt;
Write a script that takes the following CSV (https://blockchain.info/charts/market-price) and can tell the user the following information:&lt;br /&gt;
&lt;br /&gt;
* What was the greatest percent increase over the previous day, and what day was it?&lt;br /&gt;
* What was the greatest percent decrease over the previous day, and what day was it?&lt;br /&gt;
* What is the highest price in the the data, and what day was it?&lt;br /&gt;
&lt;br /&gt;
It should be clear how to get the the script to use the csv file by path in the commandline&lt;br /&gt;
For a unittest, make sure there is a function that can calculate the desired values, and you can test that function with example data as inputs.&lt;br /&gt;
&lt;br /&gt;
Here is how to find biggest changes between values in a series&lt;br /&gt;
https://gist.github.com/anonymous/ed315c65da92fd685a9668c74402c7fc&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/18f50e3b-dd4d-4f8d-ab90-d20b5b0886d7/public&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/850df2db-0c72-4c75-b768-c2f511a65e9f/public&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;br /&gt;
&lt;br /&gt;
=== Lectures 8 &amp;amp; 9 ===&lt;br /&gt;
&lt;br /&gt;
Django&lt;br /&gt;
&lt;br /&gt;
Knowledge of Django is only useful if you are using Django. &lt;br /&gt;
&lt;br /&gt;
Here is the code I made with my lecture: https://github.com/evrom/django-example-for-class&lt;br /&gt;
&lt;br /&gt;
Here is a good tutorial to start with django: https://tutorial.djangogirls.org/en/django/&lt;br /&gt;
&lt;br /&gt;
=== Lecture 10 ===&lt;br /&gt;
&lt;br /&gt;
Binary, Hex, and Base64 with CryptoPals&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture10&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=128703</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=128703"/>
		<updated>2017-12-20T11:29:28Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Don&amp;#039;t have a project idea? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a README that explains how to run it.&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline will be Friday January 12, 2018.&lt;br /&gt;
&lt;br /&gt;
=== Don&#039;t have a project idea? ===&lt;br /&gt;
&lt;br /&gt;
You may do the following task. You submit it like a project and will follow the same requirements. So it must have a relevant unittest, and a readme, and be in version control (i.e. github, bitbucket). &lt;br /&gt;
&lt;br /&gt;
Write a script that takes the following CSV (https://blockchain.info/charts/market-price) and can tell the user the following information:&lt;br /&gt;
&lt;br /&gt;
* What was the greatest percent increase over the previous day, and what day was it?&lt;br /&gt;
* What was the greatest percent decrease over the previous day, and what day was it?&lt;br /&gt;
* What is the highest price in the the data, and what day was it?&lt;br /&gt;
&lt;br /&gt;
It should be clear how to get the the script to use the csv file by path in the commandline&lt;br /&gt;
For a unittest, make sure there is a function that can calculate the desired values, and you can test that function with example data as inputs.&lt;br /&gt;
&lt;br /&gt;
Here is how to find biggest changes between values in a series&lt;br /&gt;
https://gist.github.com/anonymous/ed315c65da92fd685a9668c74402c7fc&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/18f50e3b-dd4d-4f8d-ab90-d20b5b0886d7/public&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/850df2db-0c72-4c75-b768-c2f511a65e9f/public&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;br /&gt;
&lt;br /&gt;
=== Lectures 8 &amp;amp; 9 ===&lt;br /&gt;
&lt;br /&gt;
Django&lt;br /&gt;
&lt;br /&gt;
Knowledge of Django is only useful if you are using Django. &lt;br /&gt;
&lt;br /&gt;
Here is the code I made with my lecture: https://github.com/evrom/django-example-for-class&lt;br /&gt;
&lt;br /&gt;
Here is a good tutorial to start with django: https://tutorial.djangogirls.org/en/django/&lt;br /&gt;
&lt;br /&gt;
=== Lecture 10 ===&lt;br /&gt;
&lt;br /&gt;
Binary, Hex, and Base64 with CryptoPals&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture10&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=127812</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=127812"/>
		<updated>2017-12-11T11:18:35Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a README that explains how to run it.&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline will be Friday January 12, 2018.&lt;br /&gt;
&lt;br /&gt;
=== Don&#039;t have a project idea? ===&lt;br /&gt;
&lt;br /&gt;
You may do the following task. You submit it like a project and will follow the same requirements. So it must have a relevant unittest, and a readme, and be in version control (i.e. github, bitbucket). &lt;br /&gt;
&lt;br /&gt;
Write a script that takes the following CSV (https://blockchain.info/charts/market-price) and can tell the user the following information:&lt;br /&gt;
&lt;br /&gt;
* What was the greatest percent increase over the previous day, and what day was it?&lt;br /&gt;
* What was the greatest percent decrease over the previous day, and what day was it?&lt;br /&gt;
* What is the highest price in the the data, and what day was it?&lt;br /&gt;
&lt;br /&gt;
It should be clear how to get the the script to use the csv file by path in the commandline&lt;br /&gt;
For a unittest, make sure there is a function that can calculate the desired values, and you can test that function with example data as inputs.&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/18f50e3b-dd4d-4f8d-ab90-d20b5b0886d7/public&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/850df2db-0c72-4c75-b768-c2f511a65e9f/public&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;br /&gt;
&lt;br /&gt;
=== Lectures 8 &amp;amp; 9 ===&lt;br /&gt;
&lt;br /&gt;
Django&lt;br /&gt;
&lt;br /&gt;
Knowledge of Django is only useful if you are using Django. &lt;br /&gt;
&lt;br /&gt;
Here is the code I made with my lecture: https://github.com/evrom/django-example-for-class&lt;br /&gt;
&lt;br /&gt;
Here is a good tutorial to start with django: https://tutorial.djangogirls.org/en/django/&lt;br /&gt;
&lt;br /&gt;
=== Lecture 10 ===&lt;br /&gt;
&lt;br /&gt;
Binary, Hex, and Base64 with CryptoPals&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture10&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=126804</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=126804"/>
		<updated>2017-11-14T08:51:55Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/18f50e3b-dd4d-4f8d-ab90-d20b5b0886d7/public&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/850df2db-0c72-4c75-b768-c2f511a65e9f/public&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;br /&gt;
&lt;br /&gt;
=== Lectures 8 &amp;amp; 9 ===&lt;br /&gt;
&lt;br /&gt;
Django&lt;br /&gt;
&lt;br /&gt;
Knowledge of Django is only useful if you are using Django. &lt;br /&gt;
&lt;br /&gt;
Here is the code I made with my lecture: https://github.com/evrom/django-example-for-class&lt;br /&gt;
&lt;br /&gt;
Here is a good tutorial to start with django: https://tutorial.djangogirls.org/en/django/&lt;br /&gt;
&lt;br /&gt;
=== Lecture 10 ===&lt;br /&gt;
&lt;br /&gt;
Binary, Hex, and Base64 with CryptoPals&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture10&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=126803</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=126803"/>
		<updated>2017-11-14T08:48:39Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/c55c42d4-ecbb-4a3a-8508-6c7d66577044/home&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/e8d9bf77-53ea-467a-b31b-7afc0352bd00/home &lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;br /&gt;
&lt;br /&gt;
=== Lectures 8 &amp;amp; 9 ===&lt;br /&gt;
&lt;br /&gt;
Django&lt;br /&gt;
&lt;br /&gt;
Knowledge of Django is only useful if you are using Django. &lt;br /&gt;
&lt;br /&gt;
Here is the code I made with my lecture: https://github.com/evrom/django-example-for-class&lt;br /&gt;
&lt;br /&gt;
Here is a good tutorial to start with django: https://tutorial.djangogirls.org/en/django/&lt;br /&gt;
&lt;br /&gt;
=== Lecture 10 ===&lt;br /&gt;
&lt;br /&gt;
Binary, Hex, and Base64 with CryptoPals&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture10&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=126802</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=126802"/>
		<updated>2017-11-14T08:28:50Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/c55c42d4-ecbb-4a3a-8508-6c7d66577044/home&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/e8d9bf77-53ea-467a-b31b-7afc0352bd00/home &lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 10 ===&lt;br /&gt;
&lt;br /&gt;
Binary, Hex, and Base64 with CryptoPals&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture10&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture10&amp;diff=126801</id>
		<title>Advanced Python (Fall 2017)/lecture10</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture10&amp;diff=126801"/>
		<updated>2017-11-14T08:26:52Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 10 =  Cryptopals  https://cryptopals.com/  Many solution here: https://www.google.ee/search?dcr=0&amp;amp;amp;source=hp&amp;amp;amp;ei=k-oCWtGxJaHg6ASl0a4g&amp;amp;amp;q=cryptopals+solution...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 10 =&lt;br /&gt;
&lt;br /&gt;
Cryptopals&lt;br /&gt;
&lt;br /&gt;
https://cryptopals.com/&lt;br /&gt;
&lt;br /&gt;
Many solution here: https://www.google.ee/search?dcr=0&amp;amp;amp;source=hp&amp;amp;amp;ei=k-oCWtGxJaHg6ASl0a4g&amp;amp;amp;q=cryptopals+solutions+python&amp;amp;amp;oq=cryptopals+solutions+p&amp;amp;amp;gs_l=psy-ab.3.0.0i19k1.657.4332.0.4870.17.16.1.0.0.0.124.1236.14j2.16.0....0...1.1.64.psy-ab..0.17.1235...0j0i131k1j0i22i30i19k1j33i21k1j33i160k1.0.IM86h-JeYBc&lt;br /&gt;
&lt;br /&gt;
Very good solutions here (better than mine): https://github.com/ricpacca/cryptopals&lt;br /&gt;
&lt;br /&gt;
== Binary, Hex, Base64 ==&lt;br /&gt;
&lt;br /&gt;
Look them up if you don&#039;t know what they are. Unfortanetly, I cannot find a very good introduction to the topics in python.&lt;br /&gt;
&lt;br /&gt;
In python you have integer literals in base 10, like &amp;lt;code&amp;gt;10&amp;lt;/code&amp;gt; or in base 16, like &amp;lt;code&amp;gt;0xf&amp;lt;/code&amp;gt; or in base 2, like &amp;lt;code&amp;gt;0b1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Binary numbers can easily be representing in base 16 (called &amp;amp;quot;Hex&amp;amp;quot;). 8 bits (binary digits) is 2 digits in hex. Base64 is a way of storing binary data so it uses only ascii characters. A string of Base64 is shorter than a string of equivalent Hex, so Base64 is popular way to put binary data embeded in a text document.&lt;br /&gt;
&lt;br /&gt;
== Problems ==&lt;br /&gt;
&lt;br /&gt;
The problems are good because they require us to understand encoding in python. My solutions are poorer quality in comparison to the solutions here: https://github.com/ricpacca/cryptopals&lt;br /&gt;
&lt;br /&gt;
== Problem 1-1 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import base64&lt;br /&gt;
&lt;br /&gt;
message_hex = &amp;quot;49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d&amp;quot;&lt;br /&gt;
message_bytes = bytearray.fromhex(message_hex)&lt;br /&gt;
message_base64 = base64.encodebytes(message_bytes)&lt;br /&gt;
print(message_base64)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Problem 1-2 ==&lt;br /&gt;
&lt;br /&gt;
one way&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# Convert both hex string to bytes&lt;br /&gt;
hex_string_1 = &#039;1c0111001f010100061a024b53535009181c&#039;&lt;br /&gt;
hex_string_2 = &#039;686974207468652062756c6c277320657965&#039;&lt;br /&gt;
&lt;br /&gt;
bytes_1 = bytearray.fromhex(hex_string_1)&lt;br /&gt;
bytes_2 = bytearray.fromhex(hex_string_2)&lt;br /&gt;
&lt;br /&gt;
# Pair each byte with other byte in same position&lt;br /&gt;
byte_pair_list = list(zip(bytes_1, bytes_2))&lt;br /&gt;
&lt;br /&gt;
# go through each bit in hex string bytes, and xor, and store result&lt;br /&gt;
# XOR opertator is ^&lt;br /&gt;
result_list = []&lt;br /&gt;
for b1, b2 in byte_pair_list:&lt;br /&gt;
    xor_result = b1 ^ b2&lt;br /&gt;
    result_list.append(xor_result)&lt;br /&gt;
&lt;br /&gt;
# convert list of integers to hex&lt;br /&gt;
result_bytes = bytearray(result_list)&lt;br /&gt;
print(bytearray.hex(result_bytes))&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=125102</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=125102"/>
		<updated>2017-10-23T22:14:53Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions. Unless you are using asyncio, which can only support python 3.&lt;br /&gt;
`&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/fail, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/c55c42d4-ecbb-4a3a-8508-6c7d66577044/home&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/e8d9bf77-53ea-467a-b31b-7afc0352bd00/home &lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;br /&gt;
&lt;br /&gt;
=== Lecture 6 ===&lt;br /&gt;
&lt;br /&gt;
Concurrency&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture6&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Lecture 7 ===&lt;br /&gt;
&lt;br /&gt;
Defining datatypes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture7&amp;diff=125101</id>
		<title>Advanced Python (Fall 2017)/lecture7</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture7&amp;diff=125101"/>
		<updated>2017-10-23T22:14:25Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 7 =  Data types  == Data type things to know ==  clases in python describe datatype, and when called, create a new object of that type. &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; returns the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 7 =&lt;br /&gt;
&lt;br /&gt;
Data types&lt;br /&gt;
&lt;br /&gt;
== Data type things to know ==&lt;br /&gt;
&lt;br /&gt;
clases in python describe datatype, and when called, create a new object of that type. &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; returns the datatype &amp;lt;code&amp;gt;isinstance&amp;lt;/code&amp;gt; check if object is an instance of the class&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;In [3]: class A:&lt;br /&gt;
   ...:     pass&lt;br /&gt;
   ...:&lt;br /&gt;
&lt;br /&gt;
In [4]: type(A)&lt;br /&gt;
Out[4]: type&lt;br /&gt;
&lt;br /&gt;
In [5]: type(int)&lt;br /&gt;
Out[5]: type&lt;br /&gt;
&lt;br /&gt;
In [6]: int(10)&lt;br /&gt;
Out[6]: 10&lt;br /&gt;
&lt;br /&gt;
In [7]: float(10)&lt;br /&gt;
 Out[7]: 10.0&lt;br /&gt;
&lt;br /&gt;
In [8]: isinstance(10, int)&lt;br /&gt;
Out[8]: True&lt;br /&gt;
&lt;br /&gt;
In [9]: isinstance(10, float)&lt;br /&gt;
Out[9]: False&lt;br /&gt;
&lt;br /&gt;
In [10]: class MyInt(int):&lt;br /&gt;
    pass&lt;br /&gt;
   ....:&lt;br /&gt;
&lt;br /&gt;
In [11]: a = MyInt(10)&lt;br /&gt;
&lt;br /&gt;
In [12]: a&lt;br /&gt;
Out[12]: 10&lt;br /&gt;
&lt;br /&gt;
In [13]: type(a)&lt;br /&gt;
Out[13]: __main__.MyInt&lt;br /&gt;
&lt;br /&gt;
In [14]: isinstance(a, int)&lt;br /&gt;
Out[14]: True&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Magic Methods ==&lt;br /&gt;
&lt;br /&gt;
there are prefixed and suffixed with &#039;__&#039;, sometimes called &#039;dunder&#039; for &#039;double underscore&#039;.&lt;br /&gt;
&lt;br /&gt;
They define specific python functionality.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;class A:&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        pass&lt;br /&gt;
&lt;br /&gt;
    def __str__(self):&lt;br /&gt;
        return &#039;I am an instance of A&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
a = A()&lt;br /&gt;
print(a.__str__())&lt;br /&gt;
print(str(a))&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Task 1 ===&lt;br /&gt;
&lt;br /&gt;
Make an integer which is: equal to both 5, 6 and the actual number (itself) greater than 3 less than 2&lt;br /&gt;
&lt;br /&gt;
=== Solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class MyInt(int):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Define some magic methods!&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def __lt__(self, x):&lt;br /&gt;
        if x == 2:&lt;br /&gt;
            return True&lt;br /&gt;
        else:&lt;br /&gt;
            return super().__lt__(x)&lt;br /&gt;
&lt;br /&gt;
    def __gt__(self, x):&lt;br /&gt;
        if x == 3:&lt;br /&gt;
            return True&lt;br /&gt;
        else:&lt;br /&gt;
            return super().__gt__(x)&lt;br /&gt;
&lt;br /&gt;
    def __eq__(self, x):&lt;br /&gt;
        if x == 5 or x == 6:&lt;br /&gt;
            return True&lt;br /&gt;
        else:&lt;br /&gt;
            return super().__eq__(x)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class MyIntTestCase(TestCase):&lt;br /&gt;
    def test_gt(self):&lt;br /&gt;
        a = MyInt(1)&lt;br /&gt;
        self.assertTrue(a &amp;gt; 3)&lt;br /&gt;
&lt;br /&gt;
    def test_lt(self):&lt;br /&gt;
        a = MyInt(100)&lt;br /&gt;
        self.assertTrue(a &amp;lt; 2)&lt;br /&gt;
&lt;br /&gt;
    def test_eq(self):&lt;br /&gt;
        a = MyInt(1)&lt;br /&gt;
        self.assertTrue(a == 5)&lt;br /&gt;
        self.assertTrue(a == 6)&amp;lt;/source&amp;gt;&lt;br /&gt;
```&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture6&amp;diff=125100</id>
		<title>Advanced Python (Fall 2017)/lecture6</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture6&amp;diff=125100"/>
		<updated>2017-10-23T22:08:21Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 6: Concurrency =  Concurrency is doing to things at once, not necessarily simultaneously.  == Task 1. ==  Make a socket echo server  === Solution ===  use google! th...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 6: Concurrency =&lt;br /&gt;
&lt;br /&gt;
Concurrency is doing to things at once, not necessarily simultaneously.&lt;br /&gt;
&lt;br /&gt;
== Task 1. ==&lt;br /&gt;
&lt;br /&gt;
Make a socket echo server&lt;br /&gt;
&lt;br /&gt;
=== Solution ===&lt;br /&gt;
&lt;br /&gt;
use google! this one is from https://pymotw.com/3/socket/tcp.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# socket_echo_server.py&lt;br /&gt;
&lt;br /&gt;
import socket&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
# Create a TCP/IP socket&lt;br /&gt;
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;
&lt;br /&gt;
# Bind the socket to the port&lt;br /&gt;
server_address = (&#039;localhost&#039;, 10000)&lt;br /&gt;
print(&#039;starting up on {} port {}&#039;.format(*server_address))&lt;br /&gt;
sock.bind(server_address)&lt;br /&gt;
&lt;br /&gt;
# Listen for incoming connections&lt;br /&gt;
sock.listen(1)&lt;br /&gt;
&lt;br /&gt;
while True:&lt;br /&gt;
    # Wait for a connection&lt;br /&gt;
    print(&#039;waiting for a connection&#039;)&lt;br /&gt;
    connection, client_address = sock.accept()&lt;br /&gt;
    try:&lt;br /&gt;
        print(&#039;connection from&#039;, client_address)&lt;br /&gt;
&lt;br /&gt;
        # Receive the data in small chunks and retransmit it&lt;br /&gt;
        while True:&lt;br /&gt;
            data = connection.recv(16)&lt;br /&gt;
            print(&#039;received {!r}&#039;.format(data))&lt;br /&gt;
            if data:&lt;br /&gt;
                print(&#039;sending data back to the client&#039;)&lt;br /&gt;
                connection.sendall(data)&lt;br /&gt;
            else:&lt;br /&gt;
                print(&#039;no data from&#039;, client_address)&lt;br /&gt;
                break&lt;br /&gt;
&lt;br /&gt;
    finally:&lt;br /&gt;
        # Clean up the connection&lt;br /&gt;
        connection.close()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You can connect with this echo server with the command &amp;lt;code&amp;gt;nc localhost 10000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Need for concurrency ==&lt;br /&gt;
&lt;br /&gt;
What happens if you try to open multiple connections to this socket server, and write a message?&lt;br /&gt;
&lt;br /&gt;
Does it respond with an echo?&lt;br /&gt;
&lt;br /&gt;
== Async ==&lt;br /&gt;
&lt;br /&gt;
python 3.4 adds a new library called asyncio which adds the ability to do ansychronous programming with python, using only the standard library. Asynchronous python, like javascript, has the ability to do something else when it is waiting.&lt;br /&gt;
&lt;br /&gt;
function with &amp;lt;code&amp;gt;async def&amp;lt;/code&amp;gt; are coroutines. actions which the async coroutine waits for are preceded with &amp;lt;code&amp;gt;await&amp;lt;/code&amp;gt; and are generators.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
Here is an example of doing things out of order, and sleeping without blocking: https://asyncio.readthedocs.io/en/latest/hello_clock.html&lt;br /&gt;
&lt;br /&gt;
Here is a tcp echo server: https://asyncio.readthedocs.io/en/latest/tcp_echo.html&lt;br /&gt;
&lt;br /&gt;
here is an example that will stay connected until the connection is closed by the client&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import asyncio&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
async def handle_echo(reader, writer):&lt;br /&gt;
    while True:&lt;br /&gt;
        data = await reader.read(100)&lt;br /&gt;
        message = data.decode()&lt;br /&gt;
        addr = writer.get_extra_info(&#039;peername&#039;)&lt;br /&gt;
        print(&amp;quot;Received %r from %r&amp;quot; % (message, addr))&lt;br /&gt;
        if len(message.strip()) == 0:&lt;br /&gt;
            print(&amp;quot;Close the client socket&amp;quot;)&lt;br /&gt;
            writer.close()&lt;br /&gt;
            break&lt;br /&gt;
        print(&amp;quot;Send: %r&amp;quot; % message)&lt;br /&gt;
        writer.write(data)&lt;br /&gt;
        await writer.drain()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
loop = asyncio.get_event_loop()&lt;br /&gt;
coro = asyncio.start_server(handle_echo, &#039;127.0.0.1&#039;, 8888, loop=loop)&lt;br /&gt;
server = loop.run_until_complete(coro)&lt;br /&gt;
&lt;br /&gt;
# Serve requests until Ctrl+C is pressed&lt;br /&gt;
print(&#039;Serving on {}&#039;.format(server.sockets[0].getsockname()))&lt;br /&gt;
try:&lt;br /&gt;
    loop.run_forever()&lt;br /&gt;
except KeyboardInterrupt:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
# Close the server&lt;br /&gt;
server.close()&lt;br /&gt;
loop.run_until_complete(server.wait_closed())&lt;br /&gt;
loop.close()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
What happens if you make multiple connections with this server?&lt;br /&gt;
&lt;br /&gt;
== Threads ==&lt;br /&gt;
&lt;br /&gt;
Threads can run concurrently, and they share the same memory.&lt;br /&gt;
&lt;br /&gt;
this will take about 1 second to run using threads. without threads it would take 100 seconds&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import threading&lt;br /&gt;
import time&lt;br /&gt;
threads = []&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def foo():&lt;br /&gt;
    time.sleep(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for i in range(100):&lt;br /&gt;
    t = threading.Thread(target=foo)&lt;br /&gt;
    threads.append(t)&lt;br /&gt;
&lt;br /&gt;
for t in threads:&lt;br /&gt;
    t.start()&lt;br /&gt;
&lt;br /&gt;
for t in threads:&lt;br /&gt;
    t.join()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Thread safety ===&lt;br /&gt;
&lt;br /&gt;
If you run this code with python 2, you will get different results each time you run it. It is not thread safe.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import threading&lt;br /&gt;
threads = []&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
n = 0&lt;br /&gt;
&lt;br /&gt;
def foo():&lt;br /&gt;
    global n&lt;br /&gt;
    n += 1&lt;br /&gt;
&lt;br /&gt;
for i in range(1000):&lt;br /&gt;
    t = threading.Thread(target=foo)&lt;br /&gt;
    threads.append(t)&lt;br /&gt;
&lt;br /&gt;
for t in threads:&lt;br /&gt;
    t.start()&lt;br /&gt;
&lt;br /&gt;
for t in threads:&lt;br /&gt;
    t.join()&lt;br /&gt;
&lt;br /&gt;
print(n)&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124578</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124578"/>
		<updated>2017-10-10T09:13:58Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/c55c42d4-ecbb-4a3a-8508-6c7d66577044/home&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/e8d9bf77-53ea-467a-b31b-7afc0352bd00/home &lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5 ===&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124577</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124577"/>
		<updated>2017-10-10T09:13:42Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/c55c42d4-ecbb-4a3a-8508-6c7d66577044/home&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/e8d9bf77-53ea-467a-b31b-7afc0352bd00/home &lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;br /&gt;
&lt;br /&gt;
=== Lecture 5&lt;br /&gt;
&lt;br /&gt;
Introduction to coroutines, event driven programming, streams&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture5&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture5&amp;diff=124576</id>
		<title>Advanced Python (Fall 2017)/lecture5</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture5&amp;diff=124576"/>
		<updated>2017-10-10T09:12:54Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= lecture 5 =  == piping stdout to stdin ==  you can send the outputs (stdout) of commands in shell to other commands, or write the to files  http://www.tldp.org/LDP/abs/html/...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= lecture 5 =&lt;br /&gt;
&lt;br /&gt;
== piping stdout to stdin ==&lt;br /&gt;
&lt;br /&gt;
you can send the outputs (stdout) of commands in shell to other commands, or write the to files&lt;br /&gt;
&lt;br /&gt;
http://www.tldp.org/LDP/abs/html/io-redirection.html&lt;br /&gt;
&lt;br /&gt;
To receive the output of a pipe into your python script, use &amp;lt;code&amp;gt;sys.stdin&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;sys.stdin&amp;lt;/code&amp;gt; is an iterable.&lt;br /&gt;
&lt;br /&gt;
To write to stdout, you can use &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sys.stdout.write&amp;lt;/code&amp;gt; -- which does not add the newline.&lt;br /&gt;
&lt;br /&gt;
To print all stdin to stdout in a python script, you could use.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import sys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def main()&lt;br /&gt;
    for line in sys.stdin:&lt;br /&gt;
        sys.stdout.write(line)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
main()&amp;lt;/source&amp;gt;&lt;br /&gt;
and to print out a file: &amp;lt;code&amp;gt;cat ./file.txt | python3 my_script.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To make an stream of a file that waits for new lines to be added, use the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;tail -f ./file.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and you can pipe this output to your python script.&lt;br /&gt;
&lt;br /&gt;
== Task 1: Make a basic grep ==&lt;br /&gt;
&lt;br /&gt;
something that can function as such &amp;lt;code&amp;gt;tail -f ./file.txt | grep $SEARCH_TERM&amp;lt;/code&amp;gt; where lines with the search term are written to stdout&lt;br /&gt;
&lt;br /&gt;
=== A Solution ===&lt;br /&gt;
&lt;br /&gt;
Normal function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import argparse&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def grep(term, line):&lt;br /&gt;
    if term in line:&lt;br /&gt;
        sys.stdout.write(line)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
&lt;br /&gt;
    parser = argparse.ArgumentParser()&lt;br /&gt;
    parser.add_argument(&#039;term&#039;)&lt;br /&gt;
    args = parser.parse_args()&lt;br /&gt;
    term = args.term&lt;br /&gt;
    for line in sys.stdin:&lt;br /&gt;
        grep(term, line)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    main()&amp;lt;/source&amp;gt;&lt;br /&gt;
== Event driven: Using a generator ==&lt;br /&gt;
&lt;br /&gt;
the function &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; is a generator. When the file object &amp;lt;code&amp;gt;sys.stdin&amp;lt;/code&amp;gt; yields another line, then the generator &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; yields another line. When &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; yeilds another line, then the &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop prints another line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import argparse&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def grep(term, lines):&lt;br /&gt;
    for line in lines:&lt;br /&gt;
        if term in line:&lt;br /&gt;
            print(&#039;grep executed&#039;)&lt;br /&gt;
            yield line&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
&lt;br /&gt;
    parser = argparse.ArgumentParser()&lt;br /&gt;
    parser.add_argument(&#039;term&#039;)&lt;br /&gt;
    args = parser.parse_args()&lt;br /&gt;
    term = args.term&lt;br /&gt;
    grep_lines = grep(term, sys.stdin)&lt;br /&gt;
    for line in grep_lines:&lt;br /&gt;
        print(&#039;print executed&#039;)&lt;br /&gt;
        sys.stdout.write(line)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    main()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Coroutine ==&lt;br /&gt;
&lt;br /&gt;
Please see this tutorial for a better and fuller explanation of coroutines. NOTE: this tutorial is written in Python 2 code. http://www.dabeaz.com/coroutines/&lt;br /&gt;
&lt;br /&gt;
Here is our grep written with a coroutine:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import argparse&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def grep(pattern):&lt;br /&gt;
    while True:&lt;br /&gt;
        line = (yield)&lt;br /&gt;
        if pattern in line:&lt;br /&gt;
            sys.stdout.write(line)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
&lt;br /&gt;
    parser = argparse.ArgumentParser()&lt;br /&gt;
    parser.add_argument(&#039;term&#039;)&lt;br /&gt;
    args = parser.parse_args()&lt;br /&gt;
    term = args.term&lt;br /&gt;
    g = grep(term)&lt;br /&gt;
    next(g)&lt;br /&gt;
    for line in sys.stdin:&lt;br /&gt;
        g.send(line)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    main()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124510</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124510"/>
		<updated>2017-10-03T09:40:23Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Add lecture videos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
=== Videos ===&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Wednesday 12:00-13:30 class is here:&lt;br /&gt;
https://echo360.org.uk/section/c55c42d4-ecbb-4a3a-8508-6c7d66577044/home&lt;br /&gt;
&lt;br /&gt;
The lecture videos for the Friday 16:15-19:20 class is here:&lt;br /&gt;
https://echo360.org.uk/section/e8d9bf77-53ea-467a-b31b-7afc0352bd00/home &lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124509</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124509"/>
		<updated>2017-10-03T09:38:43Z</updated>

		<summary type="html">&lt;p&gt;Eroman: add lecture 4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Lecture 4 === &lt;br /&gt;
&lt;br /&gt;
Functional Programming&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture4&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture4&amp;diff=124508</id>
		<title>Advanced Python (Fall 2017)/lecture4</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture4&amp;diff=124508"/>
		<updated>2017-10-03T09:35:44Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 4: Functional Programming =  See this for a more detailed document on functional programming in python https://docs.python.org/3/howto/functional.html  == Functions...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 4: Functional Programming =&lt;br /&gt;
&lt;br /&gt;
See this for a more detailed document on functional programming in python https://docs.python.org/3/howto/functional.html&lt;br /&gt;
&lt;br /&gt;
== Functions as first class objects ==&lt;br /&gt;
&lt;br /&gt;
function in python are first class objects.&lt;br /&gt;
&lt;br /&gt;
They can be assigned to variable, passed into other function as arguments, and be returned by a function.&lt;br /&gt;
&lt;br /&gt;
Python is not optimal for functional programming.&lt;br /&gt;
&lt;br /&gt;
Currying in python. And an equivalently functioning block of code written using a class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def my_function(name):&lt;br /&gt;
    def inside_function():&lt;br /&gt;
        print(&#039;hi {}&#039;.format(name))&lt;br /&gt;
    return inside_function&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
a1 = my_function(&#039;bob&#039;)&lt;br /&gt;
a2 = my_function(&#039;sally&#039;)&lt;br /&gt;
&lt;br /&gt;
a1()  # &#039;hi bob&#039;&lt;br /&gt;
a2()  # &#039;hi sally&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class MyClass():&lt;br /&gt;
    def __init__(self, name):&lt;br /&gt;
        self.name = name&lt;br /&gt;
&lt;br /&gt;
    def __call__(self):&lt;br /&gt;
        print(&#039;hi {}&#039;.format(self.name))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_instance = MyClass(&#039;Alex&#039;)&lt;br /&gt;
my_instance()  # &#039;hi Alex&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Decorators ==&lt;br /&gt;
&lt;br /&gt;
Here is a more detailed tutorial for decorators: https://www.python-course.eu/python3_decorators.php&lt;br /&gt;
&lt;br /&gt;
decorators can wrap a function and make the function do something different, or use the function in a different context. You most likely will not have to write your own decorators in your scripts and applications. But you may likely use one from a library.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def my_decorator(f):&lt;br /&gt;
    def wrapped():&lt;br /&gt;
        print(&#039;Decorator Engaged!&#039;)&lt;br /&gt;
        f()&lt;br /&gt;
    return wrapped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@my_decorator&lt;br /&gt;
def decorated_hello_world():&lt;br /&gt;
    print(&#039;hello world&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
hello_world()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Lambda ==&lt;br /&gt;
&lt;br /&gt;
Lambdas are similar to functions. Here are two equivalent lines of code. Lambdas should not have side effects. They should be anonymous, meaning that they do should not be assigned to a name. They should be used as an argument to a function call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# Do not name a lambda. Define a function instead.&lt;br /&gt;
my_lambda = lambda x, y: x + y&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def my_function(x, y):&lt;br /&gt;
    return x + y&amp;lt;/source&amp;gt;&lt;br /&gt;
== Using Lambdas, map, comprehensions ==&lt;br /&gt;
&lt;br /&gt;
see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124353</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124353"/>
		<updated>2017-09-24T20:20:06Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;br /&gt;
&lt;br /&gt;
=== Lecture 3 ===&lt;br /&gt;
&lt;br /&gt;
Scope within classes, `while`, and generators.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture3&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture3&amp;diff=124352</id>
		<title>Advanced Python (Fall 2017)/lecture3</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture3&amp;diff=124352"/>
		<updated>2017-09-24T20:19:50Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 3 =  == More scope (classes) ==  NB! Even though classes in python work as a namespace with their own scope, you should use modules (i.e .py files) instead of classe...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 3 =&lt;br /&gt;
&lt;br /&gt;
== More scope (classes) ==&lt;br /&gt;
&lt;br /&gt;
NB! Even though classes in python work as a namespace with their own scope, you should use modules (i.e .py files) instead of classes for this purpose.&lt;br /&gt;
&lt;br /&gt;
Classes in python create their own scope. Symbols defined outside the class are available from inside the class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;MY_CONSTANT = &#039;constant outside of the class&#039;&lt;br /&gt;
&lt;br /&gt;
class MyClass():&lt;br /&gt;
    print(MY_CONSTANT)&lt;br /&gt;
    print(&#039;lines in my_class are executed&#039;)&lt;br /&gt;
&lt;br /&gt;
    def my_function():&lt;br /&gt;
        print(&#039;my_function called&#039;)&lt;br /&gt;
&lt;br /&gt;
    my_function()&amp;lt;/source&amp;gt;&lt;br /&gt;
this prints&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;constant outside of the class&lt;br /&gt;
lines in my_class are executed&lt;br /&gt;
my_function called&amp;lt;/pre&amp;gt;&lt;br /&gt;
NB! Even though classes in python work as a namespace with their own scope, you should use modules (i.e .py files) instead of classes for this purpose.&lt;br /&gt;
&lt;br /&gt;
Symbols defined in the class are available outside the class using the class name as a namespace&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;class A:&lt;br /&gt;
    my_variable = &#039;hi&#039;&lt;br /&gt;
&lt;br /&gt;
    def my_function():&lt;br /&gt;
        print(&#039;my_function called&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
print(A.my_variable)&lt;br /&gt;
A.my_function()&amp;lt;/source&amp;gt;&lt;br /&gt;
NB! Even though classes in python work as a namespace with their own scope, you should use modules (i.e .py files) instead of classes for this purpose.&lt;br /&gt;
&lt;br /&gt;
Classes in python should be used as a constructor for objects. like in this example. An object is created when the class is called.&lt;br /&gt;
&lt;br /&gt;
methods in a class take a first argument called &#039;self&#039;. This argument is added implicitly when the method is called, but needs to be added explicitly when the method is defined. &#039;self&#039; refers to the instance (i.e the new object created when the class is called). See: https://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;class MyClass():&lt;br /&gt;
    A = &#039;class variable&#039;&lt;br /&gt;
&lt;br /&gt;
    def __init__(self, c):&lt;br /&gt;
        self.c = c  # instance variable&lt;br /&gt;
&lt;br /&gt;
    def my_method(self):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        methods can only be called on the instance of the class.&lt;br /&gt;
        So this will work:&lt;br /&gt;
        `MyClass(4).my_method()  # prints 4`&lt;br /&gt;
        But this will not work:&lt;br /&gt;
        `MyClass.my_method()  # raises Error`&lt;br /&gt;
&lt;br /&gt;
        self refers to the instance. The instance has the attributes of the class including:&lt;br /&gt;
&lt;br /&gt;
        - class variables (i.e `self.A`)&lt;br /&gt;
        - class methods  (i.e. `self.my_class_method()`)&lt;br /&gt;
        - static methods (i.e. `self.my_static_method()`)&lt;br /&gt;
&lt;br /&gt;
        and self also has attributes of the instance including:&lt;br /&gt;
&lt;br /&gt;
        instance variables (i.e. `self.c`)&lt;br /&gt;
        instanct methods (i.e. `self.my_method`)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        print(self.c)&lt;br /&gt;
&lt;br /&gt;
    @classmethod&lt;br /&gt;
    def my_class_method(cls):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        cls refers to the class. It has attributes of the class, including:&lt;br /&gt;
        - class variables (i.e `self.A`)&lt;br /&gt;
        - class methods  (i.e. `self.my_class_method()`)&lt;br /&gt;
        - static methods (i.e. `self.my_static_method()`)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        print(cls.A)&lt;br /&gt;
&lt;br /&gt;
    @staticmethod&lt;br /&gt;
    def my_static_method():&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        static methods work like a regular function that is not in a class.&lt;br /&gt;
        They do not have access to variables and methods in the class or the instance.&lt;br /&gt;
        They are only in the class for organizational reasons, and may be better&lt;br /&gt;
        outside the class.&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        print(&#039;static method called&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
print(MyClass.A)  # prints &#039;class variable&#039;&lt;br /&gt;
MyClass.my_class_method()  # prints &#039;class variable&#039;&lt;br /&gt;
MyClass.my_static_method()  # prints &#039;static method called&#039;&lt;br /&gt;
&lt;br /&gt;
my_instance = MyClass(&#039;my instance variable&#039;)&lt;br /&gt;
my_instance.my_class_method()  # prints &#039;class variable&#039;&lt;br /&gt;
print(my_instance.c)  # prints &#039;my instance variable&#039;&lt;br /&gt;
my_instance.my_method()  # prints &#039;my instance variable&#039;&lt;br /&gt;
my_instance.my_static_method()  # prints &#039;static method called&#039;&amp;lt;/source&amp;gt;&lt;br /&gt;
== Generators ==&lt;br /&gt;
&lt;br /&gt;
First we must learn about while loops. For iterating and counting, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; is superior. They are simple and usually only used in the following way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;while True:&lt;br /&gt;
    do_something()&lt;br /&gt;
    if some_condition:&lt;br /&gt;
        break&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Task 1 ===&lt;br /&gt;
&lt;br /&gt;
NOTE: you most likely will not need to write generators in your python code. iterate through a list using a while and print every element&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
You should use a `for` loop instead in real world situations.&lt;br /&gt;
This is just for teaching about `while`&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
MY_NAMES = [&#039;hi&#039;, &#039;bye&#039;, &#039;peep&#039;]&lt;br /&gt;
&lt;br /&gt;
for i in MY_NAMES:&lt;br /&gt;
    print(i)&lt;br /&gt;
&lt;br /&gt;
i = 0&lt;br /&gt;
while i &amp;lt; len(MY_NAMES):&lt;br /&gt;
    print(MY_NAMES[i])&lt;br /&gt;
    i += 1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A generator is a special object in python that can be iterated over, but each item in the iteration is generated lazily. That means it does not know the next element until it has been evaluated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; is similar to return, as in the value yielded is used the next item in the generator. But &amp;lt;code&amp;gt;yield&amp;lt;/code&amp;gt; does not stop the execution of the function.&lt;br /&gt;
&lt;br /&gt;
Here are some examples:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def my_generator_1():&lt;br /&gt;
    yield 1&lt;br /&gt;
    yield 2&lt;br /&gt;
    yield 3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
for i in my_generator_1():&lt;br /&gt;
    print(i)&lt;br /&gt;
&lt;br /&gt;
# 1&lt;br /&gt;
# 2&lt;br /&gt;
# 3&lt;br /&gt;
&lt;br /&gt;
print(list(my_generator_1()))&lt;br /&gt;
# [1, 2, 3]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def my_generator_2():&lt;br /&gt;
    for i in range(10, 0, -1):&lt;br /&gt;
        yield i&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
print(list(my_generator_2()))&lt;br /&gt;
# [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Task 2 ===&lt;br /&gt;
&lt;br /&gt;
implement a range-like function using a generator&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def my_function(first, second=None, third=1):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    NOTE: this implementation of range fails on negative step values&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    if second:&lt;br /&gt;
        stop = second&lt;br /&gt;
        start = first&lt;br /&gt;
    else:&lt;br /&gt;
        stop = first&lt;br /&gt;
        start = 0&lt;br /&gt;
    step = third&lt;br /&gt;
    i = start&lt;br /&gt;
    while i &amp;lt; stop:&lt;br /&gt;
        yield i&lt;br /&gt;
        i += step&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124199</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124199"/>
		<updated>2017-09-16T17:04:55Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;br /&gt;
&lt;br /&gt;
=== Lecture 2 ===&lt;br /&gt;
&lt;br /&gt;
Scoping and python packaging basics.&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture2&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture2&amp;diff=124198</id>
		<title>Advanced Python (Fall 2017)/lecture2</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture2&amp;diff=124198"/>
		<updated>2017-09-16T17:04:20Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 2 =  == Scope and style ==  Python scope is similar to other programming language and does not have many suprises. Basic scoping rules can be found here: https://en....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 2 =&lt;br /&gt;
&lt;br /&gt;
== Scope and style ==&lt;br /&gt;
&lt;br /&gt;
Python scope is similar to other programming language and does not have many suprises. Basic scoping rules can be found here: https://en.wikipedia.org/wiki/Scope_(computer_science)#Python&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;my_variable = 1  # in the global scope&lt;br /&gt;
&lt;br /&gt;
def my_function():&lt;br /&gt;
    print(my_variable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_function()  # prints 1&lt;br /&gt;
print(my_variable)  # prints 1&amp;lt;/source&amp;gt;&lt;br /&gt;
variables in the global scope are accessible in the local scope of a function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def my_function():&lt;br /&gt;
    my_variable = 2  # in the function scope&lt;br /&gt;
    print(my_variable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_function()  # prints 2&lt;br /&gt;
print(my_variable)  # raises NameError&amp;lt;/source&amp;gt;&lt;br /&gt;
variables defined in the local scope of a function are not available outside the function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;my_variable = 1  # in the global scope&lt;br /&gt;
&lt;br /&gt;
def my_function():&lt;br /&gt;
    my_variable = 2  # in the function scope&lt;br /&gt;
    print(my_variable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_function()  # prints 2&lt;br /&gt;
print(my_variable)  # prints 1&amp;lt;/source&amp;gt;&lt;br /&gt;
functions have there own scope and assignment statement in variables (i.e. &amp;lt;code&amp;gt;my_variable = 2&amp;lt;/code&amp;gt; creates a new variable rather than using a variable in the global scope.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;my_variable = 1  # in the global scope&lt;br /&gt;
&lt;br /&gt;
def my_function():&lt;br /&gt;
    global my_variable&lt;br /&gt;
    my_variable = 2  # in the function scope&lt;br /&gt;
    print(my_variable)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_function()  # prints 2&lt;br /&gt;
print(my_variable)  # prints 1&amp;lt;/source&amp;gt;&lt;br /&gt;
To modify a variable in the global scope from inside a function, you can use the &amp;lt;code&amp;gt;global&amp;lt;/code&amp;gt; keyword. NB! Modifying global variables if bad practice and should not be done in an application you write!&lt;br /&gt;
&lt;br /&gt;
=== Task 1 ===&lt;br /&gt;
&lt;br /&gt;
Replace the use of global with something better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;x = 0&lt;br /&gt;
&lt;br /&gt;
def add_1():&lt;br /&gt;
    global x&lt;br /&gt;
    x += 1&lt;br /&gt;
&lt;br /&gt;
add_1()&lt;br /&gt;
add_1()&lt;br /&gt;
add_1()&lt;br /&gt;
&lt;br /&gt;
print(x)  # prints 3&amp;lt;/source&amp;gt;&lt;br /&gt;
possible solution&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;class MyCounter:&lt;br /&gt;
    def __init__(self, x):&lt;br /&gt;
        self.x = x&lt;br /&gt;
&lt;br /&gt;
    def add_1(self):&lt;br /&gt;
        self.x += 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_counter = MyCounter(0)&lt;br /&gt;
my_counter.add_1()&lt;br /&gt;
my_counter.add_1()&lt;br /&gt;
my_counter.add_1()&lt;br /&gt;
print(my_counter.x)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Python Packaging (Part 1) ==&lt;br /&gt;
&lt;br /&gt;
We will do another lesson on this.&lt;br /&gt;
&lt;br /&gt;
=== Step 1 make a git repository ===&lt;br /&gt;
&lt;br /&gt;
This is not required to make a python package. You can make a python package without &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt;, but we will use &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; in this example.&lt;br /&gt;
&lt;br /&gt;
In github, make a repositiory and clone the empty repository. Make sure there is a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; with appropriate rules for python.&lt;br /&gt;
&lt;br /&gt;
=== Step 2 add some necessary files ===&lt;br /&gt;
&lt;br /&gt;
To make a python package, you need a python module and a file called &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; can start with this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from distutils.core import setup&lt;br /&gt;
&lt;br /&gt;
setup()&amp;lt;/source&amp;gt;&lt;br /&gt;
the function &amp;lt;code&amp;gt;setup&amp;lt;/code&amp;gt; then takes keyword arguments that describe our project.&lt;br /&gt;
&lt;br /&gt;
Now make a python module. I will use a module called &amp;lt;code&amp;gt;example&amp;lt;/code&amp;gt;. So I will make a directory called &amp;lt;code&amp;gt;example&amp;lt;/code&amp;gt; and put an empty file called &amp;lt;code&amp;gt;__init__.py&amp;lt;/code&amp;gt; in the directory &amp;lt;code&amp;gt;example&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to make a file that will execute when we call this package from the command line, then create a file called &amp;lt;code&amp;gt;__main__.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== step 3 add some code ===&lt;br /&gt;
&lt;br /&gt;
you can add these keyword arguments to &amp;lt;code&amp;gt;setup&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from distutils.core import setup&lt;br /&gt;
&lt;br /&gt;
setup(&lt;br /&gt;
    name=&#039;firstpackage&#039;,&lt;br /&gt;
    version=&#039;0.1&#039;,&lt;br /&gt;
    packages=[&#039;example&#039;],&lt;br /&gt;
)&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;packages&amp;lt;/code&amp;gt; should have the name of your python module in it.&lt;br /&gt;
&lt;br /&gt;
add something to execute in &amp;lt;code&amp;gt;__main__.py&amp;lt;/code&amp;gt; like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;print(&#039;Hi from my first package&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Using your new python package ===&lt;br /&gt;
&lt;br /&gt;
You can build it with &amp;lt;code&amp;gt;python setup.py sdist&amp;lt;/code&amp;gt;. This will create an archive in a newly created &amp;lt;code&amp;gt;dist&amp;lt;/code&amp;gt; directory you can install it with &amp;lt;code&amp;gt;pip install dist/firstpackage-0.1.tar.gz&amp;lt;/code&amp;gt; and you can run it with &amp;lt;code&amp;gt;python -m example&amp;lt;/code&amp;gt;. now you will see &#039;Hi from my first package&#039; printed in the terminal!&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124088</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124088"/>
		<updated>2017-09-08T20:24:33Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What should I know already? ===&lt;br /&gt;
&lt;br /&gt;
* How to use the unix shell&lt;br /&gt;
* How to install a package with pip&lt;br /&gt;
* Write and use pythons functions&lt;br /&gt;
* Use lists, strings, dictionaries, and integers with python&lt;br /&gt;
* know the syntax of a python class&lt;br /&gt;
&lt;br /&gt;
you should be able to pass these tests: https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python#Practice_Test&lt;br /&gt;
&lt;br /&gt;
=== What should I write python with? ===&lt;br /&gt;
&lt;br /&gt;
whatever you want!&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know what to use, check the following - &amp;lt;code&amp;gt;Spyder&amp;lt;/code&amp;gt; a lightweight python IDE. Very basic, but works out of the box and is quick to learn. Use this if you want to start with something easy. - &amp;lt;code&amp;gt;Vim&amp;lt;/code&amp;gt; popular and useful text editor. Hard to learn, but widely used and very effecient once learned. To start using with python, consider using https://github.com/amix/vimrc - &amp;lt;code&amp;gt;Emacs&amp;lt;/code&amp;gt; a text editor and more. Hard to learn, but once learned is very effecient and useful. - &amp;lt;code&amp;gt;Visual Studio Code&amp;lt;/code&amp;gt; an editor with IDE features from microsoft. It is very new and becoming more and more popular. It is not open source. - &amp;lt;code&amp;gt;PyCharm&amp;lt;/code&amp;gt; the most popular python IDE. It is not open source.&lt;br /&gt;
&lt;br /&gt;
=== What python version are we using? ===&lt;br /&gt;
&lt;br /&gt;
Both 2 and 3. Our code should work on both versions.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
The class is pass/faile, and passing will depend on a final project.&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
&lt;br /&gt;
* Proper version control. Small commits, with relevant commit messages.&lt;br /&gt;
* It has a relevant unit test&lt;br /&gt;
* It uses an automated test runner&lt;br /&gt;
* It runs on python 2 and 3&lt;br /&gt;
* It is in the form of a python package&lt;br /&gt;
* It has a robust README&lt;br /&gt;
* I must approve the project idea&lt;br /&gt;
&lt;br /&gt;
=== Deadlines ===&lt;br /&gt;
&lt;br /&gt;
A project idea must be picked by the middle class (8th class). I will approve the project idea or suggest improvements to the idea. If you do not submit your idea, then one will be given to you. You may change your project idea with my approval.&lt;br /&gt;
&lt;br /&gt;
The project deadline with be determined.&lt;br /&gt;
&lt;br /&gt;
== Lecture Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Lecture 1 ===&lt;br /&gt;
&lt;br /&gt;
Python 2 and 3 code. PEP 8.&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)/lecture1&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture1&amp;diff=124087</id>
		<title>Advanced Python (Fall 2017)/lecture1</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)/lecture1&amp;diff=124087"/>
		<updated>2017-09-08T20:23:29Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 1 =  == When to use what python version ==  Use python 3 if you:  are starting a new project, that you know will only be used internally, or used once, or used by pe...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 1 =&lt;br /&gt;
&lt;br /&gt;
== When to use what python version ==&lt;br /&gt;
&lt;br /&gt;
Use python 3 if you:&lt;br /&gt;
&lt;br /&gt;
are starting a new project, that you know will only be used internally, or used once, or used by people you know will use python 3.&lt;br /&gt;
&lt;br /&gt;
When to python 2:&lt;br /&gt;
&lt;br /&gt;
you are using an existing python 2 code base. or there is a python2 only package and there are no alternatives.&lt;br /&gt;
&lt;br /&gt;
When to write code that will work on both python 2 and 3:&lt;br /&gt;
&lt;br /&gt;
You are making a public package that may be used by people using either version. Or you are adding to a python2 project, and you want it to be forward compatible.&lt;br /&gt;
&lt;br /&gt;
I recommend that you write python 3 code or write code that is compatible with both versions.&lt;br /&gt;
&lt;br /&gt;
== Python 2 and 3 differences ==&lt;br /&gt;
&lt;br /&gt;
There are many small differences between python 2 and python 3. here is a comprhensive list: http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
&lt;br /&gt;
In python 3, all strings are unicode. python 2 strings are not any specific encoding. They are actually a list of bytes.&lt;br /&gt;
&lt;br /&gt;
This can cause problems when you try to use special characters. the following code will not work on python 2, but will work on python 3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;Hello {}&amp;quot;.format(u&amp;quot;Kõrvits&amp;quot;)&amp;lt;/source&amp;gt;&lt;br /&gt;
on python 2, you will get this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;In [1]: &amp;amp;quot;Hello {}&amp;amp;quot;.format(u&amp;amp;quot;Kõrvits&amp;amp;quot;)&lt;br /&gt;
---------------------------------------------------------------------------&lt;br /&gt;
UnicodeEncodeError                        Traceback (most recent call last)&lt;br /&gt;
&amp;amp;lt;ipython-input-1-462f402d17a8&amp;amp;gt; in &amp;amp;lt;module&amp;amp;gt;()&lt;br /&gt;
----&amp;amp;gt; 1 &amp;amp;quot;Hello {}&amp;amp;quot;.format(u&amp;amp;quot;Kõrvits&amp;amp;quot;)&lt;br /&gt;
&lt;br /&gt;
UnicodeEncodeError: &#039;ascii&#039; codec can&#039;t encode character u&#039;\xf5&#039; in position 1: ordinal not in range(128)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To make a string explicitly unicode typed, put a &#039;u&#039; before a string literal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;u&#039;hi&#039;&amp;lt;/pre&amp;gt;&lt;br /&gt;
or import&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;from __future__ import unicode_literals&amp;lt;/pre&amp;gt;&lt;br /&gt;
which will make all string literals unicode.&lt;br /&gt;
&lt;br /&gt;
== Python Style ==&lt;br /&gt;
&lt;br /&gt;
python has a very strict and standarized and widely style guide. It is referred to as &amp;amp;quot;PEP8&amp;amp;quot;. PEP is the Python Enhancement Project, and 8 is the number of the proposal. This proposal, PEP8, contains the style rules for python code. Read it here: https://www.python.org/dev/peps/pep-0008/&lt;br /&gt;
&lt;br /&gt;
it should be followed.&lt;br /&gt;
&lt;br /&gt;
=== Checking the style guide ===&lt;br /&gt;
&lt;br /&gt;
use a package called &#039;flake8&#039;. It is quite sensible out of the box. It does not check naming, or all style rules. It checks spacing and syntax.&lt;br /&gt;
&lt;br /&gt;
to install &#039;pip install flake8&#039;&lt;br /&gt;
&lt;br /&gt;
to run &#039;python -m flake8 PATH&#039;&lt;br /&gt;
&lt;br /&gt;
You may also use &#039;PyLint&#039;, which is much more robust and checks more things, including naming and documentation. It has to be configured because it is often too strict.&lt;br /&gt;
&lt;br /&gt;
There is also &#039;autopep8&#039;, which reformats your code to follow PEP8. ## Task 1&lt;br /&gt;
&lt;br /&gt;
Make bad legacy python code styled correctly and run on both python 2 and 3&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# coding: utf-8&lt;br /&gt;
&lt;br /&gt;
nAMES = [u&#039;Võsandi&#039;,u&#039;hyvä&#039;];&lt;br /&gt;
for Name in nAMES:&lt;br /&gt;
    if &#039;y&#039; in Name:&lt;br /&gt;
        print(&#039;{} is Finnish&#039;.format(Name));&lt;br /&gt;
    else:&lt;br /&gt;
        print(&#039;{} is Estonian&#039;.format(Name));&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# coding: utf-8&lt;br /&gt;
&lt;br /&gt;
from __future__ import unicode_literals&lt;br /&gt;
from __future__ import print_function&lt;br /&gt;
NAMES = [&#039;Võsandi&#039;, &#039;hyvä&#039;]&lt;br /&gt;
&lt;br /&gt;
for name in NAMES:&lt;br /&gt;
    if &#039;y&#039; in name:&lt;br /&gt;
        print(&#039;{} is Finnish&#039;.format(name))&lt;br /&gt;
    else:&lt;br /&gt;
        print(&#039;{} is Estonian&#039;.format(name))&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=English&amp;diff=124005</id>
		<title>English</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=English&amp;diff=124005"/>
		<updated>2017-09-06T08:57:24Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
Welcome to Estonian IT College wikis English version.&lt;br /&gt;
&lt;br /&gt;
Our official web page&lt;br /&gt;
&lt;br /&gt;
==Courses==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I253_Presessional_Informatics Presessional course in Informatics]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics Introduction to Computers and Informatics]&lt;br /&gt;
** [[Exam help]]&lt;br /&gt;
* [[Logic and Discrete Mathematics Exam Help]]&lt;br /&gt;
* [[Operating systems]]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I704_Ruby I704 Ruby (Spring 2017)]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python I719 Fundamentals of Python (Spring 2017)]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I703_Python Python]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I702_Web_Application_Programming Web Application Programming]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I802_Firewalls_and_VPN_IPSec Firewalls and VPN/IPSec]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:Ideas Ideas for research project or thesis]&lt;br /&gt;
* [[I803 IT Infrastructure services]]&lt;br /&gt;
* [[Basics of C/C++ Programming]]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017) Advanced Python (Fall 2017)]&lt;br /&gt;
2nd year Spring semester&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I804_Linux_Windows_administration Linux/Windows administration]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I805_Authentication_and_Authorization Authentication and Authorization]&lt;br /&gt;
* [[C21 Incident response]]&lt;br /&gt;
&lt;br /&gt;
3rd year&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.itcollege.ee/index.php/Category:ICS0023_Robotics Robotics course]&lt;br /&gt;
&lt;br /&gt;
Misc&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:Lecturer_FAQ Lecturer FAQ]&lt;br /&gt;
&lt;br /&gt;
==Quickstart==&lt;br /&gt;
&lt;br /&gt;
This section is for freshmen who want to get up to speed with latest open-source technology.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/User:Akerge CSE survival guide]&lt;br /&gt;
* [[Getting started with Ubuntu]]&lt;br /&gt;
* [[Getting started with Raspberry Pi]]&lt;br /&gt;
* [[Accessing a virtual machine via SSH connection]]&lt;br /&gt;
* [[Setting up SSH access to enos.itcollege.ee]]&lt;br /&gt;
* [[Getting started with GCC]]&lt;br /&gt;
&lt;br /&gt;
==International Projects==&lt;br /&gt;
&lt;br /&gt;
* [[Deploying IT Infrastructure Solutions| Erasmus intensive program &amp;quot;Deploying IT Infrastructure Solutions&amp;quot;]]&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=English&amp;diff=124004</id>
		<title>English</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=English&amp;diff=124004"/>
		<updated>2017-09-06T08:56:59Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
&lt;br /&gt;
Welcome to Estonian IT College wikis English version.&lt;br /&gt;
&lt;br /&gt;
Our official web page&lt;br /&gt;
&lt;br /&gt;
==Courses==&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I253_Presessional_Informatics Presessional course in Informatics]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I600_Introduction_to_Computers_and_Informatics Introduction to Computers and Informatics]&lt;br /&gt;
** [[Exam help]]&lt;br /&gt;
* [[Logic and Discrete Mathematics Exam Help]]&lt;br /&gt;
* [[Operating systems]]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I704_Ruby I704 Ruby (Spring 2017)]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python I719 Fundamentals of Python (Spring 2017)]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I703_Python Python]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I702_Web_Application_Programming Web Application Programming]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I802_Firewalls_and_VPN_IPSec Firewalls and VPN/IPSec]&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:Ideas Ideas for research project or thesis]&lt;br /&gt;
* [[I803 IT Infrastructure services]]&lt;br /&gt;
* [[Basics of C/C++ Programming]]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Advanced_Python_(Fall_2017)]&lt;br /&gt;
2nd year Spring semester&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I804_Linux_Windows_administration Linux/Windows administration]&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:I805_Authentication_and_Authorization Authentication and Authorization]&lt;br /&gt;
* [[C21 Incident response]]&lt;br /&gt;
&lt;br /&gt;
3rd year&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.itcollege.ee/index.php/Category:ICS0023_Robotics Robotics course]&lt;br /&gt;
&lt;br /&gt;
Misc&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/Category:Lecturer_FAQ Lecturer FAQ]&lt;br /&gt;
&lt;br /&gt;
==Quickstart==&lt;br /&gt;
&lt;br /&gt;
This section is for freshmen who want to get up to speed with latest open-source technology.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.itcollege.ee/index.php/User:Akerge CSE survival guide]&lt;br /&gt;
* [[Getting started with Ubuntu]]&lt;br /&gt;
* [[Getting started with Raspberry Pi]]&lt;br /&gt;
* [[Accessing a virtual machine via SSH connection]]&lt;br /&gt;
* [[Setting up SSH access to enos.itcollege.ee]]&lt;br /&gt;
* [[Getting started with GCC]]&lt;br /&gt;
&lt;br /&gt;
==International Projects==&lt;br /&gt;
&lt;br /&gt;
* [[Deploying IT Infrastructure Solutions| Erasmus intensive program &amp;quot;Deploying IT Infrastructure Solutions&amp;quot;]]&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124003</id>
		<title>Advanced Python (Fall 2017)</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Advanced_Python_(Fall_2017)&amp;diff=124003"/>
		<updated>2017-09-06T08:46:58Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Advanced Python =  https://goo.gl/forms/Krqx2veYYqYEupXk2&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced Python =&lt;br /&gt;
&lt;br /&gt;
https://goo.gl/forms/Krqx2veYYqYEupXk2&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123228</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123228"/>
		<updated>2017-06-07T09:01:51Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: 07.06.2017 12:00-13:30 410&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* builtin functions like `len` and `range`&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/3f0f4e8289af6230000cfbfeefed5826&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 01/06/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4bd7d28bceeb0ef939b5d6392b1e50ab&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 07/06/17 === &lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/b16e644fbd31ff1dabbd89c5dc281ee6&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
Interpreting test results&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/test_results&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123195</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123195"/>
		<updated>2017-06-06T09:28:10Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: 07.06.2017 12:00-13:30 410&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* builtin functions like `len` and `range`&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/3f0f4e8289af6230000cfbfeefed5826&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 01/06/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4bd7d28bceeb0ef939b5d6392b1e50ab&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
Interpreting test results&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/test_results&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/test_results&amp;diff=123194</id>
		<title>I719 Fundamentals of Python/test results</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/test_results&amp;diff=123194"/>
		<updated>2017-06-06T09:26:25Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Test Result Output =  == Example Code ==  &amp;lt;code&amp;gt;app.py&amp;lt;/code&amp;gt;  &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def get_hello_world_1():     return &amp;quot;Hello World!&amp;quot;   def get_hello_world_2():     &amp;quot;&amp;quot;&amp;quot;Ret...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Test Result Output =&lt;br /&gt;
&lt;br /&gt;
== Example Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def get_hello_world_1():&lt;br /&gt;
    return &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def get_hello_world_2():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Returns wrong text&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return &amp;quot;Wrong Text.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def get_hello_world_3():&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;Will raise an error when run&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    return hello_world&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;test_app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import app&lt;br /&gt;
import unittest&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class HelloWorld1TestCase(unittest.TestCase):&lt;br /&gt;
    def test_value(self):&lt;br /&gt;
        result = app.get_hello_world_1()&lt;br /&gt;
        self.assertEqual(&amp;quot;Hello World!&amp;quot;, result)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class HelloWorld2TestCase(unittest.TestCase):&lt;br /&gt;
    def test_value(self):&lt;br /&gt;
        result = app.get_hello_world_2()&lt;br /&gt;
        self.assertEqual(&amp;quot;Hello World!&amp;quot;, result)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class HelloWorld3TestCase(unittest.TestCase):&lt;br /&gt;
    def test_value(self):&lt;br /&gt;
        result = app.get_hello_world_3()&lt;br /&gt;
        self.assertEqual(&amp;quot;Hello World!&amp;quot;, result)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;.FE&lt;br /&gt;
======================================================================&lt;br /&gt;
ERROR: test_value (test_app.HelloWorld3TestCase)&lt;br /&gt;
----------------------------------------------------------------------&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;amp;quot;/tmp/test_app.py&amp;amp;quot;, line 19, in test_value&lt;br /&gt;
    result = app.get_hello_world_3()&lt;br /&gt;
  File &amp;amp;quot;/tmp/app.py&amp;amp;quot;, line 12, in get_hello_world_3&lt;br /&gt;
    return hello_world&lt;br /&gt;
NameError: name &#039;hello_world&#039; is not defined&lt;br /&gt;
&lt;br /&gt;
======================================================================&lt;br /&gt;
FAIL: test_value (test_app.HelloWorld2TestCase)&lt;br /&gt;
----------------------------------------------------------------------&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;amp;quot;/tmp/test_app.py&amp;amp;quot;, line 14, in test_value&lt;br /&gt;
    self.assertEqual(&amp;amp;quot;Hello World!&amp;amp;quot;, result)&lt;br /&gt;
AssertionError: &#039;Hello World!&#039; != &#039;Wrong Text.&#039;&lt;br /&gt;
- Hello World!&lt;br /&gt;
+ Wrong Text.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------&lt;br /&gt;
Ran 3 tests in 0.001s&lt;br /&gt;
&lt;br /&gt;
FAILED (failures=1, errors=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; is a passing test&lt;br /&gt;
* &amp;lt;code&amp;gt;F&amp;lt;/code&amp;gt; is a failure&lt;br /&gt;
* &amp;lt;code&amp;gt;E&amp;lt;/code&amp;gt; is an error&lt;br /&gt;
&lt;br /&gt;
NOTE: The test results do not appear in a consistent order.&lt;br /&gt;
&lt;br /&gt;
=== Passing Test ===&lt;br /&gt;
&lt;br /&gt;
Since the assertion -- &amp;lt;code&amp;gt;assertEqual&amp;lt;/code&amp;gt; -- is called with &#039;Hello World!&#039; and &#039;Hello World!&#039;, no error is raised.&lt;br /&gt;
&lt;br /&gt;
=== Failing Test ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;FAIL: test_value (test_app.HelloWorld2TestCase)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;FAIL&amp;lt;/code&amp;gt;, means the test failed&lt;br /&gt;
* &amp;lt;code&amp;gt;test_value&amp;lt;/code&amp;gt; is the name of the method in the TestCase&lt;br /&gt;
* &amp;lt;code&amp;gt;test_app.HelloWorld2TestCase&amp;lt;/code&amp;gt; is the python path to the TestCase&lt;br /&gt;
&lt;br /&gt;
The assertion -- &amp;lt;code&amp;gt;assertEqual&amp;lt;/code&amp;gt; -- is called with &#039;Hello World!&#039; and &#039;Wrong Text.&#039;. These two strings are not equal, so &amp;lt;code&amp;gt;assertEqual&amp;lt;/code&amp;gt; raises an &amp;lt;code&amp;gt;AssertionError&amp;lt;/code&amp;gt;. When an &amp;lt;code&amp;gt;AssertionError&amp;lt;/code&amp;gt; is raised, the test fails.&lt;br /&gt;
&lt;br /&gt;
You will see in the &amp;lt;code&amp;gt;FAIL&amp;lt;/code&amp;gt; test result the values used. This is helpful to figure out what went wrong.&lt;br /&gt;
&lt;br /&gt;
=== Error ===&lt;br /&gt;
&lt;br /&gt;
The function -- &amp;lt;code&amp;gt;get_hello_world_3&amp;lt;/code&amp;gt; raises a &amp;lt;code&amp;gt;NameError&amp;lt;/code&amp;gt;, since the name &#039;hello_world&#039; is not defined. When an error is raised, and the error is NOT an &amp;lt;code&amp;gt;AssertionError&amp;lt;/code&amp;gt;, then the test result is a special failure called an &amp;amp;quot;error&amp;amp;quot;.&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123131</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123131"/>
		<updated>2017-06-02T09:10:09Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Test dates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: 07.06.2017 12:00-13:30 410&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* builtin functions like `len` and `range`&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/3f0f4e8289af6230000cfbfeefed5826&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 01/06/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4bd7d28bceeb0ef939b5d6392b1e50ab&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123038</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123038"/>
		<updated>2017-06-01T06:59:51Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* builtin functions like `len` and `range`&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/3f0f4e8289af6230000cfbfeefed5826&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 01/06/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4bd7d28bceeb0ef939b5d6392b1e50ab&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123028</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123028"/>
		<updated>2017-05-30T20:32:39Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Test topics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* builtin functions like `len` and `range`&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/3f0f4e8289af6230000cfbfeefed5826&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123027</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123027"/>
		<updated>2017-05-30T20:31:14Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Real Test for 23/03/17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/3f0f4e8289af6230000cfbfeefed5826&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123026</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=123026"/>
		<updated>2017-05-30T20:29:56Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Real Test for 25/05/17 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
Example solutions:&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/740f3d8bf98469aebffc0d25cc8db856&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=122795</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=122795"/>
		<updated>2017-05-25T05:14:27Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Test */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 25/05/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/50b884d419c18ad9235fc741bf9fd490&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120954</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120954"/>
		<updated>2017-05-04T08:22:18Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Lecture 5 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
datetime, csv files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture5v2&amp;diff=120953</id>
		<title>I719 Fundamentals of Python/lecture5v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture5v2&amp;diff=120953"/>
		<updated>2017-05-04T08:21:00Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 5 =  Working with real data.&amp;lt;br /&amp;gt; Datetime, CSV files  == Datetime ==  &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import datetime as dt  my_datetime = dt.datetime.utcnow()  # get the cu...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 5 =&lt;br /&gt;
&lt;br /&gt;
Working with real data.&amp;lt;br /&amp;gt;&lt;br /&gt;
Datetime, CSV files&lt;br /&gt;
&lt;br /&gt;
== Datetime ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import datetime as dt&lt;br /&gt;
&lt;br /&gt;
my_datetime = dt.datetime.utcnow()  # get the current date and time (without timezone) as a datetime object&lt;br /&gt;
&lt;br /&gt;
one_day = dt.timedelta(days=1)  # create a duration of 1 day&lt;br /&gt;
&lt;br /&gt;
tomorrow = my_datetime + one_day&lt;br /&gt;
&lt;br /&gt;
yesterday = my_datetime - one_day&lt;br /&gt;
&lt;br /&gt;
tomorrow &amp;gt; yesterday  # True&lt;br /&gt;
&lt;br /&gt;
current_year = my_datetime.year&lt;br /&gt;
&lt;br /&gt;
first_day_of_year = dt.datetime(year=current_year, month=1, day=1)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Task 1 ==&lt;br /&gt;
&lt;br /&gt;
Display the current date like&amp;lt;br /&amp;gt;&lt;br /&gt;
“2017-05-04”&lt;br /&gt;
&lt;br /&gt;
Calculate How many days since Jan 1.&lt;br /&gt;
&lt;br /&gt;
Optional, requires using timezone:&amp;lt;br /&amp;gt;&lt;br /&gt;
How many hours are left until midnight today?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import datetime as dt&lt;br /&gt;
&lt;br /&gt;
print(dt.datetime.utcnow().strftime(&amp;quot;%Y-%m-%d&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
today = dt.date.today()&lt;br /&gt;
&lt;br /&gt;
first_of_the_year = dt.date(year=2017, month=1, day=1)&lt;br /&gt;
&lt;br /&gt;
print(today - first_of_the_year)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
now = dt.datetime.now()&lt;br /&gt;
midnight = dt.datetime(year=now.year, month=now.month, day=(now.day + 1))&lt;br /&gt;
print(midnight - now)&amp;lt;/source&amp;gt;&lt;br /&gt;
== CSV files ==&lt;br /&gt;
&lt;br /&gt;
CSV files are a portable and common way of using tabular data. They are easily used in python.&lt;br /&gt;
&lt;br /&gt;
== Example: Printing every row of a csv file ==&lt;br /&gt;
&lt;br /&gt;
Using a hardcoded path to &amp;lt;code&amp;gt;~/sheet1.csv&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Uses a hardcoded path to the file. used when you cannot use the command line to run python. For example if you run the script in an IDE&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
import csv&lt;br /&gt;
from os.path import expanduser, join&lt;br /&gt;
&lt;br /&gt;
home = expanduser(&amp;quot;~&amp;quot;)&lt;br /&gt;
path = join(home, &#039;sheet1.csv&#039;)&lt;br /&gt;
csv_file = open(path)&lt;br /&gt;
&lt;br /&gt;
reader = csv.reader(csv_file)&lt;br /&gt;
for row in reader:&lt;br /&gt;
    print(line)&lt;br /&gt;
&lt;br /&gt;
csv_file.close()&amp;lt;/source&amp;gt;&lt;br /&gt;
Using the argparse library&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Open a file using argparse.&lt;br /&gt;
Work when ran from command line&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
import argparse&lt;br /&gt;
import csv&lt;br /&gt;
&lt;br /&gt;
parser = argparse.ArgumentParser()&lt;br /&gt;
parser.add_argument(&#039;file&#039;)&lt;br /&gt;
args = parser.parse_args()&lt;br /&gt;
&lt;br /&gt;
csv_file = open(args.file)&lt;br /&gt;
&lt;br /&gt;
reader = csv.reader(csv_file)&lt;br /&gt;
for row in reader:&lt;br /&gt;
    print(row)&lt;br /&gt;
&lt;br /&gt;
csv_file.close()&amp;lt;/source&amp;gt;&lt;br /&gt;
== Task 2 ==&lt;br /&gt;
&lt;br /&gt;
What was the average price of bitcoin in April?&lt;br /&gt;
&lt;br /&gt;
CSV of historical price data here:&amp;lt;br /&amp;gt;&lt;br /&gt;
https://blockchain.info/charts/market-price?timespan=1year&lt;br /&gt;
&lt;br /&gt;
=== Hints ===&lt;br /&gt;
&lt;br /&gt;
convert timestamps to datetime object&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;datetime.datetime.strptime(&amp;amp;quot;2016-05-11 00:00:00&amp;amp;quot;, &amp;amp;quot;%Y-%m-%d 00:00:00&amp;amp;quot;)&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Open a file using argparse.&lt;br /&gt;
Work when ran from command line&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
import datetime as dt&lt;br /&gt;
import argparse&lt;br /&gt;
import csv&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
MIN_DATE = dt.datetime(year=2017, month=4, day=1)&lt;br /&gt;
MAX_DATE = dt.datetime(year=2017, month=5, day=1)&lt;br /&gt;
&lt;br /&gt;
parser = argparse.ArgumentParser()&lt;br /&gt;
parser.add_argument(&#039;file&#039;)&lt;br /&gt;
args = parser.parse_args()&lt;br /&gt;
csv_file = open(args.file)&lt;br /&gt;
reader = csv.reader(csv_file)&lt;br /&gt;
&lt;br /&gt;
prices_in_april = []&lt;br /&gt;
&lt;br /&gt;
for row in reader:&lt;br /&gt;
    raw_price = row[1]&lt;br /&gt;
    price = float(raw_price)&lt;br /&gt;
    raw_date = row[0]&lt;br /&gt;
    date = dt.datetime.strptime(raw_date, &amp;quot;%Y-%m-%d 00:00:00&amp;quot;)&lt;br /&gt;
    if date &amp;gt;= MIN_DATE and date &amp;lt; MAX_DATE:&lt;br /&gt;
        prices_in_april.append(price)&lt;br /&gt;
&lt;br /&gt;
csv_file.close()&lt;br /&gt;
&lt;br /&gt;
print(sum(prices_in_april) / len(prices_in_april))&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120950</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120950"/>
		<updated>2017-05-04T05:18:18Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
Git Repo with Readme, before 6th class&lt;br /&gt;
&lt;br /&gt;
Completed project, 7th class&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120528</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120528"/>
		<updated>2017-04-27T18:35:37Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Lecture 4 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project deadline system will be announced soon.&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
Making a basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4v2&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture4v2&amp;diff=120527</id>
		<title>I719 Fundamentals of Python/lecture4v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture4v2&amp;diff=120527"/>
		<updated>2017-04-27T18:26:39Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 4 =  introduction to website development with flask.  NOTE: you do not need to know this material for the test or to know python in general. It is only for showing h...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 4 =&lt;br /&gt;
&lt;br /&gt;
introduction to website development with flask.&lt;br /&gt;
&lt;br /&gt;
NOTE: you do not need to know this material for the test or to know python in general. It is only for showing how to make a website easily.&lt;br /&gt;
&lt;br /&gt;
== Task 0 ==&lt;br /&gt;
&lt;br /&gt;
copy and paste the example from flask&#039;s homepage http://flask.pocoo.org/&lt;br /&gt;
&lt;br /&gt;
then run it, and go the the url printed in your terminal&lt;br /&gt;
&lt;br /&gt;
== Query strings and form data ==&lt;br /&gt;
&lt;br /&gt;
The form data and query string data are acessible from a special &amp;lt;code&amp;gt;request&amp;lt;/code&amp;gt; object. This &amp;lt;code&amp;gt;request&amp;lt;/code&amp;gt; object is imported, and only has data when it is used inside of a view function.&lt;br /&gt;
&lt;br /&gt;
the data for query strings and forms is in a dictionary like object.&lt;br /&gt;
&lt;br /&gt;
== Task 1 ==&lt;br /&gt;
&lt;br /&gt;
Show the bitcoin price in Euro on a webpage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
from flask import Flask&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def get_btc_price():&lt;br /&gt;
    r = requests.get(&#039;https://api.coindesk.com/v1/bpi/currentprice.json&#039;)&lt;br /&gt;
    data = r.json()&lt;br /&gt;
    price = data[&#039;bpi&#039;][&#039;EUR&#039;][&#039;rate&#039;]&lt;br /&gt;
    return price&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
app = Flask(__name__)&lt;br /&gt;
app.config[&#039;DEBUG&#039;] = True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
@app.route(&amp;quot;/&amp;quot;)&lt;br /&gt;
def hello():&lt;br /&gt;
    return &#039;{} &amp;amp;euro;&#039;.format(get_btc_price())&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    app.run()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== HTML Templates ==&lt;br /&gt;
&lt;br /&gt;
To use an HTML template with the default flask configuration, make a directory &#039;templates&#039; in the same directory as your flask script. you can then put html template in here.&lt;br /&gt;
&lt;br /&gt;
for a script &amp;lt;code&amp;gt;./app.py&amp;lt;/code&amp;gt; to use a template &amp;lt;code&amp;gt;./templates/index.html&amp;lt;/code&amp;gt;, import &amp;lt;code&amp;gt;render_template&amp;lt;/code&amp;gt; from flask: &amp;lt;code&amp;gt;from flask import Flask, render_template&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and use the line in your view function &amp;lt;code&amp;gt;return render_template(&#039;index.html&#039;)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
variables in jinja2 templates look like &amp;lt;code&amp;gt;{{ variable_name }}&amp;lt;/code&amp;gt;, and can be substituted in the &amp;lt;code&amp;gt;render_template&amp;lt;/code&amp;gt; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;return render_template(&#039;index.html&#039;, variable_name=&#039;value&#039;)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Flask uses the Jinja2 templating engine. see their documentation for more information&lt;br /&gt;
&lt;br /&gt;
== Task 2 ==&lt;br /&gt;
&lt;br /&gt;
Make a form that asks for name and age, and displays:&lt;br /&gt;
&lt;br /&gt;
&#039;Hi $NAME, you are $AGE years old&#039;&lt;br /&gt;
&lt;br /&gt;
using a post request&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from flask import Flask, render_template, request&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
app = Flask(__name__)&lt;br /&gt;
app.config[&#039;DEBUG&#039;] = True&lt;br /&gt;
&lt;br /&gt;
@app.route(&amp;quot;/&amp;quot;, methods=[&#039;POST&#039;, &#039;GET&#039;])&lt;br /&gt;
def hello():&lt;br /&gt;
    name = request.form.get(&#039;name&#039;, &#039;&#039;)&lt;br /&gt;
    age = request.form.get(&#039;age&#039;, &#039;&#039;)&lt;br /&gt;
    if name and age:&lt;br /&gt;
        return render_template(&#039;index.html&#039;, name=name, age=age)&lt;br /&gt;
    else:&lt;br /&gt;
        return render_template(&#039;index.html&#039;, name=name, age=age), 400&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    app.run(port=5000)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;templates/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;html&amp;quot;&amp;gt;&amp;amp;lt;html&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;head&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/head&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;body&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;h1&amp;amp;gt;HTML!&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;p&amp;amp;gt;Hi {{ name }}, you are {{ age }} years old&amp;amp;lt;/p&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;form action=&amp;amp;quot;/&amp;amp;quot; method=&amp;amp;quot;POST&amp;amp;quot;&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;label&amp;amp;gt;Age&lt;br /&gt;
                &amp;amp;lt;input type=&amp;amp;quot;text&amp;amp;quot; name=&amp;amp;quot;age&amp;amp;quot; /&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;/label&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;label&amp;amp;gt;Name&amp;amp;lt;input type=&amp;amp;quot;text&amp;amp;quot; name=&amp;amp;quot;name&amp;amp;quot; /&amp;amp;gt;&amp;amp;lt;/label&amp;amp;gt;&lt;br /&gt;
            &amp;amp;lt;button type=&amp;amp;quot;submit&amp;amp;quot;&amp;amp;gt;submit&amp;amp;lt;/button&amp;amp;gt;&lt;br /&gt;
        &amp;amp;lt;/form&amp;amp;gt;&lt;br /&gt;
    &amp;amp;lt;/body&amp;amp;gt;&lt;br /&gt;
&amp;amp;lt;/html&amp;amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Task 3 ==&lt;br /&gt;
&lt;br /&gt;
make a post request to your application with &amp;lt;code&amp;gt;requests&amp;lt;/code&amp;gt; that submits the name and age&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;r = requests.post(&#039;http://localhost:5000/&#039;, data={&#039;name&#039;: &#039;Talvi&#039;, &#039;age&#039;: 50})&lt;br /&gt;
print(r.text)&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120340</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120340"/>
		<updated>2017-04-20T22:44:35Z</updated>

		<summary type="html">&lt;p&gt;Eroman: /* Lecture 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project deadline system will be announced soon.&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Console input, exceptions, unit testing, command line arguments, opening files&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3v3&lt;br /&gt;
&lt;br /&gt;
Old version:&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture3v3&amp;diff=120339</id>
		<title>I719 Fundamentals of Python/lecture3v3</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture3v3&amp;diff=120339"/>
		<updated>2017-04-20T22:42:07Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot; = Lecture 3 =  Input, Handling Errors, Unit Testing  == Input from console ==  You can prompt the user for input using a function called &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt;.  on python2, this...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt; = Lecture 3 =&lt;br /&gt;
&lt;br /&gt;
Input, Handling Errors, Unit Testing&lt;br /&gt;
&lt;br /&gt;
== Input from console ==&lt;br /&gt;
&lt;br /&gt;
You can prompt the user for input using a function called &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
on python2, this is called &amp;lt;code&amp;gt;raw_input&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; is a function that stops execution until the user hits &#039;enter&#039;, and the value they enter is the output of the the &amp;lt;code&amp;gt;input&amp;lt;/code&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
== Task 1 ==&lt;br /&gt;
&lt;br /&gt;
Write a program that takes two numbers from the user and prints the numbers added together.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;amp;quot;&amp;amp;quot;&amp;amp;quot;&lt;br /&gt;
Addition calculator&lt;br /&gt;
&lt;br /&gt;
Write a script that takes in two numbers, and adds them together.&lt;br /&gt;
&amp;amp;quot;&amp;amp;quot;&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
number_1 = int(input(&#039;Write a number: &#039;))&lt;br /&gt;
number_2 = int(input(&#039;Write a number: &#039;))&lt;br /&gt;
print(number_1 + number_2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;except&amp;lt;/code&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; creates a block that can run code that may raise an error. If an error is raised, the code in &amp;lt;code&amp;gt;except&amp;lt;/code&amp;gt; will run. If an error is NOT raised, then the code in &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; will run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;number_1 = input(&#039;Write a number: &#039;)&lt;br /&gt;
number_2 = input(&#039;Write a number: &#039;)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    number_1 = int(number_1)&lt;br /&gt;
    number_2 = int(number_2)&lt;br /&gt;
&lt;br /&gt;
except ValueError:&lt;br /&gt;
    print(&#039;You must enter valid integers&#039;)&lt;br /&gt;
else:&lt;br /&gt;
    print(number_1 + number_2)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Exceptions ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;class NotIntegerError(Exception):&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
number_1 = input(&#039;Write a number: &#039;)&lt;br /&gt;
number_2 = input(&#039;Write a number: &#039;)&lt;br /&gt;
&lt;br /&gt;
if not number_1.isdigit():&lt;br /&gt;
    raise NotIntegerError(&#039;{0} is not a number&#039;.format(number_1))&lt;br /&gt;
&lt;br /&gt;
if not number_2.isdigit():&lt;br /&gt;
    raise NotIntegerError(&#039;{0} is not a number&#039;.format(number_2))&lt;br /&gt;
&lt;br /&gt;
number_1 = int(number_1)&lt;br /&gt;
number_2 = int(number_2)&lt;br /&gt;
print(number_1 + number_2)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Unit testing ==&lt;br /&gt;
&lt;br /&gt;
See https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Arguments from commandline ==&lt;br /&gt;
&lt;br /&gt;
The standard library has sys which give us access to the command line arguments executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import sys&lt;br /&gt;
 &lt;br /&gt;
if &#039;-h&#039; in sys.argv or &#039;--help&#039; in sys.argv:&lt;br /&gt;
    print(&#039;Sorry I can\&#039;t help you :(&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
But argparse from the standard library is much easier if we want to use the commandline arguments.&lt;br /&gt;
&lt;br /&gt;
== Opening a file, printing every line ==&lt;br /&gt;
&lt;br /&gt;
The file path is passed into the script in the command line. run this script using &amp;lt;code&amp;gt;python3 my_script.py --help&amp;lt;/code&amp;gt; and a help message will show. run this script with &amp;lt;code&amp;gt;python3 my_script path/to/my/file.txt&amp;lt;/code&amp;gt; to read &amp;lt;code&amp;gt;file.txt&amp;lt;/code&amp;gt; line by line.&lt;br /&gt;
&lt;br /&gt;
NOTE: you must run this from the commandline, not from your IDE&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
== Task 2 ==&lt;br /&gt;
&lt;br /&gt;
Count the occurence of words in the file.&lt;br /&gt;
&lt;br /&gt;
example output&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;{&#039;banana&#039;: 1, &#039;carrot&#039;: 9, &#039;pumpkin&#039;: 2, &#039;cabbage&#039;: 7}&amp;lt;/pre&amp;gt;&lt;br /&gt;
example solution&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import argparse&lt;br /&gt;
&lt;br /&gt;
parser = argparse.ArgumentParser(description=&#039;Count unique words in a file&#039;)&lt;br /&gt;
parser.add_argument(&#039;path&#039;)&lt;br /&gt;
&lt;br /&gt;
args = parser.parse_args()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
my_file = open(args.path, &#039;r&#039;)&lt;br /&gt;
&lt;br /&gt;
result = {}&lt;br /&gt;
for line in my_file:&lt;br /&gt;
    clean_line = line.strip()&lt;br /&gt;
    result[clean_line] = result.get(clean_line, 0) + 1&lt;br /&gt;
&lt;br /&gt;
my_file.close()&lt;br /&gt;
print(result)&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120168</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=120168"/>
		<updated>2017-04-17T10:04:39Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project deadline system will be announced soon.&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
Dictionaries, importable modules, classes&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture2v2&amp;diff=120167</id>
		<title>I719 Fundamentals of Python/lecture2v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture2v2&amp;diff=120167"/>
		<updated>2017-04-17T10:03:14Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lecture 2 =  Dictionaries, Importing, HTTP Requests, and Classes  == Dictionaries ==  Map keys to values  &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# Make a list &amp;gt;&amp;gt;&amp;gt; a = [1, 2, 3] # get element...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lecture 2 =&lt;br /&gt;
&lt;br /&gt;
Dictionaries, Importing, HTTP Requests, and Classes&lt;br /&gt;
&lt;br /&gt;
== Dictionaries ==&lt;br /&gt;
&lt;br /&gt;
Map keys to values&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# Make a list&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a = [1, 2, 3]&lt;br /&gt;
# get element of a list using the index of an element &lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a[1]&lt;br /&gt;
2&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; a[0]&lt;br /&gt;
1&lt;br /&gt;
# get character in a string using the index of a character&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; hello = &amp;quot;hello&amp;quot;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; hello[1]&lt;br /&gt;
&#039;e&#039;&lt;br /&gt;
# create a dictionary, with name of a programming language as a key&lt;br /&gt;
# and the year created as the value&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict = {&#039;python&#039;: 1991}&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict&lt;br /&gt;
{&#039;python&#039;: 1991}&lt;br /&gt;
# get value from a dictionary using the key&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict[&#039;python&#039;]&lt;br /&gt;
1991&lt;br /&gt;
# accessing a key that does not exist&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict[&#039;p&#039;]&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;&amp;lt;input&amp;gt;&amp;quot;, line 1, in &amp;lt;module&amp;gt;&lt;br /&gt;
    example_dict[&#039;p&#039;]&lt;br /&gt;
KeyError: &#039;p&#039;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict.get(&#039;python&#039;)&lt;br /&gt;
1991&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict.get(&#039;pythons&#039;)&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict.get(&#039;pythons&#039;, 1990)&lt;br /&gt;
1990&lt;br /&gt;
# adding a new item (key and value pair) to a dictionary&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict[&#039;javascript&#039;] = 1995&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; example_dict&lt;br /&gt;
{&#039;javascript&#039;: 1995, &#039;python&#039;: 1991}&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
== Example creation of dictionary ==&lt;br /&gt;
&lt;br /&gt;
Make a dictionary mapping numbers to squares&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def map_numbers_to_squares(numbers):&lt;br /&gt;
    result = {}&lt;br /&gt;
    for number in numbers:&lt;br /&gt;
        result[number] = number ** 2&lt;br /&gt;
    return result&amp;lt;/source&amp;gt;&lt;br /&gt;
== TASK 1 ==&lt;br /&gt;
&lt;br /&gt;
Args: multiplier: a number to multiply numbers by numbers: a list of numbers&lt;br /&gt;
&lt;br /&gt;
Returns: dict of numbers, mapping each number to the number multiplied by the multiplier number is the key, the product is the value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt; test_function(4, [1,2])&lt;br /&gt;
# 1*4 = 4, 2*4 = 8&lt;br /&gt;
{1: 3, 2: 8}&amp;lt;/source&amp;gt;&lt;br /&gt;
Answer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def map_products(multiplier, numbers):&lt;br /&gt;
    result = {}&lt;br /&gt;
    for number in numbers:&lt;br /&gt;
        result[number] = number * multiplier&lt;br /&gt;
    return result&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Importing ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
import requests as r&lt;br /&gt;
from requests import get&amp;lt;/source&amp;gt;&lt;br /&gt;
== Requests library ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;pip3 install requests&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
&lt;br /&gt;
response = requests.get(&#039;http://google.com&#039;)&lt;br /&gt;
&lt;br /&gt;
response.text  # get the response body as a string&lt;br /&gt;
&lt;br /&gt;
response.json()  # if the response is json, convert it into python native types&amp;lt;/source&amp;gt;&lt;br /&gt;
== TASK 2 ==&lt;br /&gt;
&lt;br /&gt;
Get the bitcoin price in euros, and print it.&lt;br /&gt;
&lt;br /&gt;
== Importable thing ==&lt;br /&gt;
&lt;br /&gt;
== TASK 3 ==&lt;br /&gt;
&lt;br /&gt;
make a function that returns the bitcoin price. From another file, print the price&lt;br /&gt;
&lt;br /&gt;
== Classes ==&lt;br /&gt;
&lt;br /&gt;
This is a basic intro to classes. Classes organize code and provide the basis for the object/type system of python. An object has data and behavior. Classes define new objects. This python course will not require object oriented design, but you should know the basics of a python class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;# define a class&lt;br /&gt;
class Animal:&lt;br /&gt;
    # this is a magic method.&lt;br /&gt;
    # __init__ is called when the class is instantiated&lt;br /&gt;
    # `my_animal = Animal(&#039;masha&#039;)` makes a new Animal, executes this method, and assigns the new animal to &#039;my_animal&#039;&lt;br /&gt;
    def __init__(self, name):&lt;br /&gt;
        # self refers to newly created instance of the class.&lt;br /&gt;
        print(id(self))&lt;br /&gt;
        # this creates an instance attribute &#039;name&#039; &lt;br /&gt;
        self.name = name&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# define a Dog, which is Animal&lt;br /&gt;
# Dog also has the same __init__ method from animal&lt;br /&gt;
class Dog(Animal):&lt;br /&gt;
    def change_name(self, name):&lt;br /&gt;
        self.name = name&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# define a Cat, which is an Animal&lt;br /&gt;
class Cat(Animal):&lt;br /&gt;
    def kak_zavut(self):&lt;br /&gt;
        return &#039;minu nimi on {}&#039;.format(self.name)&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=119941</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=119941"/>
		<updated>2017-04-07T13:46:21Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is eroman@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: 01.06.2017 10:00-11:30 410&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project deadline system will be announced soon.&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;: https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Running python, integers, booleans, strings, lists, &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2&lt;br /&gt;
&lt;br /&gt;
Old lecture notes:&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture1v2&amp;diff=119940</id>
		<title>I719 Fundamentals of Python/lecture1v2</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture1v2&amp;diff=119940"/>
		<updated>2017-04-07T13:38:35Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Lesson 1 =  == Running Python ==  There are executables &amp;lt;code&amp;gt;python&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;python2&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;python3&amp;lt;/code&amp;gt; By default on ubuntu and most systems, &amp;lt;code&amp;gt;pyth...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Lesson 1 =&lt;br /&gt;
&lt;br /&gt;
== Running Python ==&lt;br /&gt;
&lt;br /&gt;
There are executables &amp;lt;code&amp;gt;python&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;python2&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;python3&amp;lt;/code&amp;gt; By default on ubuntu and most systems, &amp;lt;code&amp;gt;python&amp;lt;/code&amp;gt; is symlinked to &amp;lt;code&amp;gt;python2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== python 2 or 3? ===&lt;br /&gt;
&lt;br /&gt;
* v2 is more commonly used&lt;br /&gt;
* v3 is the official standard&lt;br /&gt;
* all the code we write today will run on both versions&lt;br /&gt;
&lt;br /&gt;
=== interactive ===&lt;br /&gt;
&lt;br /&gt;
many interactive shells&lt;br /&gt;
&lt;br /&gt;
* default repl, &amp;lt;code&amp;gt;python3&amp;lt;/code&amp;gt;&lt;br /&gt;
* IPython (recommended), &amp;lt;code&amp;gt;ipython3&amp;lt;/code&amp;gt;&lt;br /&gt;
* bpython, &amp;lt;code&amp;gt;bpython3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Run a python script ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 my_script.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Writing python ===&lt;br /&gt;
&lt;br /&gt;
The editor must recognize that python requires a 4 space indent.&lt;br /&gt;
&lt;br /&gt;
* Use what ever editor you want&lt;br /&gt;
* If you do not know what to do, use Spyder&lt;br /&gt;
* If you want to learn something new, I recommend learning vim or emacs&lt;br /&gt;
* PyCharm is a popular IDE&lt;br /&gt;
&lt;br /&gt;
== Language basics ==&lt;br /&gt;
&lt;br /&gt;
=== Whitespace dependent ===&lt;br /&gt;
&lt;br /&gt;
* 4 space indent&lt;br /&gt;
* no brackets &amp;lt;code&amp;gt;{&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;}&amp;lt;/code&amp;gt; like in java&lt;br /&gt;
* no semicolons&lt;br /&gt;
* indent level replaces brackets&lt;br /&gt;
&lt;br /&gt;
For example in javascript:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;function hi (name) {  // uses &#039;{&#039; to determine what is in function body&lt;br /&gt;
    return &amp;quot;Hi &amp;quot; + name;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
would become in python:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def hi(name):  # code indented after the function definition is the function body, and is executed when the function is called&lt;br /&gt;
    return &#039;Hi {}&#039;.format(name)&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Comments and Documentation ===&lt;br /&gt;
&lt;br /&gt;
* use &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; for comments&lt;br /&gt;
* use &amp;lt;code&amp;gt;&amp;amp;quot;&amp;amp;quot;&amp;amp;quot;&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;&#039;&#039;&#039;&amp;lt;/code&amp;gt; to start and close multiline strings that will become documentation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def hi(name):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Prepend &#039;Hi &#039; before name. This is documentation&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    result = &#039;Hi {}&#039;.format(name)  # this is a comment&lt;br /&gt;
    return result&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Types ===&lt;br /&gt;
&lt;br /&gt;
* to find the type of a symbol &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt;, use &amp;lt;code&amp;gt;type(a)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;hello = &#039;Hello World!&#039;&lt;br /&gt;
print(hello)&amp;lt;/source&amp;gt;&lt;br /&gt;
* double or single quotes are fine&lt;br /&gt;
* length of string determined by function &amp;lt;code&amp;gt;len()&amp;lt;/code&amp;gt;&lt;br /&gt;
* concatenate strings with &amp;lt;code&amp;gt;+&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;hello = &#039;Hello&#039;&lt;br /&gt;
world = &#039;World&#039;&lt;br /&gt;
hello_world = hello + &#039; &#039; + world  # &#039;Hello World&#039;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;substitute variable in a template string with &amp;lt;code&amp;gt;format&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;template_string = &#039;Hi {}&#039;&lt;br /&gt;
hi_bob = template_string.format(&#039;Bob&#039;)  # &#039;Hi Bob&#039;&amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
* uses operators like most other languages&lt;br /&gt;
* similar to java, &amp;lt;code&amp;gt;1 + 1&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== functions ===&lt;br /&gt;
&lt;br /&gt;
* to define a function, start with &amp;lt;code&amp;gt;def&amp;lt;/code&amp;gt;&lt;br /&gt;
* then the function name&lt;br /&gt;
* functions are always in snake case. always lower case and words are separated by underscores&lt;br /&gt;
* add the end of the name, list of arguments in parethesis&lt;br /&gt;
* to document function, use triple quoted string after function definition&lt;br /&gt;
* functions can use named arguments, which allow a default value for the argument. They are called &#039;Keyword Arguments&#039;&lt;br /&gt;
* Arguments can be made in order they are in the function definition, or be named specifically&lt;br /&gt;
&lt;br /&gt;
=== Lists ===&lt;br /&gt;
&lt;br /&gt;
lists in Python are like arrays in Java. They do not have predetermined length, and elements can be any type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;a = [1, 2, 3]  # defines a list&amp;lt;/source&amp;gt;&lt;br /&gt;
=== For loops ===&lt;br /&gt;
&lt;br /&gt;
Python&#039;s &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; is different from other languages. It is a &amp;amp;quot;foreach&amp;amp;quot; loop. It goes through each element of an iterator.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
0&lt;br /&gt;
1&lt;br /&gt;
2&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
for i in range(3):&lt;br /&gt;
    print(i)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; in this example becomes an element of the iterator being iterated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
H&lt;br /&gt;
e&lt;br /&gt;
l&lt;br /&gt;
l&lt;br /&gt;
o&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
for character in &amp;quot;Hello&amp;quot;:&lt;br /&gt;
    print(character)&amp;lt;/source&amp;gt;&lt;br /&gt;
= Tasks =&lt;br /&gt;
&lt;br /&gt;
== Task 1 ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;quot;Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.&amp;amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Example Solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;for x in range(1,101):&lt;br /&gt;
    if x % 15 == 0:&lt;br /&gt;
        print(&amp;quot;FizzBuzz&amp;quot;)  # Catch multiples of both first.&lt;br /&gt;
    elif x % 3 == 0:&lt;br /&gt;
        print(&amp;quot;Fizz&amp;quot;)&lt;br /&gt;
    elif x % 5 == 0:&lt;br /&gt;
        print(&amp;quot;Buzz&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(x)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Task 2 ==&lt;br /&gt;
&lt;br /&gt;
Write a function that meets these requirements:&lt;br /&gt;
&lt;br /&gt;
Args: name: a string exclamation: optional, defaults to &#039;Hi&#039;&lt;br /&gt;
&lt;br /&gt;
Returns: string with name prefixed by the exclamation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
&#039;Hi Bob!&#039;&lt;br /&gt;
&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; test_function(&#039;Sally&#039;, exclamation=&#039;Bye&#039;)&lt;br /&gt;
&#039;Bye Sally!&#039;&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def hi(name, exclamation=&#039;Hi&#039;):&lt;br /&gt;
    return &#039;{e} {n}&#039;.format(n=name, e=exclamation)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Task 2 ==&lt;br /&gt;
&lt;br /&gt;
Write a function that meets these requirements:&lt;br /&gt;
&lt;br /&gt;
Args: numbers - a list of numbers&lt;br /&gt;
&lt;br /&gt;
Returns: Boolean True if an odd number exists in the list of numbers False if only even numbers exist in numbers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; test_function([2,1])&lt;br /&gt;
# 1 is an odd number&lt;br /&gt;
True&lt;br /&gt;
&amp;amp;gt;&amp;amp;gt;&amp;amp;gt; test_function([2,4])&lt;br /&gt;
# Both 2 and 4 are even numbers&lt;br /&gt;
False&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def has_odd(l):&lt;br /&gt;
    for i in l:&lt;br /&gt;
        if i % 2 != 0:&lt;br /&gt;
            return True&lt;br /&gt;
    return False&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=119861</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=119861"/>
		<updated>2017-04-05T20:14:53Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taught Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is [mailto:eroman@itcollege.ee eroman@itcollege.ee]&lt;br /&gt;
&lt;br /&gt;
== You ==&lt;br /&gt;
&lt;br /&gt;
https://goo.gl/forms/KhjvJcN1T1ANd78g2&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: in june, TBA&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project is due the class before the last class (March 16th). You may submit your project before then, and I will check it. If It does not meet the requirements, I will give you feedback.&lt;br /&gt;
&lt;br /&gt;
To present your project, come at 10:00AM on the last day of class (Thursday, March 23rd)&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;:&amp;lt;br /&amp;gt;&lt;br /&gt;
https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv.&amp;lt;br /&amp;gt;&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=119332</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=119332"/>
		<updated>2017-03-23T06:21:19Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taugh Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is [mailto:eroman@itcollege.ee eroman@itcollege.ee]&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: in june, TBA&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
=== Real Test for 23/03/17 ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project is due the class before the last class (March 16th). You may submit your project before then, and I will check it. If It does not meet the requirements, I will give you feedback.&lt;br /&gt;
&lt;br /&gt;
To present your project, come at 10:00AM on the last day of class (Thursday, March 23rd)&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;:&amp;lt;br /&amp;gt;&lt;br /&gt;
https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv.&amp;lt;br /&amp;gt;&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=118712</id>
		<title>I719 Fundamentals of Python</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python&amp;diff=118712"/>
		<updated>2017-03-19T12:34:05Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= About =&lt;br /&gt;
&lt;br /&gt;
This class is python for beginners, taugh Spring 2017&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
My email is [mailto:eroman@itcollege.ee eroman@itcollege.ee]&lt;br /&gt;
&lt;br /&gt;
= Frequently Asked Questions =&lt;br /&gt;
&lt;br /&gt;
== What should I know already ==&lt;br /&gt;
&lt;br /&gt;
It would be good to know:&lt;br /&gt;
&lt;br /&gt;
* How to use the unix command line&lt;br /&gt;
* GIT&lt;br /&gt;
&lt;br /&gt;
== What editor/IDE should I use? ==&lt;br /&gt;
&lt;br /&gt;
Whatever you want! I recommend learning emacs or vim. If you do not know how to use any specific editor and do not want to learn one now, then use spyder for writing python.&lt;br /&gt;
&lt;br /&gt;
== What python version are we using? ==&lt;br /&gt;
&lt;br /&gt;
I will teach using python 3&lt;br /&gt;
&lt;br /&gt;
== What books/resources do you recommend? ==&lt;br /&gt;
&lt;br /&gt;
This page contains most of python&#039;s syntax: https://learnxinyminutes.com/docs/python3/&lt;br /&gt;
&lt;br /&gt;
== What software do I need to install? ==&lt;br /&gt;
&lt;br /&gt;
You only need python 3 and an editor.&lt;br /&gt;
&lt;br /&gt;
I recommend that you install an interactive python shell, like IPython[https://ipython.org/ 1] or bpython[https://bpython-interpreter.org/ 2]&lt;br /&gt;
&lt;br /&gt;
= Grading =&lt;br /&gt;
&lt;br /&gt;
There will be a test on the last day. It is pass/fail. You may do a project instead of the test. I recommend this, since it will be more fun and you will learn more.&lt;br /&gt;
&lt;br /&gt;
== Test ==&lt;br /&gt;
&lt;br /&gt;
The test will cover only builtin python types and only use the standard library. There will be 3 test dates. The format will be A series of unit test cases which you must write a function that will make the unit test pass.&lt;br /&gt;
&lt;br /&gt;
You may use the internet during the exam.&lt;br /&gt;
&lt;br /&gt;
=== Test dates ===&lt;br /&gt;
&lt;br /&gt;
Primary date: Thursday March 23rd, starting at 8:15AM&lt;br /&gt;
&lt;br /&gt;
Makeup date 1: in june, TBA&lt;br /&gt;
&lt;br /&gt;
Makeup date 2: in august, TBA&lt;br /&gt;
&lt;br /&gt;
=== Test topics ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;elif&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; statements&lt;br /&gt;
* functions&lt;br /&gt;
* lists and dictionaries&lt;br /&gt;
** see https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lists&lt;br /&gt;
* for loops&lt;br /&gt;
* basic string manipulation&lt;br /&gt;
&lt;br /&gt;
=== Example problem ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = None  # Assign to your function&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Example solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;python3 -m unittest exam.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from unittest import TestCase&lt;br /&gt;
&lt;br /&gt;
def prepend_hello(string):&lt;br /&gt;
    return &amp;quot;Hello {}&amp;quot;.format(string)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class StringCountTestCase(TestCase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Write a function that for any string, prepends &#039;Hello &#039;&lt;br /&gt;
    &amp;gt;&amp;gt;&amp;gt; test_function(&#039;Bob&#039;)&lt;br /&gt;
    &#039;Hello Bob&#039;&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def setUp(self):&lt;br /&gt;
        self.test_function = prepend_hello&lt;br /&gt;
&lt;br /&gt;
    def test_sally(self):&lt;br /&gt;
        result = self.test_function(&#039;Sally&#039;)&lt;br /&gt;
        self.assertEqual(result, &#039;Hello Sally&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Practice Test ===&lt;br /&gt;
&lt;br /&gt;
https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc&lt;br /&gt;
&lt;br /&gt;
== Project due date ==&lt;br /&gt;
&lt;br /&gt;
The project is due the class before the last class (March 16th). You may submit your project before then, and I will check it. If It does not meet the requirements, I will give you feedback.&lt;br /&gt;
&lt;br /&gt;
To present your project, come at 10:00AM on the last day of class (Thursday, March 23rd)&lt;br /&gt;
&lt;br /&gt;
== Project Requirements ==&lt;br /&gt;
&lt;br /&gt;
* it can do something&lt;br /&gt;
* it uses version control&lt;br /&gt;
** it has more than one commit&lt;br /&gt;
** it has commit messages that are relevant to the commit&lt;br /&gt;
* it has a relevant unit test&lt;br /&gt;
* it has a README that describes what it does and how to run it.&lt;br /&gt;
&lt;br /&gt;
== Project idea examples ==&lt;br /&gt;
&lt;br /&gt;
* a game&lt;br /&gt;
* exploring a technology like image recognition&lt;br /&gt;
* a command line tool that does something&lt;br /&gt;
* a web application in python&lt;br /&gt;
** [http://flask.pocoo.org/ Flask] is simple and has good documentation for building a website&lt;br /&gt;
** for a website that would require users to sign up and login, consider [https://www.djangoproject.com/ Django]&lt;br /&gt;
* a web scraper&lt;br /&gt;
* many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.&lt;br /&gt;
&lt;br /&gt;
=== If you want to do things with cryptography ===&lt;br /&gt;
&lt;br /&gt;
* a cryptographic chat app&lt;br /&gt;
* a password storage bank like KeePassX&lt;br /&gt;
&lt;br /&gt;
== Can I ...? ==&lt;br /&gt;
&lt;br /&gt;
=== Can I use python 2? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
=== Can I use external libraries outside of the standard library? ===&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
&lt;br /&gt;
If you use external libraries, include a [https://pip.pypa.io/en/stable/user_guide/#requirements-files &amp;lt;code&amp;gt;requirements.txt&amp;lt;/code&amp;gt;] or [https://docs.python.org/3/distutils/setupscript.html &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt;] which has a list of packages required by your project&lt;br /&gt;
&lt;br /&gt;
== Project Tips ==&lt;br /&gt;
&lt;br /&gt;
=== .gitignore ===&lt;br /&gt;
&lt;br /&gt;
include a &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt; file in the root directory of your project. This will prevent &amp;lt;code&amp;gt;.pyc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__pycache__&amp;lt;/code&amp;gt; from being added to your git project.&lt;br /&gt;
&lt;br /&gt;
You can save this file as &amp;lt;code&amp;gt;.gitignore&amp;lt;/code&amp;gt;:&amp;lt;br /&amp;gt;&lt;br /&gt;
https://github.com/github/gitignore/blob/master/Python.gitignore&lt;br /&gt;
&lt;br /&gt;
= Lecture Notes =&lt;br /&gt;
&lt;br /&gt;
== Recordings ==&lt;br /&gt;
&lt;br /&gt;
recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906&lt;br /&gt;
&lt;br /&gt;
== Testing Python Code ==&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing&lt;br /&gt;
&lt;br /&gt;
== Lecture 1 ==&lt;br /&gt;
&lt;br /&gt;
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1&lt;br /&gt;
&lt;br /&gt;
== Lecture 2 ==&lt;br /&gt;
&lt;br /&gt;
importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2&lt;br /&gt;
&lt;br /&gt;
== Lecture 3 ==&lt;br /&gt;
&lt;br /&gt;
Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3&lt;br /&gt;
&lt;br /&gt;
=== Assets ===&lt;br /&gt;
&lt;br /&gt;
file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing&lt;br /&gt;
&lt;br /&gt;
== Lecture 4 ==&lt;br /&gt;
&lt;br /&gt;
Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4&lt;br /&gt;
&lt;br /&gt;
== Lecture 5 ==&lt;br /&gt;
&lt;br /&gt;
Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5&lt;br /&gt;
&lt;br /&gt;
=== survey ===&lt;br /&gt;
&lt;br /&gt;
https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform&lt;br /&gt;
&lt;br /&gt;
== Lecture 6 ==&lt;br /&gt;
&lt;br /&gt;
List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv.&amp;lt;br /&amp;gt;&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6&lt;br /&gt;
&lt;br /&gt;
== Lecture 7 ==&lt;br /&gt;
&lt;br /&gt;
Reduce function, using break and return for control flow, handling user input, handling errors&lt;br /&gt;
&lt;br /&gt;
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture7&amp;diff=118706</id>
		<title>I719 Fundamentals of Python/lecture7</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/lecture7&amp;diff=118706"/>
		<updated>2017-03-19T12:24:21Z</updated>

		<summary type="html">&lt;p&gt;Eroman: Created page with &amp;quot;= Advanced control flow =  == Task 1 ==  Make a function that returns the sum of all elements in an iterable  &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt; my_sum_function([2,3,5]) # 2 + 3 + 5 10...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Advanced control flow =&lt;br /&gt;
&lt;br /&gt;
== Task 1 ==&lt;br /&gt;
&lt;br /&gt;
Make a function that returns the sum of all elements in an iterable&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&amp;gt;&amp;gt;&amp;gt; my_sum_function([2,3,5])&lt;br /&gt;
# 2 + 3 + 5&lt;br /&gt;
10&amp;lt;/source&amp;gt;&lt;br /&gt;
== all, sum, any ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt;, true if all elements are true&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt;, true if any elements are true&lt;br /&gt;
&lt;br /&gt;
== Task 2 ==&lt;br /&gt;
&lt;br /&gt;
Find if all elements are false&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;opposite_all([False, False])&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; True&amp;lt;/source&amp;gt;&lt;br /&gt;
== Task 3 ==&lt;br /&gt;
&lt;br /&gt;
Implement &amp;lt;code&amp;gt;all&amp;lt;/code&amp;gt; function with a for loop&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;my_all([True, True])&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; True&amp;lt;/source&amp;gt;&lt;br /&gt;
== Break loops ==&lt;br /&gt;
&lt;br /&gt;
== Task 4 ==&lt;br /&gt;
&lt;br /&gt;
Implement &amp;lt;code&amp;gt;any&amp;lt;/code&amp;gt; with a for loop, use a &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
* When to raise an exception&lt;br /&gt;
* handling user input&lt;br /&gt;
&lt;br /&gt;
=== Example: Addition calculator ===&lt;br /&gt;
&lt;br /&gt;
this calculator is error prone. Users can put in a value that cannot be cast to an integer, which will cause this programs to raise an error.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def add_two_numbers(a, b):&lt;br /&gt;
    return int(a) + int(b)&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    a = input(&#039;Write a number: &#039;)&lt;br /&gt;
    b = input(&#039;Write a number: &#039;)&lt;br /&gt;
    result = add_two_numbers(a, b)&lt;br /&gt;
    print(result)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    main&amp;lt;/source&amp;gt;&lt;br /&gt;
giving an error like this on bad user input&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Write a number: a&lt;br /&gt;
Write a number: 1&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;amp;quot;calc.py&amp;amp;quot;, line 12, in &amp;amp;lt;module&amp;amp;gt;&lt;br /&gt;
    main()&lt;br /&gt;
  File &amp;amp;quot;calc.py&amp;amp;quot;, line 7, in main&lt;br /&gt;
    result = add_two_numbers(a, b)&lt;br /&gt;
  File &amp;amp;quot;calc.py&amp;amp;quot;, line 2, in add_two_numbers&lt;br /&gt;
    return int(a) + int(b)&lt;br /&gt;
ValueError: invalid literal for int() with base 10: &#039;a&#039;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== With error handled ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def add_two_numbers(a, b):&lt;br /&gt;
    return int(a) + int(b)&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    a = input(&#039;Write a number: &#039;)&lt;br /&gt;
    b = input(&#039;Write a number: &#039;)&lt;br /&gt;
    try:&lt;br /&gt;
        result = add_two_numbers(a, b)&lt;br /&gt;
    except ValueError:&lt;br /&gt;
        print(&#039;you must type a valid integer!&#039;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(result)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    main()&amp;lt;/source&amp;gt;&lt;br /&gt;
==== With checking before ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def add_two_numbers(a, b):&lt;br /&gt;
    return int(a) + int(b)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    a = input(&#039;Write a number: &#039;)&lt;br /&gt;
    b = input(&#039;Write a number: &#039;)&lt;br /&gt;
    if a.isdigit() and b.isdigit():&lt;br /&gt;
        result = add_two_numbers(a, b)&lt;br /&gt;
        print(result)&lt;br /&gt;
    else: &lt;br /&gt;
        print(&#039;you must type a valid integer!&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    main()&amp;lt;/source&amp;gt;&lt;br /&gt;
= Splats =&lt;br /&gt;
&lt;br /&gt;
* dict as kwargs&lt;br /&gt;
* list as args&lt;br /&gt;
&lt;br /&gt;
== Task: Sum of all arguments ==&lt;br /&gt;
&lt;br /&gt;
=== Solution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def sum_args(*args):&lt;br /&gt;
    return sum(args)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    print(sum_args(1, 3, 5))  # 9&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Pass a list into the function ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def sum_args(*args):&lt;br /&gt;
    return sum(args)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    print(sum_args(*[1, 3, 5]))  # 9&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/testing&amp;diff=118599</id>
		<title>I719 Fundamentals of Python/testing</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=I719_Fundamentals_of_Python/testing&amp;diff=118599"/>
		<updated>2017-03-16T09:01:48Z</updated>

		<summary type="html">&lt;p&gt;Eroman: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Basic Testing =&lt;br /&gt;
&lt;br /&gt;
In the examples, &amp;lt;code&amp;gt;app.py&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;test_app.py&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;__init__.py&amp;lt;/code&amp;gt; are all in the same directory. The tests are ran with the command &amp;lt;code&amp;gt;python3 -m unittest test_app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== check the output of a function ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;def get_hello_world():&lt;br /&gt;
    return &amp;quot;Hello World!&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;test_app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import unittest&lt;br /&gt;
&lt;br /&gt;
from app import get_hello_world&lt;br /&gt;
&lt;br /&gt;
class HelloWorldTestCase(unittest.TestCase):&lt;br /&gt;
    def test_value(self):&lt;br /&gt;
        result = get_hello_world()&lt;br /&gt;
        self.assertEqual(&amp;quot;Hello World!&amp;quot;, result)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Check the side effect of a function ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;class MyPrinter():&lt;br /&gt;
    def __init__(self, value=None):&lt;br /&gt;
        self.value = value&lt;br /&gt;
&lt;br /&gt;
    def print_value(self):&lt;br /&gt;
        print(self.value)&lt;br /&gt;
&lt;br /&gt;
    def set_value(self, value):&lt;br /&gt;
        self.value = value&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;test_app.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import unittest&lt;br /&gt;
&lt;br /&gt;
from app import MyPrinter&lt;br /&gt;
&lt;br /&gt;
class HelloWorldTestCase(unittest.TestCase):&lt;br /&gt;
    def test_value(self):&lt;br /&gt;
        value = &amp;quot;Test Value&amp;quot;&lt;br /&gt;
        my_printer = MyPrinter()&lt;br /&gt;
        my_printer.set_value(value)&lt;br /&gt;
        self.assertEqual(my_printer.value, value)&amp;lt;/source&amp;gt;&lt;br /&gt;
= Advanced Testing =&lt;br /&gt;
&lt;br /&gt;
== Testing the bitcoin price printer ==&lt;br /&gt;
&lt;br /&gt;
You can convert&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
&lt;br /&gt;
def main():&lt;br /&gt;
    r = requests.get(&#039;https://api.coindesk.com/v1/bpi/currentprice.json&#039;)&lt;br /&gt;
    data = r.json()&lt;br /&gt;
    price = data[&#039;bpi&#039;][&#039;EUR&#039;][&#039;rate&#039;]&lt;br /&gt;
    print(price)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    main()&amp;lt;/source&amp;gt;&lt;br /&gt;
to something with a testable function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
&lt;br /&gt;
def get_btc_price():&lt;br /&gt;
    r = requests.get(&#039;https://api.coindesk.com/v1/bpi/currentprice.json&#039;)&lt;br /&gt;
    data = r.json()&lt;br /&gt;
    price = data[&#039;bpi&#039;][&#039;EUR&#039;][&#039;rate&#039;]&lt;br /&gt;
    return price&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    print(get_btc_price())&amp;lt;/source&amp;gt;&lt;br /&gt;
== Writing a Unit test ==&lt;br /&gt;
&lt;br /&gt;
in the same directory, make a file that starts with &amp;lt;code&amp;gt;test_&amp;lt;/code&amp;gt;. So for this example, the file is named &amp;lt;code&amp;gt;test_btc_price.py&amp;lt;/code&amp;gt;. Also ensure an &amp;lt;code&amp;gt;__init__.py&amp;lt;/code&amp;gt; file exists so you can import python modules in this directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;├── btc_price.py&lt;br /&gt;
├── test_btc_price.py&lt;br /&gt;
├── __init__.py&amp;lt;/pre&amp;gt;&lt;br /&gt;
`&amp;lt;br /&amp;gt;&lt;br /&gt;
and then write a unit test on the value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;test_btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import unittest&lt;br /&gt;
&lt;br /&gt;
from btc_price import get_btc_price&lt;br /&gt;
&lt;br /&gt;
class BtcPriceTestCase(unittest.TestCase):&lt;br /&gt;
    def test_price_accurate(self):&lt;br /&gt;
        price = get_btc_price() # The bitcoin returned changes over time!&lt;br /&gt;
        self.assertEqual(price, &#039;1000&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
and run using &amp;lt;code&amp;gt;python3 -m unittest btc_price_test.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This test will fail becuase the price of bitcoins change.&amp;lt;br /&amp;gt;&lt;br /&gt;
so instead check that value is correct in another way.&amp;lt;br /&amp;gt;&lt;br /&gt;
In this example, we check that the string value is floating point, like &amp;lt;code&amp;gt;1,101.12&amp;lt;/code&amp;gt;. This is not as robust as checking if the value is correct. So if the value does not change, do not do this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;btc_price_test.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import unittest&lt;br /&gt;
&lt;br /&gt;
from btc_price import get_btc_price&lt;br /&gt;
&lt;br /&gt;
class BtcPriceTestCase(unittest.TestCase):&lt;br /&gt;
    def test_price_format(self):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;Test price is a string with correct format&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        price = get_btc_price() # The bitcoin returned changes over time!&lt;br /&gt;
        price_without_comma = price.replace(&#039;,&#039;, &#039;&#039;)&lt;br /&gt;
        # if string `price_without_comma` cannot be converted to&lt;br /&gt;
        # a float, then this line will raise an error.&lt;br /&gt;
        # an unhandled error will cause the test to fail.&lt;br /&gt;
        float(price_without_comma)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Testing IO dependent functions without doing the IO ==&lt;br /&gt;
&lt;br /&gt;
In the previous Bitcoin price example, running the test also makes a HTTP request.&lt;br /&gt;
&lt;br /&gt;
This means:&lt;br /&gt;
&lt;br /&gt;
* our test will fail without internet&lt;br /&gt;
* our test will fail if the bitcoin price API changes or is down&lt;br /&gt;
&lt;br /&gt;
You may want to test these things in your test. This would make our unittest more like a functional test.&lt;br /&gt;
&lt;br /&gt;
You can stub out IO functions, and test if the function is correctly written, not that the price API works.&lt;br /&gt;
&lt;br /&gt;
To do this with depedency inject, we must change our original code as well.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
&lt;br /&gt;
# use `requests` by default, but allow another library to be used&lt;br /&gt;
def get_btc_price(request_library=requests):&lt;br /&gt;
    r = request_library.get(&#039;https://api.coindesk.com/v1/bpi/currentprice.json&#039;)&lt;br /&gt;
    data = r.json()&lt;br /&gt;
    price = data[&#039;bpi&#039;][&#039;EUR&#039;][&#039;rate&#039;]&lt;br /&gt;
    return price&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    print(get_btc_price())&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
import requests&lt;br /&gt;
import unittest&lt;br /&gt;
&lt;br /&gt;
MOCK_RESPONSE_BODY =&#039;&#039;&#039;&lt;br /&gt;
{&amp;quot;time&amp;quot;:{&amp;quot;updated&amp;quot;:&amp;quot;Mar 4, 2017 11:00:00 UTC&amp;quot;,&amp;quot;updatedISO&amp;quot;:&amp;quot;2017-03-04T11:00:00+00:00&amp;quot;,&amp;quot;updateduk&amp;quot;:&amp;quot;Mar 4, 2017 at 11:00 GMT&amp;quot;},&amp;quot;disclaimer&amp;quot;:&amp;quot;This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org&amp;quot;,&amp;quot;bpi&amp;quot;:{&amp;quot;USD&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;#36;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,284.8250&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;United States Dollar&amp;quot;,&amp;quot;rate_float&amp;quot;:1284.825},&amp;quot;GBP&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;GBP&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;pound;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,044.8261&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;British Pound Sterling&amp;quot;,&amp;quot;rate_float&amp;quot;:1044.8261},&amp;quot;EUR&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;EUR&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;euro;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,209.5317&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;Euro&amp;quot;,&amp;quot;rate_float&amp;quot;:1209.5317}}}&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
class MockResponse:&lt;br /&gt;
    @staticmethod&lt;br /&gt;
    def json():&lt;br /&gt;
        return json.loads(MOCK_RESPONSE_BODY)&lt;br /&gt;
&lt;br /&gt;
class MockRequests:&lt;br /&gt;
    @staticmethod&lt;br /&gt;
    def get(url):&lt;br /&gt;
        # This will raise an `AssertionError` if the url that the function is called with is different than expected, causing the test to fail&lt;br /&gt;
&lt;br /&gt;
        assert url == &#039;https://api.coindesk.com/v1/bpi/currentprice.json&#039;&lt;br /&gt;
        return MockResponse()&lt;br /&gt;
&lt;br /&gt;
class BtcPriceTestCase(unittest.TestCase):&lt;br /&gt;
    def test_price_accurate(self):&lt;br /&gt;
        # use the stub version for the test&lt;br /&gt;
        price = get_btc_price(request_library=MockRequests())&lt;br /&gt;
        # The value does not change now&lt;br /&gt;
        self.assertEqual(price, &#039;1,209.5317&#039;)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    print(get_btc_price())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
That was a lot of code. Forturnately python 3 has a library for making these mock objects. See https://docs.python.org/3/library/unittest.mock.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;test_btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
import unittest&lt;br /&gt;
&lt;br /&gt;
from unittest.mock import Mock&lt;br /&gt;
&lt;br /&gt;
MOCK_RESPONSE_BODY = &#039;&#039;&#039;&lt;br /&gt;
{&amp;quot;time&amp;quot;:{&amp;quot;updated&amp;quot;:&amp;quot;Mar 4, 2017 11:00:00 UTC&amp;quot;,&amp;quot;updatedISO&amp;quot;:&amp;quot;2017-03-04T11:00:00+00:00&amp;quot;,&amp;quot;updateduk&amp;quot;:&amp;quot;Mar 4, 2017 at 11:00 GMT&amp;quot;},&amp;quot;disclaimer&amp;quot;:&amp;quot;This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org&amp;quot;,&amp;quot;bpi&amp;quot;:{&amp;quot;USD&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;#36;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,284.8250&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;United States Dollar&amp;quot;,&amp;quot;rate_float&amp;quot;:1284.825},&amp;quot;GBP&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;GBP&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;pound;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,044.8261&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;British Pound Sterling&amp;quot;,&amp;quot;rate_float&amp;quot;:1044.8261},&amp;quot;EUR&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;EUR&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;euro;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,209.5317&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;Euro&amp;quot;,&amp;quot;rate_float&amp;quot;:1209.5317}}}&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class BtcPriceTestCase(unittest.TestCase):&lt;br /&gt;
    def test_price_accurate(self):&lt;br /&gt;
        # generate the mocks in the test function scope&lt;br /&gt;
        mock_response = Mock()&lt;br /&gt;
        mock_response.json = Mock(return_value=json.loads(MOCK_RESPONSE_BODY))&lt;br /&gt;
&lt;br /&gt;
        mock_requests = Mock()&lt;br /&gt;
        mock_requests.get = Mock(return_value=mock_response)&lt;br /&gt;
        price = get_btc_price(request_library=mock_requests)&lt;br /&gt;
        # The value does not change now&lt;br /&gt;
        self.assertEqual(price, &#039;1,209.5317&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
== Patch ==&lt;br /&gt;
&lt;br /&gt;
But we still had to change our function to support a changeable &#039;requests_library&#039;. This is okay as well, and is normal in some languages. The practice is called Dependency Injection, and is used with object oriented design. But often in python, people will &#039;patch&#039; a function when it is ran in a testing environment. This changes the body of the function in runtime.&lt;br /&gt;
&lt;br /&gt;
see https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;test_btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import json&lt;br /&gt;
import unittest&lt;br /&gt;
from unittest.mock import Mock, patch&lt;br /&gt;
&lt;br /&gt;
from btc_price import get_btc_price&lt;br /&gt;
&lt;br /&gt;
MOCK_RESPONSE_BODY = &#039;&#039;&#039;&lt;br /&gt;
{&amp;quot;time&amp;quot;:{&amp;quot;updated&amp;quot;:&amp;quot;Mar 4, 2017 11:00:00 UTC&amp;quot;,&amp;quot;updatedISO&amp;quot;:&amp;quot;2017-03-04T11:00:00+00:00&amp;quot;,&amp;quot;updateduk&amp;quot;:&amp;quot;Mar 4, 2017 at 11:00 GMT&amp;quot;},&amp;quot;disclaimer&amp;quot;:&amp;quot;This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org&amp;quot;,&amp;quot;bpi&amp;quot;:{&amp;quot;USD&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;USD&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;#36;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,284.8250&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;United States Dollar&amp;quot;,&amp;quot;rate_float&amp;quot;:1284.825},&amp;quot;GBP&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;GBP&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;pound;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,044.8261&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;British Pound Sterling&amp;quot;,&amp;quot;rate_float&amp;quot;:1044.8261},&amp;quot;EUR&amp;quot;:{&amp;quot;code&amp;quot;:&amp;quot;EUR&amp;quot;,&amp;quot;symbol&amp;quot;:&amp;quot;&amp;amp;euro;&amp;quot;,&amp;quot;rate&amp;quot;:&amp;quot;1,209.5317&amp;quot;,&amp;quot;description&amp;quot;:&amp;quot;Euro&amp;quot;,&amp;quot;rate_float&amp;quot;:1209.5317}}}&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
class BtcPriceTestCase(unittest.TestCase):&lt;br /&gt;
    def test_price_accurate(self):&lt;br /&gt;
        # generate the mocks in the test function scope&lt;br /&gt;
        mock_response = Mock()&lt;br /&gt;
        mock_response.json = Mock(return_value=json.loads(MOCK_RESPONSE_BODY))&lt;br /&gt;
&lt;br /&gt;
        mock_requests = Mock()&lt;br /&gt;
        mock_requests.get = Mock(return_value=mock_response)&lt;br /&gt;
        with patch(&#039;btc_price.requests&#039;, mock_requests):&lt;br /&gt;
            price = get_btc_price()&lt;br /&gt;
        # The value does not change now&lt;br /&gt;
        self.assertEqual(price, &#039;1,209.5317&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And you can omit the keyword argument for &amp;lt;code&amp;gt;request_library&amp;lt;/code&amp;gt;, reverting to the original script&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;btc_price.py&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;import requests&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def get_btc_price():&lt;br /&gt;
    r = requests.get(&#039;https://api.coindesk.com/v1/bpi/currentprice.json&#039;)&lt;br /&gt;
    data = r.json()&lt;br /&gt;
    price = data[&#039;bpi&#039;][&#039;EUR&#039;][&#039;rate&#039;]&lt;br /&gt;
    return price&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    print(get_btc_price())&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= check the print value =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import unittest&lt;br /&gt;
from unittest.mock import Mock, patch&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def print_hello():&lt;br /&gt;
    print(&#039;Hello&#039;)&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
class PrintHelloTestCase(unittest.TestCase):&lt;br /&gt;
    @patch(&amp;quot;builtins.print&amp;quot;,autospec=True)&lt;br /&gt;
    def test_somethingelse(self, mock_print):&lt;br /&gt;
        print_hello()&lt;br /&gt;
        mock_print.assert_called_with(&amp;quot;Hello&amp;quot;)&lt;br /&gt;
    &lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    print_hello()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Eroman</name></author>
	</entry>
</feed>