forked from tdwojak/Python2017
Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017
This commit is contained in:
commit
ba9dc1422a
124
homeworks/main.py
Executable file
124
homeworks/main.py
Executable file
@ -0,0 +1,124 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import git
|
||||||
|
import os
|
||||||
|
import importlib
|
||||||
|
import collections
|
||||||
|
import csv
|
||||||
|
|
||||||
|
logger = logging.getLogger('Homeworks')
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
fm = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
ch = logging.StreamHandler()
|
||||||
|
ch.setFormatter(fm)
|
||||||
|
logger.addHandler(ch)
|
||||||
|
|
||||||
|
|
||||||
|
def arg_parse():
|
||||||
|
parser = argparse.ArgumentParser(description='Framework for checking homeworks.')
|
||||||
|
parser.add_argument('-i', '--ids', type=str,
|
||||||
|
help='path to a file with student ids.')
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
def get_ids(path):
|
||||||
|
ids = []
|
||||||
|
with open(path) as _file:
|
||||||
|
for line in _file:
|
||||||
|
ids.append(line.strip().split(' ')[::2])
|
||||||
|
return ids
|
||||||
|
|
||||||
|
|
||||||
|
def clone_repo(username, repo_name):
|
||||||
|
repo = "https://git.wmi.amu.edu.pl/{}/{}.git".format(username, repo_name)
|
||||||
|
dest = "./Python2017-{}".format(username)
|
||||||
|
if os.path.exists(dest):
|
||||||
|
logger.debug("{}: repo exests.".format(username))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
git.Repo.clone_from(repo, dest)
|
||||||
|
except git.GitCommandError:
|
||||||
|
logger.info("Repository '{}' does not exist".format(repo))
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def check_tasks(username, repo_name, tasks):
|
||||||
|
logger.debug("Marking user: {}".format(username))
|
||||||
|
scores = collections.defaultdict(dict)
|
||||||
|
for lab in tasks:
|
||||||
|
path = os.path.realpath("./Python2017-{}/{}".format(username, lab))
|
||||||
|
for task, fun in tasks[lab]:
|
||||||
|
task_file = path + "/{}". format(task)
|
||||||
|
logger.debug(task_file)
|
||||||
|
package = 'Python2017-{}.{}.{}'.format(username, lab, task)
|
||||||
|
lib = importlib.import_module(package)
|
||||||
|
tested_fun = getattr(lib, fun)
|
||||||
|
tests = getattr(lib, 'tests')
|
||||||
|
try:
|
||||||
|
test_result = tests(tested_fun)
|
||||||
|
except Exception:
|
||||||
|
test_result = "FAILED"
|
||||||
|
|
||||||
|
if test_result == 'TESTS PASSED':
|
||||||
|
scores[lab][task] = 1
|
||||||
|
else:
|
||||||
|
scores[lab][task] = 0
|
||||||
|
return scores
|
||||||
|
|
||||||
|
def get_fieldnames(tasks):
|
||||||
|
fieldnames = ['ID']
|
||||||
|
for lab in tasks:
|
||||||
|
for task, _ in tasks[lab]:
|
||||||
|
fieldnames.append('{}:{}'.format(lab, task))
|
||||||
|
return fieldnames
|
||||||
|
|
||||||
|
def parse_scores(fieldnames, uname, scores):
|
||||||
|
out = {}
|
||||||
|
for name in fieldnames:
|
||||||
|
if name == 'ID':
|
||||||
|
out[name] = uname
|
||||||
|
continue
|
||||||
|
lab, task = name.split(':')
|
||||||
|
out[name] = scores[lab][task]
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def write_scores(scores, filename, tasks):
|
||||||
|
fieldnames = get_fieldnames(tasks)
|
||||||
|
|
||||||
|
with open(filename, 'w') as results:
|
||||||
|
writer = csv.DictWriter(results, fieldnames, restval=0)
|
||||||
|
writer.writeheader()
|
||||||
|
for student in scores:
|
||||||
|
writer.writerow(parse_scores(fieldnames, student, scores[student]))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
""" main """
|
||||||
|
options = arg_parse()
|
||||||
|
ids = get_ids(options.ids)
|
||||||
|
logger.info("Liczba studentów: {}".format(len(ids)))
|
||||||
|
scores = {}
|
||||||
|
|
||||||
|
tasks = {
|
||||||
|
'labs02' : [
|
||||||
|
('task07', 'char_sum'),
|
||||||
|
('task08', 'sum_div35'),
|
||||||
|
('task09', 'leet_speak'),
|
||||||
|
('task10', 'pokemon_speak'),
|
||||||
|
('task11', 'common_chars')
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
for repo_id in ids:
|
||||||
|
st_uname = repo_id[0]
|
||||||
|
repo_name = repo_id[-1]
|
||||||
|
if clone_repo(st_uname, repo_name):
|
||||||
|
scores[st_uname] = check_tasks(st_uname, repo_name, tasks)
|
||||||
|
write_scores(scores, 'results.csv', tasks)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
25
homeworks/results.md
Normal file
25
homeworks/results.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11 | labs03 | labs04 | labs06 |
|
||||||
|
---------|-----------------|-----------------|-----------------|-----------------|-----------------|----------|----------|----------|
|
||||||
|
s45146 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | |
|
||||||
|
s45147 | 1 | 0 | 0 | 1 | 0 | 4 | 5 | |
|
||||||
|
s45148 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | |
|
||||||
|
s45150 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | |
|
||||||
|
s45151 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | |
|
||||||
|
s45152 | 1 | 1 | 1 | 0 | 1 | 0 | 5 | |
|
||||||
|
s45153 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
|
||||||
|
s45155 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | |
|
||||||
|
s45157 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | |
|
||||||
|
s45156 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | |
|
||||||
|
s45158 | 1 | 1 | 0 | 0 | 1 | 4 | 5 | |
|
||||||
|
s45159 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | |
|
||||||
|
s45160 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | |
|
||||||
|
s45161 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | |
|
||||||
|
s45162 | 1 | 1 | 1 | 1 | 1 | 2 | 5 | |
|
||||||
|
s45163 | 1 | 1 | 1 | 1 | 1 | | 4 | |
|
||||||
|
s45164 | 1 | 1 | 0 | 1 | 0 | 0 | 5 | |
|
||||||
|
s45165 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | |
|
||||||
|
s45166 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | |
|
||||||
|
s45167 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | |
|
||||||
|
s45168 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
|
||||||
|
s45452 | 1 | 1 | 1 | 1 | 1 | 1 | 4 | |
|
||||||
|
szwedek | 1 | 1 | 1 | 1 | 1 | 2 | 5 | |
|
297
labs05/Lab05.ipynb
Normal file
297
labs05/Lab05.ipynb
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"# Python: część 3\n",
|
||||||
|
"\n",
|
||||||
|
"## Tomasz Dwojak\n",
|
||||||
|
"\n",
|
||||||
|
"### 16 grudnia 2017"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"## Co już było?\n",
|
||||||
|
" * podstawowe typy i struktury danych\n",
|
||||||
|
" * funkcje\n",
|
||||||
|
" * biblioteki\n",
|
||||||
|
" * klasy\n",
|
||||||
|
" * praca z plikami\n",
|
||||||
|
" * wyjątki"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"# Co na dziś?\n",
|
||||||
|
" * Dzielenie kodu na pliki\n",
|
||||||
|
" * Podstawy analizy danych: Pandas"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"## Dzielenie kodu\n",
|
||||||
|
"\n",
|
||||||
|
" * Zwiększenie jakości kodu\n",
|
||||||
|
" * Napisz raz i korzystaj w wielu sytuacjach\n",
|
||||||
|
" * Tworzenie własnej biblioteki"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"## Dzielenie kodu - podsumowanie\n",
|
||||||
|
" * import\n",
|
||||||
|
" * ``if __name__ == '__main__'``\n",
|
||||||
|
" * Pakiety i pliki ``__init__.py``\n",
|
||||||
|
" * zmienna PYTHONPATH i ``sys.path``"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"# Interpreter Pythona"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"# Jupyter notebook"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"## Argumenty do programu\n",
|
||||||
|
"\n",
|
||||||
|
" * czy potrzebujemy pyCharm żeby uruchomić prosty skrypt?"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"### sys.argv\n",
|
||||||
|
" * zawiera liste wszystkich argumentów\n",
|
||||||
|
" * pierwszy element zawiera nazwe pliku"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "fragment"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"['/usr/lib/python2.7/site-packages/ipykernel/__main__.py', '-f', '/run/user/1000/jupyter/kernel-7efdb6ca-75d5-474e-90c4-fda3dadc3282.json']\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import sys\n",
|
||||||
|
"print(sys.argv)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"### Biblioteka argparse"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "fragment"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import argparse\n",
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.parse_args()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.add_argument(\"number\", help=\"Opis\")\n",
|
||||||
|
"args = parser.parse_args()\n",
|
||||||
|
"print(args.number)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.add_argument(\"number\", help=\"Opis\", nargs=\"+\")\n",
|
||||||
|
"args = parser.parse_args()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.add_argument(\"--verbosity\", help=\"increase output verbosity\")\n",
|
||||||
|
"args = parser.parse_args()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.add_argument(\"--verbose\", help=\"increase output verbosity\",\n",
|
||||||
|
" action=\"store_true\")\n",
|
||||||
|
"args = parser.parse_args()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.add_argument(\"-v\", \"--verbose\", help=\"increase output verbosity\",\n",
|
||||||
|
" action=\"store_true\")\n",
|
||||||
|
"args = parser.parse_args()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true,
|
||||||
|
"slideshow": {
|
||||||
|
"slide_type": "slide"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"parser = argparse.ArgumentParser()\n",
|
||||||
|
"parser.add_argument(\"-v\", \"--verbose\", help=\"increase output verbosity\",\n",
|
||||||
|
" action=\"store_true\")\n",
|
||||||
|
"parser.add_argument(\"number\", help=\"Opis\", nargs=\"+\")\n",
|
||||||
|
"args = parser.parse_args()"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"celltoolbar": "Slideshow",
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 2",
|
||||||
|
"language": "python2",
|
||||||
|
"name": "python2"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython2",
|
||||||
|
"version": "2.7.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
20
labs05/README.md
Normal file
20
labs05/README.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
** zad. 0 **
|
||||||
|
Napisz funkcję ``suma``, która przyjmnie jeden argument: listę liczb i zwróci ich sumę.
|
||||||
|
|
||||||
|
** zad. 1 **
|
||||||
|
Zaimportuj z zadania 0 fukcje ``suma``. Korzystając z tej fukcji i tablicy ``sys.argv`` oblicz i wyświetl sumę argumentów, jakie zostały przekazane do proramu. Załóź, że argumentami do programu będą tylko liczby zmiennoprzecinkowe.
|
||||||
|
|
||||||
|
** zad. 2 **
|
||||||
|
Uodpornoj program z zad. 1 w następujący sposób: do programu mogą zostać przekazane argumenty, które nie mają wartości liczbowej (przyjmijmy, że ich wartość to 0). Skorzystaj z mechanizmu wyjątków: złap wyjątek, jeżeli argumenty nie da się skonwertować na liczbę zmiennoprzecinkową.
|
||||||
|
|
||||||
|
** zad. 3 **
|
||||||
|
Przekształć rozwiązanie zadania drugiego w taki sposob, żeby korzystało z biblioteki ``argparse`` zamiast z z listy ``sys.argv``.
|
||||||
|
|
||||||
|
** zad. 4 (Domowe) **
|
||||||
|
Plik ``task04.py`` zawiera kod prorgamu, który działa jak popularne narzędzie unixowe ``wc`` (Word Counter): zlicza liczbę linii, wyrazów i znaków. Aktualnie program potrafi działać wyłącznie na wejściu podanym z klawiatury. Dodaj do niego opcje programu:
|
||||||
|
* domyślnie program ma zliczać na wejściu z klawiatury (stdin) i wyświetlać wszystkie 3 liczby.
|
||||||
|
* Jeżeli został podany przełącznik `-l`, to to ma zostać zwrócona tylko liczba linii.
|
||||||
|
* Jeżeli został podany przełącznik `-w`, to to ma zostać zwrócona tylko liczba słów.
|
||||||
|
* Jeżeli został podany przełącznik `-c`, to to ma zostać zwrócona tylko liczba znaków.
|
||||||
|
* Jeżeli został podany inny argument, to należy założyć że jest to nazwa pliku i potraktować ten plik jako wejście do programu.
|
||||||
|
|
0
labs05/__init__.py
Normal file
0
labs05/__init__.py
Normal file
29
labs05/argparse_min.py
Normal file
29
labs05/argparse_min.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.parse_args()
|
||||||
|
|
||||||
|
# parser = argparse.ArgumentParser()
|
||||||
|
# parser.add_argument("number", help="Opis")
|
||||||
|
# args = parser.parse_args()
|
||||||
|
|
||||||
|
# parser = argparse.ArgumentParser()
|
||||||
|
# parser.add_argument("number", help="Opis", nargs="+")
|
||||||
|
# args = parser.parse_args()
|
||||||
|
|
||||||
|
# parser = argparse.ArgumentParser()
|
||||||
|
# parser.add_argument("--verbosity", help="increase output verbosity")
|
||||||
|
# args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
# parser = argparse.ArgumentParser()
|
||||||
|
# parser.add_argument("--verbose", help="increase output verbosity",
|
||||||
|
# action="store_true")
|
||||||
|
# args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
# parser = argparse.ArgumentParser()
|
||||||
|
# parser.add_argument("-v", "--verbose", help="increase output verbosity",
|
||||||
|
# action="store_true")
|
||||||
|
# parser.add_argument("number", help="Opis", nargs="+")
|
||||||
|
# args = parser.parse_args()
|
11
labs05/lib.py
Normal file
11
labs05/lib.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def greetings():
|
||||||
|
print("Pozdrowienia!!!")
|
||||||
|
|
||||||
|
print("SPAM " * 6)
|
||||||
|
print(__name__)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("Jestem głównym plikiem!")
|
18
labs05/main.py
Normal file
18
labs05/main.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import lib
|
||||||
|
import tools.fib
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# sys.path.append("..")
|
||||||
|
# import labs02.task01
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Hello World")
|
||||||
|
lib.greetings()
|
||||||
|
print(tools.fib.non_reccurent_fibonacci(50))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
11
labs05/task00.py
Normal file
11
labs05/task00.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def suma(liczby):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print(summa([1, 2, 3, 4]))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
0
labs05/task01.py
Normal file
0
labs05/task01.py
Normal file
0
labs05/task02.py
Normal file
0
labs05/task02.py
Normal file
0
labs05/task03.py
Normal file
0
labs05/task03.py
Normal file
39
labs05/task04.py
Normal file
39
labs05/task04.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Implementacja narzedzia ``wc`` z linuksa (word counter).
|
||||||
|
Zwraca liczbę słów, znaków i linii.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def count_lines(text):
|
||||||
|
""" return number of lines. """
|
||||||
|
return len(text.strip().split('\n'))
|
||||||
|
|
||||||
|
def count_words(text):
|
||||||
|
""" return number of words. """
|
||||||
|
return sum([len([1 for word in line.split(' ') if len(word)])
|
||||||
|
for line in text.split('\n')])
|
||||||
|
|
||||||
|
def count_chars(text):
|
||||||
|
""" return number of words. """
|
||||||
|
return len(text)
|
||||||
|
|
||||||
|
def wc(text):
|
||||||
|
""" proper wc """
|
||||||
|
lines = count_lines(text)
|
||||||
|
words = count_words(text)
|
||||||
|
chars = count_chars(text)
|
||||||
|
return lines, words, chars
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
""" main """
|
||||||
|
print(wc(sys.stdin.read()))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
0
labs05/tools/__init__.py
Normal file
0
labs05/tools/__init__.py
Normal file
38
labs05/tools/fib.py
Normal file
38
labs05/tools/fib.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Obliczenie n-tego wyrazu ciągu fibonacciego na dwa sposoby.
|
||||||
|
1. Naiwna rekurencja: podstawienie do wzoru.
|
||||||
|
2. Wersja z cachem: każdy wyraz jest obliczany dokładnie raz.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def naive_fibonacci(n):
|
||||||
|
if n <= 0:
|
||||||
|
return 0
|
||||||
|
if n in [1,2]:
|
||||||
|
return 1
|
||||||
|
return naive_fibonacci(n-1) + naive_fibonacci(n-2)
|
||||||
|
|
||||||
|
|
||||||
|
def cache_fibonacci(n, cache=None):
|
||||||
|
if cache is None:
|
||||||
|
cache = [None for i in range(n+1)]
|
||||||
|
cache[0] = 0
|
||||||
|
cache[1] = cache[2] = 1
|
||||||
|
return cache_fibonacci(n, cache)
|
||||||
|
else:
|
||||||
|
if cache[n] is not None:
|
||||||
|
return cache[n]
|
||||||
|
else:
|
||||||
|
cache[n] = cache_fibonacci(n-1, cache) + cache_fibonacci(n-2, cache)
|
||||||
|
return cache[n]
|
||||||
|
|
||||||
|
def non_reccurent_fibonacci(n):
|
||||||
|
cache = [None for i in range(n+1)]
|
||||||
|
cache[0] = 0
|
||||||
|
cache[1] = cache[2] = 1
|
||||||
|
for i in range(2, n + 1):
|
||||||
|
cache[i] = cache[i-1] + cache[i-2]
|
||||||
|
return cache[n]
|
||||||
|
|
874
labs06/Pandas.ipynb
Normal file
874
labs06/Pandas.ipynb
Normal file
File diff suppressed because one or more lines are too long
18
labs06/README.md
Normal file
18
labs06/README.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
## Zadania
|
||||||
|
|
||||||
|
** zad. 0 **
|
||||||
|
Sprawdź, czy masz zainstalowany pakiet ``pandas``. Jeżeli nie, zainstaluj go.
|
||||||
|
|
||||||
|
** zad. 2 (domowe) **
|
||||||
|
Jest to zadanie złożone, składające się z kilku części. Całość będzie opierać się o dane zawarte w pliku *mieszkania.csv* i dotyczą cen mieszkań w Poznaniu kilka lat temu.
|
||||||
|
1, Otwórz plik ``task02.py``, który zawiera szkielet kodu, który będziemy rozwijać w tym zadaniu.
|
||||||
|
1. Napisz funkcje, która wczyta zestaw danych z pliku *mieszkania.csv* i zwróci obiekt typu *DataFrame*. Jeżeli wszystko zostało zrobione poprawnie, powinno się wyśtwietlić 5 pierwszych wierszy.
|
||||||
|
1. Uzupełnij funkcję ``most_common_room_number``, która zwróci jaka jest najpopularniejsza liczba pokoi w ogłoszeniach. Funkcji powinna zwrócić liczbę całkowitą.
|
||||||
|
1. Uzupełnij kod w funkcji ``cheapest_flats(dane, n)``, która wzróci *n* najtańszych ofert mieszkań. Wzrócony obiekt typu ``DataFrame``.
|
||||||
|
1. Napisz funkcje ``find_borough(desc)``, która przyjmuje 1 argument typu *string* i zwróci jedną z dzielnic zdefiniowaną w liście ``dzielnice``. Funkcja ma zwrócić pierwszą (wzgledem kolejności) nazwę dzielnicy, która jest zawarta w ``desc``. Jeżeli żadna nazwa nie została odnaleziona, zwróć *Inne*.
|
||||||
|
1. Dodaj kolumnę ``Borough``, która będzie zawierać informacje o dzielnicach i powstanie z kolumny ``Localization``. Wykorzystaj do tego funkcję ``find_borough``.
|
||||||
|
1. Uzupełnił funkcje ``write_plot``, która zapisze do pliku ``filename`` wykres słupkowy przedstawiający liczbę ogłoszeń mieszkań z podziałem na dzielnice.
|
||||||
|
1. Napisz funkcje ``mean_price``, która zwróci średnią cenę mieszkania ``room_numer``-pokojowego.
|
||||||
|
1. Uzupełnij funkcje ``find_13``, która zwróci listę dzielnic, które zawierają ofertę mieszkanie na 13 piętrze.
|
||||||
|
1. Napisz funkcje ``find_best_flats``, która zwróci wszystkie ogłoszenia mieszkań, które znajdują się na Winogradach, mają 3 pokoje i są położone na 1 piętrze.
|
||||||
|
1. *(dodatkowe)*: Korzystając z pakietu *sklearn* zbuduj model regresji liniowej, która będzie wyznaczać cenę mieszkania na podstawie wielkości mieszkania i liczby pokoi.
|
311
labs06/bikes.csv
Normal file
311
labs06/bikes.csv
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
Date;Berri 1;Brébeuf (données non disponibles);Côte-Sainte-Catherine;Maisonneuve 1;Maisonneuve 2;du Parc;Pierre-Dupuy;Rachel1;St-Urbain (données non disponibles)
|
||||||
|
01/01/2012;35;;0;38;51;26;10;16;
|
||||||
|
02/01/2012;83;;1;68;153;53;6;43;
|
||||||
|
03/01/2012;135;;2;104;248;89;3;58;
|
||||||
|
04/01/2012;144;;1;116;318;111;8;61;
|
||||||
|
05/01/2012;197;;2;124;330;97;13;95;
|
||||||
|
06/01/2012;146;;0;98;244;86;4;75;
|
||||||
|
07/01/2012;98;;2;80;108;53;6;54;
|
||||||
|
08/01/2012;95;;1;62;98;64;11;63;
|
||||||
|
09/01/2012;244;;2;165;432;198;12;173;
|
||||||
|
10/01/2012;397;;3;238;563;275;18;241;
|
||||||
|
11/01/2012;273;;0;182;443;258;12;194;
|
||||||
|
12/01/2012;157;;1;134;261;137;9;63;
|
||||||
|
13/01/2012;75;;0;41;105;64;2;0;
|
||||||
|
14/01/2012;32;;0;54;56;19;0;1;
|
||||||
|
15/01/2012;54;;0;33;60;18;0;0;
|
||||||
|
16/01/2012;168;;2;136;312;137;1;0
|
||||||
|
17/01/2012;155;;0;86;256;74;0;0
|
||||||
|
18/01/2012;139;;0;66;188;68;3;0
|
||||||
|
19/01/2012;191;;1;104;248;79;3;0
|
||||||
|
20/01/2012;161;;4;96;217;67;1;1
|
||||||
|
21/01/2012;53;;0;47;70;32;1;0
|
||||||
|
22/01/2012;71;;0;41;73;35;5;0
|
||||||
|
23/01/2012;210;;6;114;357;91;6;0
|
||||||
|
24/01/2012;299;;1;189;444;174;4;0
|
||||||
|
25/01/2012;334;;1;217;453;180;4;0
|
||||||
|
26/01/2012;306;;0;215;495;191;0;1
|
||||||
|
27/01/2012;91;;5;79;204;65;0;0
|
||||||
|
28/01/2012;80;;1;61;123;33;9;1
|
||||||
|
29/01/2012;87;;1;65;132;40;7;0
|
||||||
|
30/01/2012;219;;0;146;371;152;2;0
|
||||||
|
31/01/2012;186;;1;109;324;122;0;0
|
||||||
|
01/02/2012;138;;0;100;271;71;5;0
|
||||||
|
02/02/2012;217;;5;134;345;128;2;2
|
||||||
|
03/02/2012;174;;1;103;301;111;1;1
|
||||||
|
04/02/2012;84;;0;53;119;44;8;0
|
||||||
|
05/02/2012;72;;0;46;133;54;7;0
|
||||||
|
06/02/2012;248;;1;136;425;167;10;0
|
||||||
|
07/02/2012;316;;0;209;516;225;9;0
|
||||||
|
08/02/2012;271;;0;202;503;215;4;1
|
||||||
|
09/02/2012;342;;0;227;471;231;11;0
|
||||||
|
10/02/2012;303;;1;206;478;216;6;2
|
||||||
|
11/02/2012;71;;0;63;112;49;3;0
|
||||||
|
12/02/2012;78;;0;36;91;53;5;0
|
||||||
|
13/02/2012;211;;0;175;408;207;4;0
|
||||||
|
14/02/2012;318;;0;186;504;243;9;1
|
||||||
|
15/02/2012;307;;0;180;491;232;5;1
|
||||||
|
16/02/2012;386;;1;212;569;295;10;0
|
||||||
|
17/02/2012;332;;3;237;496;260;11;1
|
||||||
|
18/02/2012;220;;1;159;280;134;30;0
|
||||||
|
19/02/2012;169;;3;110;205;113;13;2
|
||||||
|
20/02/2012;303;;2;224;470;243;14;10
|
||||||
|
21/02/2012;441;;5;292;503;286;10;6
|
||||||
|
22/02/2012;375;;10;263;501;264;12;3
|
||||||
|
23/02/2012;397;;10;293;528;329;22;13
|
||||||
|
24/02/2012;243;;4;187;313;137;4;13
|
||||||
|
25/02/2012;62;;0;48;52;18;2;5
|
||||||
|
26/02/2012;78;;0;76;47;35;4;0
|
||||||
|
27/02/2012;119;;4;94;298;134;3;5
|
||||||
|
28/02/2012;195;;0;158;350;168;9;3
|
||||||
|
29/02/2012;242;;0;164;446;190;7;4
|
||||||
|
01/03/2012;92;;0;56;199;63;0;14
|
||||||
|
02/03/2012;143;;0;56;283;77;7;1
|
||||||
|
03/03/2012;82;;0;65;133;47;2;0
|
||||||
|
04/03/2012;107;;2;79;138;60;15;0
|
||||||
|
05/03/2012;155;;1;114;363;157;8;2
|
||||||
|
06/03/2012;269;;0;192;437;170;10;0
|
||||||
|
07/03/2012;438;;3;290;715;266;28;0
|
||||||
|
08/03/2012;348;;6;238;530;270;9;9
|
||||||
|
09/03/2012;371;;8;279;575;268;8;38
|
||||||
|
10/03/2012;182;;13;162;296;165;0;58
|
||||||
|
11/03/2012;380;;60;253;540;289;0;285
|
||||||
|
12/03/2012;802;;179;618;1265;747;0;548
|
||||||
|
13/03/2012;442;;145;321;769;425;0;325
|
||||||
|
14/03/2012;469;;146;313;739;451;0;336
|
||||||
|
15/03/2012;724;;244;562;1021;631;63;565
|
||||||
|
16/03/2012;423;;149;305;695;419;9;422
|
||||||
|
17/03/2012;681;;287;422;872;468;334;1008
|
||||||
|
18/03/2012;1940;;856;1036;1923;1021;1128;2477
|
||||||
|
19/03/2012;1821;;1024;1278;2581;1609;506;2058
|
||||||
|
20/03/2012;2481;;1261;1709;3130;1955;762;2609
|
||||||
|
21/03/2012;2829;;1558;1893;3510;2225;993;2846
|
||||||
|
22/03/2012;2195;;1030;1640;2654;1958;548;2254
|
||||||
|
23/03/2012;2115;;1143;1512;2955;1791;663;2325
|
||||||
|
24/03/2012;753;;336;517;1001;635;277;1035
|
||||||
|
25/03/2012;520;;243;309;691;427;145;723
|
||||||
|
26/03/2012;968;;564;729;1493;965;130;1168
|
||||||
|
27/03/2012;1049;;517;774;1576;972;163;1207
|
||||||
|
28/03/2012;435;;179;329;709;486;28;529
|
||||||
|
29/03/2012;878;;406;646;1264;807;78;937
|
||||||
|
30/03/2012;1157;;529;910;1596;957;196;1288
|
||||||
|
31/03/2012;980;;499;587;1083;706;524;1370
|
||||||
|
01/04/2012;662;;341;442;824;471;168;1086
|
||||||
|
02/04/2012;1937;;967;1537;2853;1614;394;2122
|
||||||
|
03/04/2012;2416;;1078;1791;3556;1880;513;2450
|
||||||
|
04/04/2012;2211;;933;1674;2956;1666;274;2242
|
||||||
|
05/04/2012;2424;;1036;1823;3273;1699;355;2463
|
||||||
|
06/04/2012;1633;;650;1045;1913;975;621;2138
|
||||||
|
07/04/2012;1208;;494;739;1445;709;598;1566
|
||||||
|
08/04/2012;1164;;560;621;1333;704;792;1533
|
||||||
|
09/04/2012;828;;298;560;1048;605;65;1001
|
||||||
|
10/04/2012;2183;;909;1588;2932;1736;252;2108
|
||||||
|
11/04/2012;2328;;1049;1765;3122;1843;330;2311
|
||||||
|
12/04/2012;3064;;1483;2306;4076;2280;590;3213
|
||||||
|
13/04/2012;3341;;1505;2565;4465;2358;922;3728
|
||||||
|
14/04/2012;2890;;1072;1639;2994;1594;1284;3428
|
||||||
|
15/04/2012;2554;;1210;1637;2954;1559;1846;3604
|
||||||
|
16/04/2012;3643;;1841;2723;4830;2677;1061;3616
|
||||||
|
17/04/2012;3539;;1616;2636;4592;2450;544;3333
|
||||||
|
18/04/2012;3570;;1751;2759;4655;2534;706;3542
|
||||||
|
19/04/2012;4231;;2010;3235;5311;2877;1206;3929
|
||||||
|
20/04/2012;2087;;800;1529;2922;1531;170;2065
|
||||||
|
21/04/2012;533;;212;398;710;408;50;755
|
||||||
|
22/04/2012;1853;;487;1224;1331;654;198;1779
|
||||||
|
23/04/2012;623;;315;544;1076;612;27;846
|
||||||
|
24/04/2012;1810;;720;1355;2379;1286;188;1753
|
||||||
|
25/04/2012;2966;;1023;2228;3444;1800;445;2454
|
||||||
|
26/04/2012;2751;;1069;2196;3546;1789;381;2438
|
||||||
|
27/04/2012;1986;;743;1526;2586;1298;139;1899
|
||||||
|
28/04/2012;1684;;628;1190;1908;931;523;2323
|
||||||
|
29/04/2012;1970;;765;1212;2077;1062;702;2493
|
||||||
|
30/04/2012;3610;;1572;2825;4675;2446;851;3541
|
||||||
|
01/05/2012;1986;;815;1722;2766;1516;195;1960
|
||||||
|
02/05/2012;3724;;1677;2885;4731;2508;876;3501
|
||||||
|
03/05/2012;3698;;1618;3001;4943;2577;731;3603
|
||||||
|
04/05/2012;2511;;1163;2058;3717;1823;380;2631
|
||||||
|
05/05/2012;3492;;1366;2106;3696;1779;1677;4108
|
||||||
|
06/05/2012;3411;;1525;1815;3346;1879;2036;4633
|
||||||
|
07/05/2012;5552;;2573;3959;6355;3416;1848;5253
|
||||||
|
08/05/2012;1241;;625;991;1729;1007;119;1383
|
||||||
|
09/05/2012;3297;;1545;2700;4343;2340;737;3129
|
||||||
|
10/05/2012;2755;;1227;2130;4056;2075;399;2437
|
||||||
|
11/05/2012;4639;;1803;3663;5713;2888;1260;4499
|
||||||
|
12/05/2012;3854;;1457;2429;3894;1805;2268;4855
|
||||||
|
13/05/2012;2741;;1223;1703;3086;1592;1394;3496
|
||||||
|
14/05/2012;6189;;2709;4402;7006;3868;2215;5775
|
||||||
|
15/05/2012;3964;;1773;3144;5088;2650;975;3765
|
||||||
|
16/05/2012;4947;;2178;3681;5882;3057;1332;4348
|
||||||
|
17/05/2012;5351;;2441;4182;6551;3408;1631;4988
|
||||||
|
18/05/2012;5980;;2241;4415;6646;3196;1711;5273
|
||||||
|
19/05/2012;4732;;1454;2807;4673;1966;2914;5293
|
||||||
|
20/05/2012;5255;;1663;2730;4462;2182;4241;5539
|
||||||
|
21/05/2012;5129;;1646;2672;4169;2044;3413;5053
|
||||||
|
22/05/2012;2315;;938;1847;2599;1610;251;2069
|
||||||
|
23/05/2012;5974;;2650;4407;7281;3737;1826;4798
|
||||||
|
24/05/2012;6485;;2653;4600;7600;3792;2062;5209
|
||||||
|
25/05/2012;5697;;2205;4096;6734;3341;1953;5174
|
||||||
|
26/05/2012;4974;;1622;2936;4991;2373;3455;5443
|
||||||
|
27/05/2012;4396;;1525;2578;4587;2073;2886;5168
|
||||||
|
28/05/2012;4268;;1962;3449;5798;2898;1027;3894
|
||||||
|
29/05/2012;3154;;1184;2325;3904;1933;475;2731
|
||||||
|
30/05/2012;6459;;2722;4806;7632;3817;2454;5172
|
||||||
|
31/05/2012;5104;;2177;3985;6631;3205;1389;4410
|
||||||
|
01/06/2012;6097;;2604;4110;7175;3895;1692;6595
|
||||||
|
02/06/2012;943;;392;630;1289;628;71;1436
|
||||||
|
03/06/2012;2755;;1897;2020;3768;2324;1312;4936
|
||||||
|
04/06/2012;2717;;1408;2095;4276;2168;333;3090
|
||||||
|
05/06/2012;5842;;2721;3927;7302;3786;1232;5348
|
||||||
|
06/06/2012;6037;;2724;4273;7822;3987;1223;5269
|
||||||
|
07/06/2012;6246;;2607;4670;8222;3972;1019;5724
|
||||||
|
08/06/2012;4169;;1833;3303;5881;3001;623;4474
|
||||||
|
09/06/2012;5164;;1672;3418;5557;2451;1551;6026
|
||||||
|
10/06/2012;5112;;1812;2905;4798;2328;1833;6170
|
||||||
|
11/06/2012;6206;;2577;4333;7015;3757;1264;5721
|
||||||
|
12/06/2012;3361;;1556;2362;4230;2381;589;3030
|
||||||
|
13/06/2012;6180;;2792;4374;7297;3825;1968;5887
|
||||||
|
14/06/2012;6908;;2978;4809;7934;4223;2386;6243
|
||||||
|
15/06/2012;7077;;2469;4999;7663;4053;2293;6491
|
||||||
|
16/06/2012;5421;;1651;3099;4909;2337;3280;5537
|
||||||
|
17/06/2012;4638;;1552;2082;4108;2020;3453;5128
|
||||||
|
18/06/2012;5921;;2703;3582;6824;3960;2455;5496
|
||||||
|
19/06/2012;5382;;2360;3447;6679;3438;1711;5015
|
||||||
|
20/06/2012;5713;;2402;3524;6848;3510;2363;4852
|
||||||
|
21/06/2012;5183;;2195;3297;6684;3272;2265;4957
|
||||||
|
22/06/2012;5398;;1934;3612;6659;3252;2009;5263
|
||||||
|
23/06/2012;3753;;1326;1842;3992;1910;2585;4824
|
||||||
|
24/06/2012;3341;;1152;1423;2989;1510;3634;4581
|
||||||
|
25/06/2012;2245;;1077;1374;3031;1440;1349;3283
|
||||||
|
26/06/2012;3327;;1435;2139;4318;2193;620;3223
|
||||||
|
27/06/2012;3141;;1322;2142;4211;2134;536;2897
|
||||||
|
28/06/2012;6064;;2381;4411;6864;3523;2415;5175
|
||||||
|
29/06/2012;5770;;1935;4004;6656;3090;2109;5332
|
||||||
|
30/06/2012;4738;;1359;3007;4226;1822;2870;4527
|
||||||
|
01/07/2012;4758;;1343;2911;3935;1777;3732;4522
|
||||||
|
02/07/2012;4144;;1397;2658;3998;1883;2783;4464
|
||||||
|
03/07/2012;6712;;2634;4398;7416;3896;2606;5462
|
||||||
|
04/07/2012;5153;;2038;3591;5814;3070;1246;4493
|
||||||
|
05/07/2012;6672;;2603;4830;7764;3816;2746;5153
|
||||||
|
06/07/2012;5958;;2095;4137;6942;3387;2248;5610
|
||||||
|
07/07/2012;5420;;1289;3802;4978;2132;3156;4939
|
||||||
|
08/07/2012;4756;;1497;2407;4495;2089;4386;5535
|
||||||
|
09/07/2012;5661;;2330;3524;6769;3577;2599;4987
|
||||||
|
10/07/2012;6500;;2625;4064;7436;3749;2822;5952
|
||||||
|
11/07/2012;6424;;2548;3921;7374;3781;2779;5474
|
||||||
|
12/07/2012;6179;;2371;3772;7200;3687;2433;5140
|
||||||
|
13/07/2012;5518;;2005;3525;6492;3088;2219;5185
|
||||||
|
14/07/2012;4206;;1244;2441;4284;1562;2900;4252
|
||||||
|
15/07/2012;3035;;1060;1798;3437;1449;2034;3545
|
||||||
|
16/07/2012;4827;;2092;3141;6049;2965;1703;4379
|
||||||
|
17/07/2012;2756;;1046;2001;3802;1700;569;2641
|
||||||
|
18/07/2012;6180;;2589;3750;7311;3654;2813;5884
|
||||||
|
19/07/2012;6309;;2397;3996;7699;3777;2647;5665
|
||||||
|
20/07/2012;5813;;2088;3744;6959;3316;2538;5775
|
||||||
|
21/07/2012;5092;;1419;2957;4658;1821;3835;4848
|
||||||
|
22/07/2012;4971;;1238;2683;4104;1788;2960;4787
|
||||||
|
23/07/2012;3877;;1660;2420;4937;2534;1461;3475
|
||||||
|
24/07/2012;5243;;2318;3465;6721;3317;2170;4694
|
||||||
|
25/07/2012;6104;;2593;3786;7073;3622;3132;5059
|
||||||
|
26/07/2012;5560;;2043;4174;6476;3208;1595;4383
|
||||||
|
27/07/2012;5759;;1948;3658;6851;3275;2653;5295
|
||||||
|
28/07/2012;4105;;1345;2504;4540;1767;2468;4631
|
||||||
|
29/07/2012;4230;;1332;1791;4235;1905;3731;4906
|
||||||
|
30/07/2012;5225;;2285;2975;6219;3196;2564;5100
|
||||||
|
31/07/2012;5415;;2185;3145;6705;3222;2505;4468
|
||||||
|
01/08/2012;4638;;1842;2783;5846;2810;1481;3889
|
||||||
|
02/08/2012;5715;;2361;3340;6956;3329;2643;4828
|
||||||
|
03/08/2012;5577;;1915;3306;6427;2789;3195;5031
|
||||||
|
04/08/2012;4223;;1305;2019;4425;1769;2939;4467
|
||||||
|
05/08/2012;1864;;630;1100;2327;970;1066;2268
|
||||||
|
06/08/2012;5240;;2277;3193;6375;3187;2274;4604
|
||||||
|
07/08/2012;5997;;2410;3622;6840;3480;2780;4903
|
||||||
|
08/08/2012;5498;;2313;3365;6862;3403;2226;4771
|
||||||
|
09/08/2012;4127;;1802;2601;5377;2656;1471;3636
|
||||||
|
10/08/2012;2414;;934;1727;3323;1641;440;2456
|
||||||
|
11/08/2012;2453;;815;1589;2628;1043;1340;2608
|
||||||
|
12/08/2012;3995;;1338;1937;3427;1719;2988;4178
|
||||||
|
13/08/2012;4931;;2298;3124;5936;3151;2090;4842
|
||||||
|
14/08/2012;5333;;2322;3571;6332;3260;1456;4362
|
||||||
|
15/08/2012;4297;;1882;2936;4948;2686;970;3877
|
||||||
|
16/08/2012;6062;;2538;3898;6549;3366;1549;4943
|
||||||
|
17/08/2012;4236;;1777;3099;4979;2581;586;4154
|
||||||
|
18/08/2012;4427;;1333;2505;3866;1864;1229;4359
|
||||||
|
19/08/2012;4644;;1408;2605;3780;1758;1683;4478
|
||||||
|
20/08/2012;5335;;2474;3521;6088;3332;1439;5201
|
||||||
|
21/08/2012;5792;;2508;4063;6687;3369;2353;5640
|
||||||
|
22/08/2012;6529;;2671;4513;7065;3774;2391;5154
|
||||||
|
23/08/2012;5437;;2482;3807;6773;3573;1864;5010
|
||||||
|
24/08/2012;5690;;2394;3778;6703;3312;2178;5299
|
||||||
|
25/08/2012;4242;;1305;2358;4126;1726;2558;4833
|
||||||
|
26/08/2012;3964;;1318;2118;3558;1750;2932;4536
|
||||||
|
27/08/2012;4314;;2273;3098;5196;2762;1010;3598
|
||||||
|
28/08/2012;5817;;2794;3966;6313;3420;1629;4720
|
||||||
|
29/08/2012;6327;;3092;4370;7009;3759;2152;5342
|
||||||
|
30/08/2012;6003;;2910;4199;6781;3481;1796;5202
|
||||||
|
31/08/2012;4106;;1868;2999;5054;2541;875;4188
|
||||||
|
01/09/2012;3934;;1225;2371;3917;1887;2801;3845
|
||||||
|
02/09/2012;3698;;1232;2093;3827;1788;2959;4247
|
||||||
|
03/09/2012;4179;;1532;2233;3718;1620;3783;4709
|
||||||
|
04/09/2012;4225;;1934;3057;5275;3006;894;3868
|
||||||
|
05/09/2012;5655;;2722;3861;7110;4061;1383;4491
|
||||||
|
06/09/2012;5883;;2883;3967;7511;4014;1498;4732
|
||||||
|
07/09/2012;6186;;2720;4153;7323;3886;2051;6104
|
||||||
|
08/09/2012;2155;;1192;1467;2739;898;801;2626
|
||||||
|
09/09/2012;3312;;1810;1828;3458;2668;2118;4355
|
||||||
|
10/09/2012;5077;;2792;3718;6644;3849;1271;4984
|
||||||
|
11/09/2012;6015;;2913;4081;7148;4314;1484;5451
|
||||||
|
12/09/2012;6349;;3124;4209;7292;4510;1981;5697
|
||||||
|
13/09/2012;6520;;3076;4369;7514;4494;1986;5742
|
||||||
|
14/09/2012;5216;;2257;3480;6104;3574;1524;4918
|
||||||
|
15/09/2012;3341;;1100;1900;3099;1593;1268;3426
|
||||||
|
16/09/2012;3635;;1231;1614;3040;1852;2348;3696
|
||||||
|
17/09/2012;5299;;2658;3670;6582;4076;1704;4788
|
||||||
|
18/09/2012;2530;;1277;1695;3254;2275;388;2377
|
||||||
|
19/09/2012;4653;;2351;3176;5746;3738;840;4189
|
||||||
|
20/09/2012;5260;;2496;3615;6348;3991;1391;5119
|
||||||
|
21/09/2012;4022;;1821;2911;4745;2945;889;3886
|
||||||
|
22/09/2012;1521;;656;1073;1682;971;365;1974
|
||||||
|
23/09/2012;2314;;1093;1496;2572;1470;984;3321
|
||||||
|
24/09/2012;4553;;2246;3117;5738;3705;1100;4683
|
||||||
|
25/09/2012;5038;;2236;3273;5861;3712;1007;4420
|
||||||
|
26/09/2012;3948;;1873;2720;4755;3119;650;3721
|
||||||
|
27/09/2012;5119;;2288;3465;5983;3704;1152;4598
|
||||||
|
28/09/2012;4652;;2134;3209;5372;3309;1133;4361
|
||||||
|
29/09/2012;1896;;755;1206;1963;1062;442;2267
|
||||||
|
30/09/2012;876;;359;513;957;520;133;1162
|
||||||
|
01/10/2012;3255;;1576;2184;3830;2582;397;2987
|
||||||
|
02/10/2012;5139;;2525;3281;5845;3732;1229;4497
|
||||||
|
03/10/2012;4685;;2377;3191;5475;3415;858;3941
|
||||||
|
04/10/2012;4034;;2025;2705;4850;3066;555;3418
|
||||||
|
05/10/2012;4151;;1977;2799;4688;2844;1035;4088
|
||||||
|
06/10/2012;1304;;469;933;1589;776;236;1775
|
||||||
|
07/10/2012;1580;;660;922;1629;860;695;2052
|
||||||
|
08/10/2012;1854;;880;987;1818;1040;1115;2502
|
||||||
|
09/10/2012;4787;;2210;3026;5138;3418;927;4078
|
||||||
|
10/10/2012;3115;;1537;2081;3681;2608;560;2703
|
||||||
|
11/10/2012;3746;;1857;2569;4694;3034;558;3457
|
||||||
|
12/10/2012;3169;;1460;2261;4045;2564;448;3224
|
||||||
|
13/10/2012;1783;;802;1205;2113;1183;681;2309
|
||||||
|
14/10/2012;587;;287;443;852;503;65;952
|
||||||
|
15/10/2012;3292;;1678;2165;4197;2754;560;3183
|
||||||
|
16/10/2012;3739;;1858;2684;4681;2997;554;3593
|
||||||
|
17/10/2012;4098;;1964;2645;4836;3063;728;3834
|
||||||
|
18/10/2012;4671;;2292;3129;5542;3477;1108;4245
|
||||||
|
19/10/2012;1313;;597;885;1668;1209;111;1486
|
||||||
|
20/10/2012;2011;;748;1323;2266;1213;797;2243
|
||||||
|
21/10/2012;1277;;609;869;1777;898;242;1648
|
||||||
|
22/10/2012;3650;;1819;2495;4800;3023;757;3721
|
||||||
|
23/10/2012;4177;;1997;2795;5216;3233;795;3554
|
||||||
|
24/10/2012;3744;;1868;2625;4900;3035;649;3622
|
||||||
|
25/10/2012;3735;;1815;2528;5010;3017;631;3767
|
||||||
|
26/10/2012;4290;;1987;2754;5246;3000;1456;4578
|
||||||
|
27/10/2012;1857;;792;1244;2461;1193;618;2471
|
||||||
|
28/10/2012;1310;;697;910;1776;955;387;1876
|
||||||
|
29/10/2012;2919;;1458;2071;3768;2440;411;2795
|
||||||
|
30/10/2012;2887;;1251;2007;3516;2255;338;2790
|
||||||
|
31/10/2012;2634;;1294;1835;3453;2220;245;2570
|
||||||
|
01/11/2012;2405;;1208;1701;3082;2076;165;2461
|
||||||
|
02/11/2012;1582;;737;1109;2277;1392;97;1888
|
||||||
|
03/11/2012;844;;380;612;1137;713;105;1302
|
||||||
|
04/11/2012;966;;446;710;1277;692;197;1374
|
||||||
|
05/11/2012;2247;;1170;1705;3221;2143;179;2430
|
Can't render this file because it has a wrong number of fields in line 17.
|
5001
labs06/mieszkania.csv
Normal file
5001
labs06/mieszkania.csv
Normal file
File diff suppressed because it is too large
Load Diff
54
labs06/task02.py
Executable file
54
labs06/task02.py
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def wczytaj_dane():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def most_common_room_number(dane):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def cheapest_flats(dane, n):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def find_borough(desc):
|
||||||
|
dzielnice = ['Stare Miasto',
|
||||||
|
'Wilda',
|
||||||
|
'Jeżyce',
|
||||||
|
'Rataje',
|
||||||
|
'Piątkowo',
|
||||||
|
'Winogrady',
|
||||||
|
'Miłostowo',
|
||||||
|
'Dębiec']
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def add_borough(dane):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def write_plot(dane, filename):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def mean_price(dane, room_number):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def find_13(dane):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def find_best_flats(dane):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main():
|
||||||
|
dane = wczytaj_dane()
|
||||||
|
print(dane[:5])
|
||||||
|
|
||||||
|
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
|
||||||
|
.format(most_common_room_number(dane)))
|
||||||
|
|
||||||
|
print("{} to najłądniejsza dzielnica w Poznaniu."
|
||||||
|
.format(find_borough("Grunwald i Jeżyce"))))
|
||||||
|
|
||||||
|
print("Średnia cena mieszkania 3-pokojowego, to: {}"
|
||||||
|
.format(mean_price(dane, 3)))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user