Compare commits

...

8 Commits

Author SHA1 Message Date
puderniczka
b281bcfeef Merge https://git.wmi.amu.edu.pl/tdwojak/Python2018 2018-06-03 20:03:01 +02:00
puderniczka
6394f96098 task03 done 2018-06-02 23:11:47 +02:00
puderniczka
73ec835b5e task10, task11, test_task done 2018-06-02 22:57:30 +02:00
puderniczka
b1a003874e task08, task09 done 2018-06-02 22:22:16 +02:00
puderniczka
c9dd223315 task06, task07 done 2018-06-02 22:13:16 +02:00
puderniczka
102e7db81e task04, task05 done 2018-06-02 22:04:03 +02:00
puderniczka
7cab28e194 task01, task02 done 2018-06-02 21:48:37 +02:00
puderniczka
170aa04df1 intro_task done 2018-06-02 21:36:10 +02:00
19 changed files with 170 additions and 28 deletions

11
.idea/Python2018.iml Normal file
View 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>

14
.idea/misc.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.6 (/usr/bin/python2.7)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View 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/Python2018.iml" filepath="$PROJECT_DIR$/.idea/Python2018.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -131,7 +131,9 @@
}
},
"outputs": [],
"source": []
"source": [
""
]
},
{
"cell_type": "code",
@ -150,7 +152,9 @@
]
}
],
"source": []
"source": [
""
]
},
{
"cell_type": "code",
@ -250,7 +254,9 @@
]
}
],
"source": []
"source": [
""
]
},
{
"cell_type": "code",
@ -261,7 +267,9 @@
}
},
"outputs": [],
"source": []
"source": [
""
]
},
{
"cell_type": "code",
@ -594,7 +602,7 @@
"if zmienna < 0:\n",
" print(\"Ujemna!\")\n",
"elif zmienna == 0:\n",
" print(\"Zero!\")\n"
" print(\"Zero!\")"
]
},
{
@ -786,7 +794,7 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
"version": 3.0
},
"file_extension": ".py",
"mimetype": "text/x-python",
@ -797,5 +805,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 1
}
"nbformat_minor": 0
}

View File

@ -131,7 +131,9 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
""
]
}
],
"metadata": {
@ -144,7 +146,7 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
"version": 3.0
},
"file_extension": ".py",
"mimetype": "text/x-python",
@ -155,5 +157,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 1
}
"nbformat_minor": 0
}

View File

@ -9,48 +9,66 @@ Zadania wprowadzające do pierwszych ćwiczeń.
"""
Wypisz na ekran swoje imię i nazwisko.
"""
print('Joanna Malińska')
"""
Oblicz i wypisz na ekran pole koła o promienie 10. Jako PI przyjmij 3.14.
"""
r = 10
pi = 3.14
print(pi * r **2)
"""
Stwórz zmienną pole_kwadratu i przypisz do liczbę: pole kwadratu o boku 3.
"""
pole_kwadratu = 3 ** 2
print(pole_kwadratu)
"""
Stwórz 3 elementową listę, która zawiera nazwy 3 Twoich ulubionych owoców.
Wynik przypisz do zmiennej `owoce`.
"""
owoce = ['truskawki', 'borówki', 'mango']
print(owoce)
"""
Dodaj do powyższej listy jako nowy element "pomidor".
"""
owoce.append('pomidor')
print(owoce)
"""
Usuń z powyższej listy drugi element.
"""
owoce.pop(1)
print(owoce)
"""
Rozszerz listę o tablice ['Jabłko', "Gruszka"].
"""
owoce.extend(['Jabłko', "Gruszka"])
print(owoce)
"""
Wyświetl listę owoce, ale bez pierwszego i ostatniego elementu.
"""
print(owoce[1:-1]) # i=1, i < -1, i++; -1 to ostatni element
"""
Wyświetl co trzeci element z listy owoce.
"""
print(owoce[::3]) # i=0, i +=3
"""
Stwórz pusty słownik i przypisz go do zmiennej magazyn.
"""
magazyn = {}
"""
Dodaj do słownika magazyn owoce z listy owoce, tak, aby owoce były kluczami,
zaś wartościami były równe 5.
"""
for o in owoce:
magazyn[o] = 5
print magazyn

View File

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

View File

@ -6,7 +6,16 @@
"""
def days_in_year(days):
pass
if days % 400 == 0:
return 366
elif days % 100 == 0:
return 365
elif days % 4 == 0:
return 366
else:
return 365
def tests(f):
inputs = [[2015], [2012], [1900], [2400], [1977]]

View File

@ -10,10 +10,18 @@ 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ń.)
"""
from sets import Set
def oov(text, vocab):
pass
w = Set()
a = text.split(' ')
for wyraz in a:
if wyraz.lower() not in vocab:
w.add(wyraz.lower())
#print w
return w

View File

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

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
"""
Napisz funkcję euclidean_distance obliczającą odległość między
@ -10,7 +10,8 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5.
"""
def euclidean_distance(x, y):
pass
return math.sqrt( (y[0]-x[0]) ** 2 + (y[1]-x[1]) ** 2 + (y[2]-x[2]) ** 2 )
def tests(f):
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):
pass
if n < 5:
return "It's not a Big 'No!'"
w = 'N'
for i in range(n):
w += 'O'
w += '!'
return w
def tests(f):
inputs = [[5], [6], [2]]

View File

@ -6,7 +6,11 @@ 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 a in text:
suma += ord(a)
#print suma
return suma
def tests(f):
inputs = [["this is a string"], ["this is another string"]]

View File

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

View File

@ -9,7 +9,20 @@ Np. leet('leet') powinno zwrócić '1337'.
def leet_speak(text):
pass
w = ''
for a in text:
if a == 'e':
w += '3'
elif a == 'l':
w += '1'
elif a == 'o':
w += '0'
elif a == 't':
w += '7'
else:
w += a
#print(w)
return w
def tests(f):

View File

@ -9,7 +9,18 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'.
def pokemon_speak(text):
pass
w = ''
for i in range(len(text)):
if i % 2 == 0:
w += text[i].upper()
else:
w += text[i]
#print w
return w
def tests(f):

View File

@ -9,7 +9,17 @@ Oba napisy będą składać się wyłacznie z małych liter.
"""
def common_chars(string1, string2):
pass
lista = []
for a in range(97,123,1):
if chr(a) in string1 and chr(a) in string2:
lista.append(chr(a))
print lista
return lista
#print(cmp(string1, string2))
#ord(string2)
print(ord('a'), 'do', ord('z'))
def tests(f):

View File

@ -6,7 +6,7 @@ def suma(a, b):
"""
Napisz funkcję, która zwraca sumę elementów.
"""
return 0
return a + b
def tests(f):
inputs = [(2, 3), (0, 0), (1, 1)]