I719 Fundamentals of Python: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 5: Line 5:
== Contact ==
== Contact ==


My email is [mailto:eroman@itcollege.ee eroman@itcollege.ee]
My email is eroman@itcollege.ee
 
== You ==
 
https://goo.gl/forms/KhjvJcN1T1ANd78g2


= Frequently Asked Questions =
= Frequently Asked Questions =
Line 50: Line 46:
=== Test dates ===
=== Test dates ===


Primary date: Thursday March 23rd, starting at 8:15AM
Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM


Makeup date 1: in june, TBA
Makeup date 1: 01.06.2017 10:00-11:30 410


Makeup date 2: in august, TBA
Makeup date 2: in august, TBA
Line 116: Line 112:
== Project due date ==
== Project due date ==


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.
The project deadline system will be announced soon.
 
To present your project, come at 10:00AM on the last day of class (Thursday, March 23rd)


== Project Requirements ==
== Project Requirements ==
Line 163: Line 157:
include a <code>.gitignore</code> file in the root directory of your project. This will prevent <code>.pyc</code> and <code>__pycache__</code> from being added to your git project.
include a <code>.gitignore</code> file in the root directory of your project. This will prevent <code>.pyc</code> and <code>__pycache__</code> from being added to your git project.


You can save this file as <code>.gitignore</code>:<br />
You can save this file as <code>.gitignore</code>: https://github.com/github/gitignore/blob/master/Python.gitignore
https://github.com/github/gitignore/blob/master/Python.gitignore


= Lecture Notes =
= Lecture Notes =
Line 177: Line 170:


== Lecture 1 ==
== Lecture 1 ==
Running python, integers, booleans, strings, lists, <code>for</code> and <code>if</code>, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2
Old lecture notes:


Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1
Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1
Line 206: Line 203:
== Lecture 6 ==
== Lecture 6 ==


List and Dictionary transformations and manipulations. Intro to numpy with linear algebra and intro to pandas with extracting data from a csv.<br />
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
https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture6


== Lecture 7 ==
== Lecture 7 ==

Revision as of 15:46, 7 April 2017

About

This class is python for beginners, taught Spring 2017

Contact

My email is eroman@itcollege.ee

Frequently Asked Questions

What should I know already

It would be good to know:

  • How to use the unix command line
  • GIT

What editor/IDE should I use?

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.

What python version are we using?

I will teach using python 3

What books/resources do you recommend?

This page contains most of python's syntax: https://learnxinyminutes.com/docs/python3/

What software do I need to install?

You only need python 3 and an editor.

I recommend that you install an interactive python shell, like IPython1 or bpython2

Grading

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.

Test

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.

You may use the internet during the exam.

Test dates

Primary date: Thursday March 23rd, starting at 8:15AM Primary date for class 2: May 25th, starting at 8:15AM

Makeup date 1: 01.06.2017 10:00-11:30 410

Makeup date 2: in august, TBA

Test topics

Example problem

from unittest import TestCase


class StringCountTestCase(TestCase):
    """
    Write a function that for any string, prepends 'Hello '
    >>> test_function('Bob')
    'Hello Bob'
    """
    def setUp(self):
        self.test_function = None  # Assign to your function

    def test_sally(self):
        result = self.test_function('Sally')
        self.assertEqual(result, 'Hello Sally')

Example solution

python3 -m unittest exam.py

from unittest import TestCase

def prepend_hello(string):
    return "Hello {}".format(string)


class StringCountTestCase(TestCase):
    """
    Write a function that for any string, prepends 'Hello '
    >>> test_function('Bob')
    'Hello Bob'
    """
    def setUp(self):
        self.test_function = prepend_hello

    def test_sally(self):
        result = self.test_function('Sally')
        self.assertEqual(result, 'Hello Sally')

Practice Test

https://gist.github.com/evrom/4f8158b2613cb80c5050e7315fa309cc

Real Test for 23/03/17

https://gist.github.com/evrom/d948b56afe9a41aa2c18b8a3094eddad

Project due date

The project deadline system will be announced soon.

Project Requirements

  • it can do something
  • it uses version control
    • it has more than one commit
    • it has commit messages that are relevant to the commit
  • it has a relevant unit test
  • it has a README that describes what it does and how to run it.

Project idea examples

  • a game
  • exploring a technology like image recognition
  • a command line tool that does something
  • a web application in python
    • Flask is simple and has good documentation for building a website
    • for a website that would require users to sign up and login, consider Django
  • a web scraper
  • many websites have HTTP APIs that can give you data, you can make something that uses data from public APIs.

If you want to do things with cryptography

  • a cryptographic chat app
  • a password storage bank like KeePassX

Can I ...?

Can I use python 2?

Yes

Can I use external libraries outside of the standard library?

Yes

If you use external libraries, include a requirements.txt or setup.py which has a list of packages required by your project

Project Tips

.gitignore

include a .gitignore file in the root directory of your project. This will prevent .pyc and __pycache__ from being added to your git project.

You can save this file as .gitignore: https://github.com/github/gitignore/blob/master/Python.gitignore

Lecture Notes

Recordings

recordings are found here: https://echo360.e-ope.ee/ess/portal/section/fc0c6bfd-9187-4365-b2c9-0085b3a89906

Testing Python Code

https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/testing

Lecture 1

Running python, integers, booleans, strings, lists, for and if, functions https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1v2

Old lecture notes:

Basic types, lists, for-loops, functions, imports and classes https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture1

Lecture 2

importable modules, unit tests, dictionaries https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture2

Lecture 3

Command line arguements, opening and using files, csv files https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture3

Assets

file to count words in: http://pastebin.com/3faqcc5j csv file: https://docs.google.com/spreadsheets/d/1uSbHeppEyKNxF0WncvhxTBF8wj_co0v5XOYlXKLL8Lg/edit?usp=sharing

Lecture 4

Exceptions, slices, Http request to get JSON data, Basic dynamic website https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture4

Lecture 5

Advanced testing, datetime, python style guide. https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture5

survey

https://docs.google.com/forms/d/e/1FAIpQLSeCu0boQIBbRsCcgLovm0Jis3JLYnjD8JhCBlh4nQUPpF6N1Q/viewform

Lecture 6

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

Lecture 7

Reduce function, using break and return for control flow, handling user input, handling errors

https://wiki.itcollege.ee/index.php/I719_Fundamentals_of_Python/lecture7