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",
"execution_count": 10,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"123\n",
"[1, 2, 3, 1, 2, 3]\n"
]
}
],
"outputs": [],
"source": [
"def dwojak(x): x *= 2\n",
" \n",
@ -113,22 +104,13 @@
},
{
"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",
"[1, 2, 3]\n"
]
}
],
"outputs": [],
"source": [
"def dwojak1(x): x *= 2\n",
"def dwojak2(x): x = x * 2\n",
@ -144,21 +126,13 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, 4]\n"
]
}
],
"outputs": [],
"source": [
"l = [1, 2, 3]\n",
"e = l\n",
@ -168,21 +142,13 @@
},
{
"cell_type": "code",
"execution_count": 15,
"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",
@ -206,22 +172,13 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(1, 'napis', None)\n",
"3\n"
]
}
],
"outputs": [],
"source": [
"t = (1, \"napis\", None)\n",
"elem = t[0]\n",
@ -242,33 +199,13 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"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"
}
],
"outputs": [],
"source": [
"def suma(*args):\n",
" return sum(args)\n",
@ -294,24 +231,13 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a\n",
"b\n",
"c\n",
"d\n"
]
}
],
"outputs": [],
"source": [
"def alfaRange(x, y):\n",
" for i in range(ord(x), ord(y)):\n",
@ -334,23 +260,13 @@
},
{
"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"
]
}
],
"outputs": [],
"source": [
"plik = open(\"haslo.txt\", 'r')\n",
"for linia in plik.readlines():\n",
@ -361,24 +277,13 @@
},
{
"cell_type": "code",
"execution_count": 44,
"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"
]
}
],
"outputs": [],
"source": [
"with open(\"haslo.txt\", 'r') as plik:\n",
" for linia in plik.readlines():\n",
@ -388,8 +293,9 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "slide"
}
@ -428,22 +334,13 @@
},
{
"cell_type": "code",
"execution_count": 57,
"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",
@ -454,31 +351,13 @@
},
{
"cell_type": "code",
"execution_count": 64,
"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": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from collections import *\n",
"print(Counter(\"konstantynopolitańczykowianeczka\"))\n",
@ -487,6 +366,75 @@
"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",
"execution_count": null,