1
0
forked from tdwojak/Python2017

task06 passed

This commit is contained in:
Ewelina 2017-11-27 00:29:45 +01:00
parent fea63c37b7
commit 53c2cb3f5f
2 changed files with 60 additions and 5 deletions

View File

@ -30,6 +30,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -43,6 +44,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -76,6 +78,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -110,6 +113,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -130,6 +134,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -146,6 +151,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -177,6 +183,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
@ -207,6 +214,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -221,6 +229,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -235,6 +244,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -260,6 +270,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -291,6 +302,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -320,6 +332,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -348,6 +361,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -362,6 +376,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -387,6 +402,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -415,6 +431,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -433,6 +450,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -458,6 +476,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -472,6 +491,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -509,6 +529,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -526,6 +547,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -553,6 +575,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -570,6 +593,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -595,13 +619,21 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Wiadomość\n"
]
}
],
"source": [ "source": [
"napis = \"Wiadomość\"\n", "napis = \"Wiadomość\"\n",
"print(napis)" "print(napis)"
@ -609,13 +641,29 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 3,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"W 87\n",
"i 105\n",
"a 97\n",
"d 100\n",
"o 111\n",
"m 109\n",
"o 111\n",
"ś 347\n",
"ć 263\n"
]
}
],
"source": [ "source": [
"for znak in napis:\n", "for znak in napis:\n",
" print(znak, ord(znak))" " print(znak, ord(znak))"
@ -625,6 +673,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
@ -641,6 +690,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "slide" "slide_type": "slide"
} }
@ -655,6 +705,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }
@ -669,6 +720,7 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"slideshow": { "slideshow": {
"slide_type": "fragment" "slide_type": "fragment"
} }

View File

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