Compare commits

...

5 Commits

Author SHA1 Message Date
Magdalena Lewandowicz
3624beaac4 zadanie 2018-06-23 17:06:27 +02:00
Magdalena Lewandowicz
04cc66810a Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2018 2018-06-03 11:23:00 +02:00
Magdalena Lewandowicz
42b8cda889 Merge branch 'master' of https://git.wmi.amu.edu.pl/tdwojak/Python2018 2018-06-03 09:59:45 +02:00
Magdalena Lewandowicz
10ddbf40ed zadanie 2018-06-02 20:48:43 +02:00
Magdalena Lewandowicz
c1a510a707 Zadania 7-11 2018-05-29 18:50:29 +02:00
7 changed files with 77 additions and 20 deletions

View File

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

View File

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

View File

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

View File

@ -7,9 +7,17 @@ Napisz funkcję pokemon_speak, która zamienia w podanym napisie co drugą liter
na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
"""
def pokemon_speak(text):
pass
text2=""
b=""
a = len(text)
for i in range(a):
if (i % 2 == 0):
b = text[i].upper()
text2 += b
else:
text2 += text[i]
return text2
def tests(f):

View File

@ -9,8 +9,17 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
def common_chars(string1, string2):
pass
list1=[]
for i in string1:
if i in string2:
list1.append(i)
for i in string2:
if i in string1:
list1.append(i)
list1=list(set(list1))
list1.sort()
list1.pop(0)
return list1
def tests(f):
inputs = [["this is a string", "ala ma kota"]]

16
labs04/zadanie5.py Normal file
View File

@ -0,0 +1,16 @@
import glob
pliki = glob.glob('scores/*')
wyniki = []
for plik in pliki:
f = open(plik, 'r')
tekst = f.readline()
tekst = tekst.split(" ")
tekst = [x.strip(",") for x in tekst]
wyniki.append(tekst[2])
f.close()
index = wyniki.index(max(wyniki))
sciezka = pliki[index]
print(sciezka)

35
labs06/task02.py Executable file → Normal file
View File

@ -1,15 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
import matplotlib.pyplot as plt
def wczytaj_dane():
pass
dane = pd.read_csv("./mieszkania.csv")
return dane
def most_common_room_number(dane):
pass
return dane.Rooms.value_counts().idxmax()
def cheapest_flats(dane, n):
pass
return dane.sort('Expected').head(n)
def find_borough(desc):
dzielnice = ['Stare Miasto',
'Wilda',
@ -19,23 +23,30 @@ def find_borough(desc):
'Winogrady',
'Miłostowo',
'Dębiec']
pass
for dzielnica in dzielnice:
list = desc.split(' ')
for element in list:
if len(element) > 2 and element == dzielnica:
return dzielnica
break
return "Inne"
def add_borough(dane):
pass
dane['Borough'] = dane['Location'].apply(find_borough)
return dane
def write_plot(dane, filename):
pass
dane['Borough'].value_counts().plot.bar().get_figure().savefig(filename)
def mean_price(dane, room_number):
pass
mean_price = dane.Expected[(dane['Rooms'] == room_number)]
return mean_price.mean()
def find_13(dane):
pass
return dane.Location[(dane['Floor'] == 13)].unique()
def find_best_flats(dane):
pass
return dane[(dane['Location'] == 'Winogrady') & (dane['Rooms'] == 3) & (dane['Floor'] == 1)]
def main():
dane = wczytaj_dane()
@ -45,7 +56,7 @@ def main():
.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)))