1
0
forked from tdwojak/Python2017

Fix wyklad

This commit is contained in:
Tomasz Dwojak 2017-12-02 12:43:05 +01:00
parent ba2d8c7e36
commit feac488751

View File

@ -49,22 +49,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"123\n",
"[1, 2, 3, 1, 2, 3]\n"
]
}
],
"source": [ "source": [
"def dwojak(x): x *= 2\n", "def dwojak(x): x *= 2\n",
" \n", " \n",
@ -113,22 +104,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, 1, 2, 3]\n",
"[1, 2, 3]\n"
]
}
],
"source": [ "source": [
"def dwojak1(x): x *= 2\n", "def dwojak1(x): x *= 2\n",
"def dwojak2(x): x = x * 2\n", "def dwojak2(x): x = x * 2\n",
@ -144,21 +126,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, 4]\n"
]
}
],
"source": [ "source": [
"l = [1, 2, 3]\n", "l = [1, 2, 3]\n",
"e = l\n", "e = l\n",
@ -168,21 +142,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[1], [1], [1]]\n"
]
}
],
"source": [ "source": [
"e = []\n", "e = []\n",
"f = [e for i in range(3)]\n", "f = [e for i in range(3)]\n",
@ -206,22 +172,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"(1, 'napis', None)\n",
"3\n"
]
}
],
"source": [ "source": [
"t = (1, \"napis\", None)\n", "t = (1, \"napis\", None)\n",
"elem = t[0]\n", "elem = t[0]\n",
@ -242,33 +199,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 33, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"15\n",
"a == 1\n",
"b == (3, 4)\n"
]
},
{
"data": {
"text/plain": [
"'b'"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"def suma(*args):\n", "def suma(*args):\n",
" return sum(args)\n", " return sum(args)\n",
@ -294,24 +231,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 34, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"a\n",
"b\n",
"c\n",
"d\n"
]
}
],
"source": [ "source": [
"def alfaRange(x, y):\n", "def alfaRange(x, y):\n",
" for i in range(ord(x), ord(y)):\n", " for i in range(ord(x), ord(y)):\n",
@ -334,23 +260,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 45, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"W Paryżu najlepsze kasztany są na placu Pigalle\n",
"Zuzanna lubi je tylko jesienią.\n",
"\n"
]
}
],
"source": [ "source": [
"plik = open(\"haslo.txt\", 'r')\n", "plik = open(\"haslo.txt\", 'r')\n",
"for linia in plik.readlines():\n", "for linia in plik.readlines():\n",
@ -361,24 +277,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 44, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "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"
]
}
],
"source": [ "source": [
"with open(\"haslo.txt\", 'r') as plik:\n", "with open(\"haslo.txt\", 'r') as plik:\n",
" for linia in plik.readlines():\n", " for linia in plik.readlines():\n",
@ -388,8 +293,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 48, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
@ -428,22 +334,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 57, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"posix\n",
"Nazwa uzytkownika: tomaszd\n"
]
}
],
"source": [ "source": [
"import os\n", "import os\n",
"print(os.name)\n", "print(os.name)\n",
@ -454,31 +351,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 64, "execution_count": null,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [ "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": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"from collections import *\n", "from collections import *\n",
"print(Counter(\"konstantynopolitańczykowianeczka\"))\n", "print(Counter(\"konstantynopolitańczykowianeczka\"))\n",
@ -487,6 +366,75 @@
"np.array([[1, 3, 4, 5]], dtype='float32')" "np.array([[1, 3, 4, 5]], dtype='float32')"
] ]
}, },
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Instalacja\n",
"\n",
" * lokalnie (per użytkownik) lub globalnie\n",
" * pyCharm lub linia komend, np. ``pip install --user flask`` lub ``python -m pip install --user flask``"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Wczytywanie z klawiatury"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"name = input(\"What's your name?\\n\")\n",
"print(\"Welcome home, {}.\".format(name))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"liczby = eval(input(\"Podaj liczby\"))\n",
"print(sum(liczby))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Co ominąłem?\n",
"\n",
" * klasy (jutro)\n",
" * podział programu na pliki (jutro)\n",
" "
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,