Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
5238249af5 | |||
689e3bc8ee | |||
ba9dc1422a | |||
00d565690f | |||
e7c555cd6a | |||
417669ce28 | |||
169b8cb51f | |||
58ec99c4ad | |||
27d6fb7c7b | |||
881ce4306e | |||
dcd13d8f6d | |||
4a20298ab2 | |||
8eda90d9f8 | |||
ac68c51136 | |||
5fbc3b57d4 | |||
505e2aa30c | |||
c6a24f1f8e | |||
86d33a2a5d | |||
47b7c62adf |
11
.idea/Python2017.iml
Normal file
11
.idea/Python2017.iml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
|
||||
</component>
|
||||
</module>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6.2 (C:\software\python3\python.exe)" project-jdk-type="Python SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Python2017.iml" filepath="$PROJECT_DIR$/.idea/Python2017.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -1,38 +1,25 @@
|
||||
ID | labs02:task07 | labs02:task08 | labs02:task09 | labs02:task10 | labs02:task11 | labs03 | labs04 | labs06 | Punkty | Ocena |
|
||||
---------|-----------------|-----------------|-----------------|-----------------|-----------------|----------|----------|----------|--------|-------|
|
||||
s45146 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45147 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45148 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45150 | 1 | 1 | 1 | 1 | 1 | 2 | 1 | 8 | 16 | 4 |
|
||||
s45151 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 18 | 4.5 |
|
||||
s45152 | 1 | 1 | 1 | 0 | 1 | 0 | 5 | 8 | 17 | 4 |
|
||||
s45153 | 0 | 1 | 1 | 1 | 1 | 4 | 0 | 8 | 16 | 4 |
|
||||
s45155 | 1 | 1 | 1 | 1 | 1 | 1 | 5 | 8 | 19 | 4.5 |
|
||||
s45156 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45157 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
s45158 | 1 | 1 | 0 | 0 | 1 | 4 | 5 | 8 | 19 | 4.5 |
|
||||
s45159 | 1 | 1 | 1 | 1 | 1 | 2 | 3 | 8 | 18 | 4.5 |
|
||||
s45160 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
s45161 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45162 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45163 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
s45164 | 1 | 1 | 0 | 1 | 0 | 0 | 5 | 8 | 16 | 4 |
|
||||
s45165 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45166 | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 8 | 22 | 5 |
|
||||
s45167 | 1 | 1 | 1 | 1 | 1 | 0 | 5 | 8 | 17 | 4 |
|
||||
s45168 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
|
||||
s45452 | 1 | 1 | 1 | 1 | 1 | 4 | 4 | 8 | 21 | 5 |
|
||||
szwedek | 1 | 1 | 1 | 1 | 1 | 4 | 5 | 10 | 24 | 5 |
|
||||
|
||||
Skala:
|
||||
|
||||
Punkty | Ocena |
|
||||
-------|-------|
|
||||
24-20 | 5 |
|
||||
19-18 | 4.5 |
|
||||
17-16 | 4 |
|
||||
15-13 | 3 |
|
||||
12-0 | 2 |
|
||||
|
||||
|
||||
Max: 22
|
||||
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 | |
|
||||
|
@ -7,8 +7,9 @@ która zawiera tylko elementy z list o parzystych indeksach.
|
||||
"""
|
||||
|
||||
def even_elements(lista):
|
||||
pass
|
||||
return lista[::2]
|
||||
|
||||
print(even_elements([1,2,3,4]))
|
||||
|
||||
def tests(f):
|
||||
inputs = [[[1, 2, 3, 4, 5, 6]], [[]], [[41]]]
|
||||
@ -23,3 +24,5 @@ def tests(f):
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(tests(even_elements))
|
||||
|
||||
|
||||
|
@ -6,7 +6,13 @@
|
||||
"""
|
||||
|
||||
def days_in_year(days):
|
||||
pass
|
||||
if (days % 4 == 0 and days % 100 != 0) or days % 400 == 0:
|
||||
return 366
|
||||
else:
|
||||
return 365
|
||||
|
||||
|
||||
print("dni:",days_in_year(2000))
|
||||
|
||||
def tests(f):
|
||||
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
||||
|
@ -10,11 +10,21 @@ znakowy i lista łańuchów znakowych. Wszystkie wyrazy należy zmienić na mał
|
||||
litery. (OOV = out of vocabulary) (W pythonie istnieje struktura danych tak
|
||||
jak 'set', która przechowuje elementy bez powtórzeń.)
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
a = []
|
||||
text = "dom dla lalek"
|
||||
a = text.split(' ')
|
||||
print(a[1])
|
||||
"""
|
||||
def oov(text,vocab):
|
||||
pass
|
||||
b = set()
|
||||
a = text.split(' ')
|
||||
for wyr in a:
|
||||
if wyr not in vocab:
|
||||
b.add(wyr)
|
||||
return b
|
||||
|
||||
print(oov("Dom dla kasia", "lalek dom"))
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -7,7 +7,15 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
|
||||
"""
|
||||
|
||||
def sum_from_one_to_n(n):
|
||||
pass
|
||||
sum=0
|
||||
if n < 1:
|
||||
return 0
|
||||
else:
|
||||
for i in range(n+1):
|
||||
sum+=i
|
||||
return sum
|
||||
|
||||
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -10,7 +10,11 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
|
||||
"""
|
||||
|
||||
def euclidean_distance(x, y):
|
||||
pass
|
||||
if len(x)!=len(y):
|
||||
return 'Error'
|
||||
else:
|
||||
return ((x[0]-y[0])**2+(x[1]-y[1])**2+(x[2]-y[2])**2)**(1/2)
|
||||
|
||||
|
||||
def tests(f):
|
||||
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]
|
||||
|
@ -10,7 +10,13 @@ ma być zwracany napis "It's not a Big 'No!'".
|
||||
"""
|
||||
|
||||
def big_no(n):
|
||||
pass
|
||||
if (n<5):
|
||||
return "It's not a Big 'No!'"
|
||||
else:
|
||||
S="N"
|
||||
for i in range(n):
|
||||
S+="O"
|
||||
return S+"!"
|
||||
|
||||
def tests(f):
|
||||
inputs = [[5], [6], [2]]
|
||||
|
@ -6,7 +6,7 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
|
||||
sumę kodów ASCII znaków.
|
||||
"""
|
||||
def char_sum(text):
|
||||
pass
|
||||
return sum(ord(i) for i in text)
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string"], ["this is another string"]]
|
||||
|
@ -7,7 +7,12 @@ przez 3 lub 5 mniejszych niż n.
|
||||
"""
|
||||
|
||||
def sum_div35(n):
|
||||
pass
|
||||
sum=0
|
||||
for i in range(n):
|
||||
if (i%5==0) or (i%3==0):
|
||||
sum+=i
|
||||
return sum
|
||||
|
||||
|
||||
def tests(f):
|
||||
inputs = [[10], [100], [3845]]
|
||||
|
@ -9,7 +9,15 @@ Np. leet('leet') powinno zwrócić '1337'.
|
||||
|
||||
|
||||
def leet_speak(text):
|
||||
pass
|
||||
tekst=""
|
||||
slownik = {"e": "3", "l": "1", "o": "0", "t":"7"}
|
||||
for i in text:
|
||||
if i in slownik:
|
||||
tekst+=slownik[i]
|
||||
else:
|
||||
tekst+=i
|
||||
return tekst
|
||||
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -9,7 +9,14 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
|
||||
|
||||
|
||||
def pokemon_speak(text):
|
||||
pass
|
||||
s=""
|
||||
for i in range(len(text)):
|
||||
if (i%2==0):
|
||||
s+=text[i].upper()
|
||||
else:
|
||||
s+=text[i]
|
||||
return s
|
||||
|
||||
|
||||
|
||||
def tests(f):
|
||||
|
@ -9,8 +9,11 @@ Oba napisy będą składać się wyłacznie z małych liter.
|
||||
"""
|
||||
|
||||
def common_chars(string1, string2):
|
||||
pass
|
||||
|
||||
b =[]
|
||||
for i in sorted(string1):
|
||||
if (i in sorted(string2)) and i!=" " and i not in b:
|
||||
b.append(i)
|
||||
return b
|
||||
|
||||
def tests(f):
|
||||
inputs = [["this is a string", "ala ma kota"]]
|
||||
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
def suma(a, b):
|
||||
"""
|
||||
Napisz funkcję, która zwraca sumę elementów.
|
||||
"""
|
||||
return a + b
|
||||
|
||||
def tests(f):
|
||||
inputs = [(2, 3), (0, 0), (1, 1)]
|
||||
outputs = [5, 0, 2]
|
||||
|
||||
for input, output in zip(inputs, outputs):
|
||||
if f(*input) != output:
|
||||
return "ERROR: {}!={}".format(f(*input), output)
|
||||
break
|
||||
return "TESTS PASSED"
|
||||
|
||||
print(tests(suma))
|
@ -49,34 +49,22 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"2\n",
|
||||
"[1, 2, 3, 1, 2, 3]\n",
|
||||
"123\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def dwojak(x): \n",
|
||||
" x *= 2\n",
|
||||
" return x\n",
|
||||
"def dwojak(x): x *= 2\n",
|
||||
" \n",
|
||||
"l = [1, 2, 3]\n",
|
||||
"s = \"123\"\n",
|
||||
"\n",
|
||||
"dwojak(l)\n",
|
||||
"dwojak(s)\n",
|
||||
"print(dwojak(1))\n",
|
||||
"\n",
|
||||
"print(l)\n",
|
||||
"print(s)"
|
||||
]
|
||||
@ -116,28 +104,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[1, 2, 3, 1, 2, 3]\n",
|
||||
"F: [1, 2, 3, 1, 2, 3]\n",
|
||||
"[1, 2, 3]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def dwojak1(x): x *= 2\n",
|
||||
"def dwojak2(x): \n",
|
||||
" x = x * 2\n",
|
||||
" print(\"F:\", x)\n",
|
||||
"def dwojak2(x): x = x * 2\n",
|
||||
"\n",
|
||||
"l = [1,2, 3]\n",
|
||||
"dwojak1(l)\n",
|
||||
@ -150,47 +126,29 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[1, 2, 3]\n",
|
||||
"[1, 2, 3, 4]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"l = [1, 2, 3]\n",
|
||||
"e = l[:]\n",
|
||||
"e = l\n",
|
||||
"e.append(4)\n",
|
||||
"print(l)\n",
|
||||
"print(e)"
|
||||
"print(l)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[[1], [1], [1]]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"e = []\n",
|
||||
"f = [e for i in range(3)]\n",
|
||||
@ -214,39 +172,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(1, 'napis', [0])\n",
|
||||
"3\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "TypeError",
|
||||
"evalue": "unhashable type: 'list'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-25-2bd2fa17fbf5>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;31mTypeError\u001b[0m: unhashable type: 'list'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"t = (1, \"napis\", [])\n",
|
||||
"t[-1].append(0)\n",
|
||||
"t = (1, \"napis\", None)\n",
|
||||
"elem = t[0]\n",
|
||||
"print(t)\n",
|
||||
"print(len(t))\n",
|
||||
"print({t: None})"
|
||||
"print(len(t))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -262,29 +199,19 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"15\n",
|
||||
"a == 1\n",
|
||||
"b == (3, 4)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def suma(*args):\n",
|
||||
" return sum(args)\n",
|
||||
"print(suma(1,2,3,4,5))\n",
|
||||
"\n",
|
||||
"def greet_me(z=None,**kwargs):\n",
|
||||
"def greet_me(**kwargs):\n",
|
||||
" if kwargs is not None:\n",
|
||||
" for key, value in kwargs.items():\n",
|
||||
" print(\"%s == %s\" %(key,value))\n",
|
||||
@ -304,32 +231,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"97\n",
|
||||
"a\n",
|
||||
"98\n",
|
||||
"b\n",
|
||||
"99\n",
|
||||
"c\n",
|
||||
"100\n",
|
||||
"d\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def alfaRange(x, y):\n",
|
||||
" for i in range(ord(x), ord(y)):\n",
|
||||
" print(i)\n",
|
||||
" yield chr(i)\n",
|
||||
"\n",
|
||||
"for c in alfaRange('a', 'e'):\n",
|
||||
@ -349,74 +260,40 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"W Paryżu najlepsze kasztany są na placu Pigalle\n",
|
||||
"Zuzanna lubi je tylko jesienią.\n",
|
||||
"\n",
|
||||
">>\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"plik = open(\"haslo.txt\", 'r')\n",
|
||||
"for linia in plik.readlines():\n",
|
||||
" print(linia.strip())\n",
|
||||
"print(plik.read())\n",
|
||||
"print(\">>\")\n",
|
||||
"plik.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 47,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"W Paryżu najlepsze kasztany są na placu Pigalle\n",
|
||||
"\n",
|
||||
"Zuzanna lubi je tylko jesienią.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "ValueError",
|
||||
"evalue": "I/O operation on closed file.",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-47-f06513c1bbec>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlinia\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mplik\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadlines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlinia\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplik\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;31mValueError\u001b[0m: I/O operation on closed file."
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"haslo.txt\", 'r') as plik:\n",
|
||||
" for linia in plik.readlines():\n",
|
||||
" print(linia)\n",
|
||||
"print(plik.read())"
|
||||
"# print(plik.read())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 48,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": true,
|
||||
"slideshow": {
|
||||
@ -457,22 +334,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 49,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"posix\n",
|
||||
"Nazwa uzytkownika: tomaszd\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"print(os.name)\n",
|
||||
@ -483,31 +351,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "slide"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Counter({'o': 4, 'n': 4, 'a': 4, 'k': 3, 't': 3, 'y': 2, 'i': 2, 'c': 2, 'z': 2, 's': 1, 'p': 1, 'l': 1, 'ń': 1, 'w': 1, 'e': 1})\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"array([[ 1., 3., 4., 5.]], dtype=float32)"
|
||||
]
|
||||
},
|
||||
"execution_count": 50,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from collections import *\n",
|
||||
"print(Counter(\"konstantynopolitańczykowianeczka\"))\n",
|
||||
@ -544,23 +394,13 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 51,
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "fragment"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"What's your name?\n",
|
||||
"Tomasz\n",
|
||||
"Welcome home, Tomasz.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"name = input(\"What's your name?\\n\")\n",
|
||||
"print(\"Welcome home, {}.\".format(name))"
|
||||
|
@ -27,7 +27,10 @@ Zainstaluj bibliotekę ``weather-api`` (https://pypi.python.org/pypi/weather-api
|
||||
* Korzystając z prognozy, znajdź dzień, w którym będzie najzimniej. Wypisz nazwę tygodnia (w języku polskim) i temperaturę w C.
|
||||
|
||||
**ćwiczenie 5**
|
||||
Katalog scores zawiera 64 pliki tekstowe, które posiadają informacje o wysokości miary ``BLEU`` na różnych etapach trenowania modelu. Nazwa każdego pliku na postać ``model.iterXXXXXXX.npz.bleu``, gdzie ``XXXXXXX``, to liczba iteracji.Zawartość każdego pliku jest podobna i ma następującą formę: *BLEU = YY.YY, 44.4/18.5/9.3/5.0 (BP=1.000, ratio=1.072, hyp_len=45976, ref_len=42903)*, gdzie ``YY.YY`` to wartość miary ``BLEU``. Znajdź plik, który zawiera najwyższą wartość miary ``BLEU``.
|
||||
Katalog scores zawiera 64 pliki tekstowe, które posiadają informacje o wysokości miary ``BLEU``
|
||||
na różnych etapach trenowania modelu. Nazwa każdego pliku na postać ``model.iterXXXXXXX.npz.bleu``, gdzie ``XXXXXXX``,
|
||||
to liczba iteracji.Zawartość każdego pliku jest podobna i ma następującą formę: *BLEU = YY.YY, 44.4/18.5/9.3/5.0 (BP=1.000,
|
||||
ratio=1.072, hyp_len=45976, ref_len=42903)*, gdzie ``YY.YY`` to wartość miary ``BLEU``. Znajdź plik, który zawiera najwyższą wartość miary ``BLEU``.
|
||||
* Wykorzystaj bibliotekę ``glob`` (https://docs.python.org/2/library/glob.html)
|
||||
* Wyświetl tylko pełną nazwe pliku (wraz z ścieżką).
|
||||
|
||||
|
3
labs03/task01.py
Normal file
3
labs03/task01.py
Normal file
@ -0,0 +1,3 @@
|
||||
print(id([3,5]))
|
||||
print(id('kot'))
|
||||
print(id((1/3)))
|
11
labs03/task02.py
Normal file
11
labs03/task02.py
Normal file
@ -0,0 +1,11 @@
|
||||
def Fib(n):
|
||||
a, b = 0, 1
|
||||
for _ in range(n):
|
||||
yield a
|
||||
a, b = b, a + b
|
||||
|
||||
for c in Fib(7):
|
||||
print(c)
|
||||
|
||||
##(``F(0)=1, F(1)=1, FN=F(N-1) + F(N-2)``).
|
||||
|
5
labs03/task03.py
Normal file
5
labs03/task03.py
Normal file
@ -0,0 +1,5 @@
|
||||
# pip install --user requests
|
||||
import requests
|
||||
r = requests.get('https://api.fixer.io/latest', auth=('user', 'pass'))
|
||||
jkursy=r.json()
|
||||
print("EUR:PLN "+str(jkursy['rates']['PLN']))
|
20
labs03/task04.py
Normal file
20
labs03/task04.py
Normal file
@ -0,0 +1,20 @@
|
||||
#pip install --user weather-api
|
||||
from datetime import datetime
|
||||
from weather import Weather
|
||||
weather=Weather()
|
||||
city="Poznan"
|
||||
weather_city=weather.lookup_by_location(city)
|
||||
print("Aktualna pogoda in "+city+" :", weather_city.condition().text())
|
||||
|
||||
def ftoC(t):
|
||||
return round(5/9 * (t-32),3)
|
||||
|
||||
daymap={0:"Poniedziałek",1:"Wtorek",2:"Środa",3:"Czwartek",4:"Piątek",5:"Sobota",6:"Niedziela"}
|
||||
tmin=[]
|
||||
dates=[]
|
||||
for item in weather_city.forecast():
|
||||
dates.append(item.date())
|
||||
tmin.append(ftoC(int(item.low())))
|
||||
|
||||
|
||||
print("Minimana temperatura w dniach "+dates[0]+" - " + dates[-1]+ " to " + str(min(tmin)) +"C przewidywana na dzień "+ dates[tmin.index(min(tmin))] + " ("+daymap[datetime.strptime(dates[tmin.index(min(tmin))],'%d %b %Y').weekday()]+").")
|
8
labs03/task05.py
Normal file
8
labs03/task05.py
Normal file
@ -0,0 +1,8 @@
|
||||
import glob,json
|
||||
bleu={}
|
||||
name=""
|
||||
for i in glob.glob('scores/*'):
|
||||
file=open(i,'r').read().replace(",","").split(" ")
|
||||
bleu[i]=float(file[2])
|
||||
|
||||
print("Maksymalna wartość BLEU znaleziona w pliku: " +max(bleu, key=bleu.get))
|
@ -309,13 +309,13 @@
|
||||
{
|
||||
"ename": "AttributeError",
|
||||
"evalue": "'Parser' object has no attribute '__parse'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-6-80ee186598d3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mparser\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mParser\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__parse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;31mAttributeError\u001b[0m: 'Parser' object has no attribute '__parse'"
|
||||
]
|
||||
],
|
||||
"output_type": "error"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
@ -465,13 +465,13 @@
|
||||
{
|
||||
"ename": "FileNotFoundError",
|
||||
"evalue": "[Errno 2] No such file or directory: 'nieistniejący_plik.txt'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-20-41928d542bef>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"nieistniejący_plik.txt\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplik\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mplik\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'nieistniejący_plik.txt'"
|
||||
]
|
||||
],
|
||||
"output_type": "error"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
@ -614,13 +614,13 @@
|
||||
{
|
||||
"ename": "MyError",
|
||||
"evalue": "Coś poszło nie tak!",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mMyError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-36-4fb306b42ebc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mMyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Coś poszło nie tak!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||
"\u001b[0;31mMyError\u001b[0m: Coś poszło nie tak!"
|
||||
]
|
||||
],
|
||||
"output_type": "error"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
|
@ -1,3 +1,8 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
def is_numeric(lista):
|
||||
for x in lista:
|
||||
if not(isinstance(x,float)) and not(isinstance(x,int)):
|
||||
return False
|
||||
return True
|
||||
|
@ -1,3 +1,37 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
class Employee:
|
||||
id=0
|
||||
def __init__(self, imie, nazwisko):
|
||||
self.imie= imie
|
||||
self.nazwisko=nazwisko
|
||||
self.id=id(self)
|
||||
|
||||
def get_id(self):
|
||||
return self.id
|
||||
|
||||
class Recruiter(Employee):
|
||||
recruited=[]
|
||||
def __init__(self, imie, nazwisko):
|
||||
super().__init__(imie,nazwisko)
|
||||
|
||||
def recruit(self, empId):
|
||||
self.recruited.append(empId)
|
||||
|
||||
|
||||
|
||||
class Programmer(Employee):
|
||||
def __init__(self, imie, nazwisko, rekruter):
|
||||
super().__init__(imie,nazwisko)
|
||||
self.recruiter=rekruter.get_id()
|
||||
|
||||
|
||||
|
||||
prac1=Employee('Anna', 'Nowak')
|
||||
prac2=Recruiter('Jan', 'Kowalski')
|
||||
prac3=Programmer('Ala', 'Makota',prac2)
|
||||
|
||||
print(prac1.get_id())
|
||||
print(prac2.get_id())
|
||||
print(prac3.get_id(), "Zrekrutowany przez ",prac3.recruiter)
|
@ -1,3 +1,41 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from task01 import *
|
||||
|
||||
class DimensionError(Exception):
|
||||
def __init__(self, text):
|
||||
self.text = text
|
||||
def __str__(self):
|
||||
return self.text
|
||||
|
||||
class Point:
|
||||
|
||||
def __init__(self, wspolrzedne):
|
||||
if (is_numeric(wspolrzedne)):
|
||||
self.wspolrzedne=wspolrzedne
|
||||
else:
|
||||
raise Exception("Non numerical coords")
|
||||
def __len__(self):
|
||||
return len(self.wspolrzedne)
|
||||
def __str__(self):
|
||||
return(str(self.wspolrzedne))
|
||||
def to_string(self):
|
||||
return str(self.wspolrzedne)
|
||||
def __add__(self, other):
|
||||
if len(self.wspolrzedne)!=len(other.wspolrzedne):
|
||||
raise DimensionError("Elements have different dimensions!!1")
|
||||
else:
|
||||
return [i+j for (i,j) in zip(self.wspolrzedne,other.wspolrzedne)]
|
||||
|
||||
|
||||
|
||||
pt=Point([1,2])
|
||||
print(len(pt))
|
||||
print(str(pt))
|
||||
print(pt.to_string())
|
||||
pt2=Point([7,99])
|
||||
print(pt+pt2)
|
||||
pt3=Point([1,2,3])
|
||||
print(pt+pt3)
|
||||
|
||||
|
BIN
labs06/barPlot.png
Normal file
BIN
labs06/barPlot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -1,14 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import pandas as pd
|
||||
def wczytaj_dane():
|
||||
pass
|
||||
mieszkania = pd.read_csv('mieszkania.csv', # ścieżka do pliku
|
||||
sep=',', # separator
|
||||
encoding='UTF-8',
|
||||
usecols=[0,1,2,3,4,5,6])
|
||||
return mieszkania
|
||||
|
||||
def most_common_room_number(dane):
|
||||
pass
|
||||
return dane.mode(numeric_only =True)["Rooms"][0]
|
||||
|
||||
def cheapest_flats(dane, n):
|
||||
pass
|
||||
return dane.sort_values("Expected")[:n]
|
||||
|
||||
def find_borough(desc):
|
||||
dzielnice = ['Stare Miasto',
|
||||
@ -19,36 +23,41 @@ def find_borough(desc):
|
||||
'Winogrady',
|
||||
'Miłostowo',
|
||||
'Dębiec']
|
||||
pass
|
||||
inputList=desc.split(' ')
|
||||
for i in inputList:
|
||||
if i in dzielnice:
|
||||
return i
|
||||
break
|
||||
return "Inne"
|
||||
|
||||
|
||||
def add_borough(dane):
|
||||
pass
|
||||
newcol=dane["Location"].apply(find_borough)
|
||||
dane["Borough"]=newcol
|
||||
return dane
|
||||
|
||||
def write_plot(dane, filename):
|
||||
pass
|
||||
bar=dane["Borough"].value_counts().plot(kind="bar", figsize=(6,6))
|
||||
fig=bar.get_figure()
|
||||
fig.savefig(filename)
|
||||
|
||||
def mean_price(dane, room_number):
|
||||
pass
|
||||
return dane[dane["Rooms"]==room_number]["Expected"].mean()
|
||||
|
||||
def find_13(dane):
|
||||
pass
|
||||
return dane[dane["Floor"]==13]["Borough"].unique()
|
||||
|
||||
def find_best_flats(dane):
|
||||
pass
|
||||
return dane[(dane["Borough"]=="Winogrady") & (dane["Floor"]==1) & (dane["Rooms"]==3)]
|
||||
|
||||
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"))))
|
||||
|
||||
.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