Compare commits

...

48 Commits

Author SHA1 Message Date
s45150
d6a66ea496 commited tasks 2018-01-02 17:38:06 +01:00
s45150
693f24077e commited tasks 2018-01-02 16:06:30 +01:00
s45150
9c719633e7 commited tasks 2018-01-02 15:28:01 +01:00
s45150
1ea9b5fc16 commited tasks 2017-12-16 13:10:58 +01:00
s45150
d26963a968 commited tasks 2017-12-16 13:00:41 +01:00
s45150
128c5bbadf commited tasks 2017-12-16 10:23:01 +01:00
s45150
976044eb47 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-16 09:08:16 +01:00
s45150
0233fb9ede commited tasks 2017-12-15 23:10:58 +01:00
s45150
6fd225e26b commited tasks 2017-12-15 22:49:02 +01:00
s45150
3b84741c12 commited tasks 2017-12-14 18:52:48 +01:00
s45150
f6f01153ef commited tasks 2017-12-12 19:24:28 +01:00
s45150
0395d2f228 commited tasks 2017-12-12 19:12:07 +01:00
s45150
b08baa9110 commited tasks 2017-12-12 18:59:49 +01:00
s45150
e41ec1cb80 commited tasks 2017-12-12 18:40:59 +01:00
s45150
832c2d6460 commited tasks 2017-12-11 19:29:05 +01:00
s45150
1fc06b7b66 commited tasks 2017-12-11 19:19:12 +01:00
s45150
b353aee815 commited tasks 2017-12-11 17:03:33 +01:00
s45150
a0d2623f9f commited tasks 2017-12-03 18:10:30 +01:00
s45150
f372aff821 commited tasks 2017-12-03 17:16:56 +01:00
s45150
4288d56ba2 commited tasks 2017-12-03 15:28:07 +01:00
s45150
dc66b8063e commited tasks 2017-12-03 14:14:37 +01:00
s45150
fbd88d6053 commited tasks 2017-12-03 14:11:49 +01:00
s45150
9e1a9f3e36 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-03 13:33:22 +01:00
s45150
b8c22f98aa commited tasks 2017-12-02 15:46:33 +01:00
s45150
f7bd46129e commited tasks 2017-12-02 15:37:04 +01:00
s45150
7715d08532 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2017 2017-12-02 15:05:36 +01:00
s45150
b3e6b03710 commited tasks 2017-12-01 17:52:46 +01:00
s45150
fe8c5810e4 commited tasks 2017-11-26 23:15:50 +01:00
s45150
464d765a82 commited tasks 2017-11-26 22:47:10 +01:00
s45150
4576474620 commited tasks 2017-11-26 22:37:25 +01:00
s45150
06b4cc2eff commited tasks 2017-11-26 22:35:41 +01:00
s45150
4816a4408f commited tasks 2017-11-26 15:22:44 +01:00
s45150
442fd6891f commited tasks 2017-11-26 15:05:03 +01:00
s45150
360ce4d88e commited tasks 2017-11-26 14:54:06 +01:00
s45150
a33c14f1bb commited tasks 2017-11-26 14:08:10 +01:00
s45150
32d82a2556 commited tasks 2017-11-26 14:03:31 +01:00
s45150
d64e3c0545 commited tasks 2017-11-25 18:02:43 +01:00
s45150
977a92617e commited tasks 2017-11-25 16:31:53 +01:00
s45150
49ade33e4b commited tasks 2017-11-25 16:19:19 +01:00
s45150
2e77b2ed58 commited tasks 2017-11-25 15:19:18 +01:00
s45150
141caa611c commited tasks 2017-11-25 15:15:27 +01:00
s45150
4480bb891e commited tasks 2017-11-25 14:56:10 +01:00
s45150
712d7f43c1 commited tasks 2017-11-25 14:53:51 +01:00
s45150
82d5caf3d7 commited tasks 2017-11-19 20:35:51 +01:00
s45150
4f1d8b6065 commited tasks 2017-11-19 18:02:03 +01:00
s45150
2522037757 commited tasks 2017-11-19 15:44:38 +01:00
s45150
fa0b6aa45a commited tasks 2017-11-19 15:15:35 +01:00
s45150
933e36a688 commit tasks 1 2017-11-19 15:01:30 +01:00
24 changed files with 398 additions and 37 deletions

View File

@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach.
""" """
def even_elements(lista): def even_elements(lista):
pass return lista[::2]
def tests(f): def tests(f):

View File

@ -5,8 +5,11 @@
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366). Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
""" """
def days_in_year(days): def days_in_year(year):
pass if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
return 366
else:
return 365
def tests(f): def tests(f):
inputs = [[2015], [2012], [1900], [2400], [1977]] inputs = [[2015], [2012], [1900], [2400], [1977]]

View File

@ -13,7 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.)
def oov(text, vocab): def oov(text, vocab):
pass test_list = []
_textSPlit =text.split(" ")
for i in _textSPlit:
if i not in vocab:
test_list.append(i)
return test_list

View File

@ -7,7 +7,13 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0.
""" """
def sum_from_one_to_n(n): def sum_from_one_to_n(n):
pass if n < 0:
return 0
else:
x = 0
for i in range(n+1):
x = x + i
return x
def tests(f): def tests(f):

View File

@ -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): def euclidean_distance(x, y):
pass dist = 0
for i in range(len(x)):
dist += (x[i]-y[i])**2
dist = dist**0.5
return dist
def tests(f): def tests(f):
inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]] inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]]

View File

@ -10,7 +10,14 @@ ma być zwracany napis "It's not a Big 'No!'".
""" """
def big_no(n): def big_no(n):
pass if n < 5:
out = "It's not a Big 'No!'"
else:
out = "N"
for i in range(n):
out += "O"
out += "!"
return out
def tests(f): def tests(f):
inputs = [[5], [6], [2]] inputs = [[5], [6], [2]]

View File

@ -6,7 +6,12 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca
sumę kodów ASCII znaków. sumę kodów ASCII znaków.
""" """
def char_sum(text): def char_sum(text):
pass sumaAsci = 0
text_tmp = text
for i in text_tmp:
sumaAsci += ord(i)
return sumaAsci
def tests(f): def tests(f):
inputs = [["this is a string"], ["this is another string"]] inputs = [["this is a string"], ["this is another string"]]

View File

@ -7,7 +7,13 @@ przez 3 lub 5 mniejszych niż n.
""" """
def sum_div35(n): def sum_div35(n):
pass suma = 0
i = 0
while i < n:
if i%3 == 0 or i%5 == 0:
suma += i
i += 1
return suma
def tests(f): def tests(f):
inputs = [[10], [100], [3845]] inputs = [[10], [100], [3845]]

View File

@ -9,8 +9,20 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text): def leet_speak(text):
pass text_tmp = text
lista_temp = ""
for i in text_tmp:
if i =='e':
lista_temp += '3'
elif i =='l':
lista_temp += '1'
elif i =='o':
lista_temp += '0'
elif i =='t':
lista_temp +='7'
else:
lista_temp +=i
return lista_temp
def tests(f): def tests(f):
inputs = [['leet'], ['do not want']] inputs = [['leet'], ['do not want']]

View File

@ -9,7 +9,23 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text): def pokemon_speak(text):
pass #spacja Asci 32
lista_temp = ""
j = 1
for i in text:
if ord(i) == 32:
j=1
lista_temp += i
else:
if j%2 == 0:
lista_temp += i
else:
lista_temp += i.upper()
j += 1
return lista_temp
def tests(f): def tests(f):

View File

@ -9,7 +9,21 @@ Oba napisy będą składać się wyłacznie z małych liter.
""" """
def common_chars(string1, string2): def common_chars(string1, string2):
pass string1=''.join(sorted(string1))
string1 = string1.strip(' ')
#print string1
string2 = ''.join(sorted(string2))
string2 = string2.strip(' ')
#print string2
slist = list()
for char in string1:
count=string2.count(char)
if count > 0:
if char not in slist:
slist.append(char)
#print(slist)
return(slist)
def tests(f): def tests(f):

View File

@ -232,13 +232,13 @@
{ {
"ename": "TypeError", "ename": "TypeError",
"evalue": "unhashable type: 'list'", "evalue": "unhashable type: 'list'",
"output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\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;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'" "\u001b[0;31mTypeError\u001b[0m: unhashable type: 'list'"
] ],
"output_type": "error"
} }
], ],
"source": [ "source": [
@ -398,13 +398,13 @@
{ {
"ename": "ValueError", "ename": "ValueError",
"evalue": "I/O operation on closed file.", "evalue": "I/O operation on closed file.",
"output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\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;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." "\u001b[0;31mValueError\u001b[0m: I/O operation on closed file."
] ],
"output_type": "error"
} }
], ],
"source": [ "source": [

4
labs03/task01 Normal file
View File

@ -0,0 +1,4 @@
print(id(2))
print(id("Ala ma kotA"))
print(id([1, 3, 11]))

15
labs03/task02.py Normal file
View File

@ -0,0 +1,15 @@
#task02
#Fibonacci
def fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n-2) + fibonacci(n-1)
print(fibonacci(0))
print(fibonacci(1))
print(fibonacci(2))
print(fibonacci(3))
print(fibonacci(4))
print(fibonacci(20))

16
labs03/task03.py Normal file
View File

@ -0,0 +1,16 @@
#task 03
import requests
url = "https://api.fixer.io/latest"
response = requests.get(url)
ALLData = response.json()
CurrancyPLN = ALLData['rates']
print("Kurs EURO: {} PLN".format(CurrancyPLN['PLN']))

55
labs03/task04.py Normal file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
**ćwiczenie 4**
Zainstaluj bibliotekę ``weather-api`` (https://pypi.python.org/pypi/weather-api). Korzystając z niej:
* Wypisz informacje o aktualnej pogodzie.
* Napisz funkcję, która zamieni stopnie ``F`` na ``C``.
* Korzystając z prognozy, znajdź dzień, w którym będzie najzimniej. Wypisz nazwę tygodnia (w języku polskim) i temperaturę w C.
"""
#task04
from weather import Weather
DD = {'Mon':'Poniedziałek','Tue':'Poniedziałek','Wed':'Środa','Thu':'Czwartek','Fri':'Piątek','Sat':'Sobota','Sun':'Niedziela'}
MM = {'Jan':'Styczeń','Feb':'Luty','Mar':'Marzec','Apr':'Kwiecień','May':'Maj','Jun':'Czerwiec','Jul':'Lipiec','Aug':'Sierpień','Sep':'Wrzesień','Oct':'Październik','Nov':'Listopad','Dec':'Grudzień'}
def ConvertF_TO_C (F):
conF = round((float(F) - 32) / 1.8,1)
return conF
weather = Weather()
miasto ='Poznań'
location = weather.lookup_by_location(miasto)
condition = location.condition()
OgolnieP = condition.text()
dataP = condition.date()
TempC = ConvertF_TO_C(condition.temp())
ddayD=dataP.split(',')[0]
dday=dataP.split(' ')[1]
MMonth=dataP.split(' ')[2]
YYYY=dataP.split(' ')[3]
print"Data = ", dday, '-',MM[MMonth], '-', YYYY, " ", DD[ddayD]
print "Pogoda ogólnie (ang.) = ", OgolnieP
print "Temperatura = ", TempC, " C"
forcst = location.forecast()
tmin = condition.temp()
dmin = condition.date()
for fc in forcst:
if fc.low() < tmin:
dmin = fc.date()
tmin = fc.low()
print("Prognoza:")
dmin = dmin.split(' ')
MMonth=dmin[1]
print "Min temp: ", tmin, " C"
print "W dniu: ",dmin[0] , "-",MM[MMonth] ,'-', dmin[2]

28
labs03/task05.py Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#task05
import os
import glob
BLEUValue = 0
BLEUFileMax = ''
for Fname in glob.glob(os.getcwd() + '\scores\*.bleu'):
with open(Fname, 'r') as fp:
#print(fp.name)
for lineFile in fp:
iList=lineFile
iList= iList.split(',')
#print(iList)
BLEUValueTmp = iList[0][7:]
BLEUValueTmp = float(BLEUValueTmp)
#print(BLEUValueTmp)
if BLEUValueTmp > BLEUValue:
BLEUValue = BLEUValueTmp
BLEUFileMax = fp.name
fp.close
print "Max:", BLEUValue
print "File Name: ", BLEUFileMax

View File

@ -309,13 +309,13 @@
{ {
"ename": "AttributeError", "ename": "AttributeError",
"evalue": "'Parser' object has no attribute '__parse'", "evalue": "'Parser' object has no attribute '__parse'",
"output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", "\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;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'" "\u001b[0;31mAttributeError\u001b[0m: 'Parser' object has no attribute '__parse'"
] ],
"output_type": "error"
} }
], ],
"source": [ "source": [
@ -465,13 +465,13 @@
{ {
"ename": "FileNotFoundError", "ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: 'nieistniejący_plik.txt'", "evalue": "[Errno 2] No such file or directory: 'nieistniejący_plik.txt'",
"output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", "\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;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'" "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'nieistniejący_plik.txt'"
] ],
"output_type": "error"
} }
], ],
"source": [ "source": [
@ -614,13 +614,13 @@
{ {
"ename": "MyError", "ename": "MyError",
"evalue": "Coś poszło nie tak!", "evalue": "Coś poszło nie tak!",
"output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mMyError\u001b[0m Traceback (most recent call last)", "\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;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!" "\u001b[0;31mMyError\u001b[0m: Coś poszło nie tak!"
] ],
"output_type": "error"
} }
], ],
"source": [ "source": [

View File

@ -1,3 +1,11 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
def isNumeric(x):
for i in range(len(x)):
if isinstance(x[i], (int , float ))==False:
return False
return True
print(isNumeric([1,4,4.8,1]))

View File

@ -1,3 +1,58 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class Employee:
id_prac = 0
def __init__ (self,imie, nazwisko):
Employee.id_prac += 1
self.imie = imie
self.nazwisko = nazwisko
self.id_prac = Employee.id_prac
def get_id (self):
return self.id_prac
class Recruiter (Employee):
def __int__(self,imieR, nazwiskoR):
Employee.__init__(self,imieR, nazwiskoR)
self.recruited=[]
def recruit(self,id):
self.recruited.append(id)
def __str__(self):
return '<Rekruter %s,%s,%s>' % (self.imieR, self.nazwiskoR, self.recruited)
class Programmer(Recruiter):
def __int__(self,imieP,nazwiskoP,rekruter):
Recruiter.__init__(self,imieP,nazwiskoP)
Recruiter.id_prac = rekruter
def __str__(self):
return '<Programista %s,%s, został zrekrutowany przez rekrutera o ID = >' % (self.imieP, self.nazwiskoP, Recruiter.id_prac)
prac1 = Employee("X1","Y1")
prac2 = Employee("X2","Y2")
prac3 = Employee("XY","Y3")
print(prac1.get_id())
print(prac2.get_id())
print(prac3.get_id())
print(Employee.id_prac )
prac4 = Recruiter('Rek1', 'RekN1')
print(prac4.imie)
print(prac4.nazwisko)
print(prac4.id_prac)
#to mi jeszcze nie działa
#prac5 = Programmer('Bozena','Bozeniasta', 4)
#print(prac5.imie)
#print(prac5.nazwisko)
#print(prac5.id_prac)
#print(prac5.get_id())

View File

@ -1,3 +1,28 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
class DimensionError(Exception):
def __init__(self):
super().__init__(self)
self.msg = 'Błąd !!!'
class Point():
def __int__(self,wspolrzedne):
if self.isNumeric(wspolrzedne):
self.wspolrzedne = wspolrzedne
else:
self.wspolrzedne = None
def isNumeric(x):
for i in range(len(x)):
if isinstance(x[i], (int, float)) == False:
return False
return True
pkt1 = Point([1, 1, 1])
pkt2 = Point([3, 3, 3])

View File

@ -2,10 +2,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
def suma(liczby): def suma(liczby):
pass return sum(liczby)
def main(): def main():
print(summa([1, 2, 3, 4])) print(suma([1, 2, 3, 4]))
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import task00
import sys
def main():
print(sys.argv)
task00.suma()
if __name__ == "__main__":
main()

View File

@ -1,14 +1,38 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import pandas as pd
def wczytaj_dane(): def wczytaj_dane():
pass rooms_data = pd.read_csv('mieszkania.csv', # ścieżka do pliku
sep=',', # separator
encoding='utf-8', # kodowanie
index_col='Id') # ustawienie indeksu na kolumnę Date
return rooms_data
def most_common_room_number(dane): def most_common_room_number(dane):
pass d=dane['Rooms']
d= d.value_counts()
j=0
"""
for i in d:
print d.index[j] , i
j +=1
"""
d = d.index[0]
return d
def cheapest_flats(dane, n): def cheapest_flats(dane, n):
pass SortDane = dane.sort_values('Expected',ascending=True)
PriceCheapest = SortDane['Expected']
PriceCheapest = PriceCheapest.head(n)
return PriceCheapest
def find_borough(desc): def find_borough(desc):
dzielnice = ['Stare Miasto', dzielnice = ['Stare Miasto',
@ -19,36 +43,74 @@ def find_borough(desc):
'Winogrady', 'Winogrady',
'Miłostowo', 'Miłostowo',
'Dębiec'] 'Dębiec']
pass for district in dzielnice:
if district in desc: return district
return 'Inne'
def add_borough(dane): def add_borough(dane):
pass boroughArr = []
for current_location in dane:
findborough = find_borough(current_location)
#print current_location , findborough
boroughArr.append(findborough)
return pd.Series(boroughArr)
def write_plot(dane, filename): def write_plot(dane, filename):
pass add_borough(dane)
hist_data = dane['Borough'].value_counts()
Hist_out = hist_data.plot(kind='bar', alpha=0.5, title="Appartments in Distrinct",fontsize=5, figsize=(7, 5))
fig = Hist_out.get_figure()
fig.savefig(filename)
def mean_price(dane, room_number): def mean_price(dane, room_number):
pass AVGdane = dane[dane.Rooms == room_number]
AVGdane = round(AVGdane.Expected.mean(),2)
return AVGdane
def find_13(dane): def find_13(dane):
pass add_borough(dane)
List_13 = []
WhatLookFor = dane['Borough'].loc[dane['Floor'] == 13]
for j in WhatLookFor:
List_13.append(j)
return List_13
def find_best_flats(dane): def find_best_flats(dane):
pass add_borough(dane)
TheBest = dane[(dane.Borough == 'Winogrady') & (dane.Rooms == 3) & (dane.Floor == 1)]
return TheBest
def main(): def main():
dane = wczytaj_dane() dane = wczytaj_dane()
print(dane[:5]) #print(dane[:5])
print("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
print ("Najpopularniejsza liczba pokoi w mieszkaniu to: {}"
.format(most_common_room_number(dane))) .format(most_common_room_number(dane)))
print("{} to najłądniejsza dzielnica w Poznaniu." 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: {}" print("Średnia cena mieszkania 3-pokojowego, to: {}"
.format(mean_price(dane, 3))) .format(mean_price(dane, 3)))
roomCheapest = cheapest_flats(dane, 5)
print roomCheapest
district = add_borough(dane['Location'])
dane['Borough'] = district.values
#print(dane[:5])
write_plot(dane, 'plot.png')
list_13 = find_13(dane)
print list_13
TheBestFlat = find_best_flats(dane)
print TheBestFlat['Location']
if __name__ == "__main__": if __name__ == "__main__":
main() main()