Skip to content

Commit 3a6dabe

Browse files
author
dodo
committed
Ergänzungen zu Variablen
1 parent 808ed57 commit 3a6dabe

1 file changed

Lines changed: 76 additions & 37 deletions

File tree

Level_01/Level_1.ipynb

Lines changed: 76 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 10,
24+
"execution_count": 28,
2525
"metadata": {},
2626
"outputs": [
2727
{
@@ -39,7 +39,7 @@
3939
},
4040
{
4141
"cell_type": "code",
42-
"execution_count": 11,
42+
"execution_count": 29,
4343
"metadata": {},
4444
"outputs": [
4545
{
@@ -57,7 +57,7 @@
5757
},
5858
{
5959
"cell_type": "code",
60-
"execution_count": 12,
60+
"execution_count": 30,
6161
"metadata": {},
6262
"outputs": [
6363
{
@@ -87,7 +87,7 @@
8787
},
8888
{
8989
"cell_type": "code",
90-
"execution_count": 13,
90+
"execution_count": 31,
9191
"metadata": {},
9292
"outputs": [
9393
{
@@ -105,7 +105,7 @@
105105
},
106106
{
107107
"cell_type": "code",
108-
"execution_count": 14,
108+
"execution_count": 32,
109109
"metadata": {},
110110
"outputs": [
111111
{
@@ -134,7 +134,7 @@
134134
},
135135
{
136136
"cell_type": "code",
137-
"execution_count": 15,
137+
"execution_count": 33,
138138
"metadata": {},
139139
"outputs": [
140140
{
@@ -143,7 +143,7 @@
143143
"38"
144144
]
145145
},
146-
"execution_count": 15,
146+
"execution_count": 33,
147147
"metadata": {},
148148
"output_type": "execute_result"
149149
}
@@ -162,7 +162,7 @@
162162
},
163163
{
164164
"cell_type": "code",
165-
"execution_count": 16,
165+
"execution_count": 34,
166166
"metadata": {},
167167
"outputs": [
168168
{
@@ -198,7 +198,7 @@
198198
},
199199
{
200200
"cell_type": "code",
201-
"execution_count": 17,
201+
"execution_count": 35,
202202
"metadata": {},
203203
"outputs": [
204204
{
@@ -229,7 +229,7 @@
229229
},
230230
{
231231
"cell_type": "code",
232-
"execution_count": 18,
232+
"execution_count": 36,
233233
"metadata": {},
234234
"outputs": [
235235
{
@@ -258,7 +258,7 @@
258258
},
259259
{
260260
"cell_type": "code",
261-
"execution_count": 19,
261+
"execution_count": 37,
262262
"metadata": {},
263263
"outputs": [
264264
{
@@ -289,9 +289,18 @@
289289
]
290290
},
291291
{
292-
"cell_type": "code",
293-
"execution_count": 27,
292+
"cell_type": "markdown",
294293
"metadata": {},
294+
"source": [
295+
" Bei der Benennung von Variablen sollte darauf geachtet werden, kurze aber verständliche Variablennamen zu benutzen, da so klar ist wozu die Variable benutzt wird. Auf keinen Fall sollten Variablennamen wie `l`, `O` oder `I` benutzt werden, da die, je nach Schriftart, wie `0` oder `1` aussehen können."
296+
]
297+
},
298+
{
299+
"cell_type": "code",
300+
"execution_count": 38,
301+
"metadata": {
302+
"scrolled": false
303+
},
295304
"outputs": [
296305
{
297306
"name": "stdout",
@@ -304,12 +313,45 @@
304313
}
305314
],
306315
"source": [
307-
"# den Typen eines Wertes kann mit type() bestimmt werden:\n",
316+
"# den Typen eines Wertes können wir mit type() bestimmt werden:\n",
308317
"print(type(\"a\"))\n",
309318
"print(type(2))\n",
310319
"print(type(4.8))"
311320
]
312321
},
322+
{
323+
"cell_type": "markdown",
324+
"metadata": {},
325+
"source": [
326+
"Python besitzt eine streng dynamische Typisierung, das heißt:\n",
327+
"\n",
328+
"1. Eine Variable kann auf Werte verschiedenen Typs zeigen.\n",
329+
"2. Jedes Objekt hat einen Typ.\n",
330+
"\n",
331+
"Bei jeder neuen Zuweisung wird der Wert einer Variable überschrieben, dabei kann sich der Typ des Werts ändern."
332+
]
333+
},
334+
{
335+
"cell_type": "code",
336+
"execution_count": 39,
337+
"metadata": {},
338+
"outputs": [
339+
{
340+
"name": "stdout",
341+
"output_type": "stream",
342+
"text": [
343+
"<class 'str'>\n",
344+
"<class 'int'>\n"
345+
]
346+
}
347+
],
348+
"source": [
349+
"s = \"String\"\n",
350+
"print(type(s))\n",
351+
"s = 4\n",
352+
"print(type(s))"
353+
]
354+
},
313355
{
314356
"cell_type": "markdown",
315357
"metadata": {},
@@ -320,7 +362,7 @@
320362
},
321363
{
322364
"cell_type": "code",
323-
"execution_count": 20,
365+
"execution_count": 40,
324366
"metadata": {},
325367
"outputs": [
326368
{
@@ -347,7 +389,7 @@
347389
},
348390
{
349391
"cell_type": "code",
350-
"execution_count": 28,
392+
"execution_count": 41,
351393
"metadata": {},
352394
"outputs": [
353395
{
@@ -375,7 +417,7 @@
375417
},
376418
{
377419
"cell_type": "code",
378-
"execution_count": 11,
420+
"execution_count": 42,
379421
"metadata": {},
380422
"outputs": [
381423
{
@@ -396,18 +438,15 @@
396438
},
397439
{
398440
"cell_type": "code",
399-
"execution_count": 2,
441+
"execution_count": 43,
400442
"metadata": {},
401443
"outputs": [
402444
{
403-
"data": {
404-
"text/plain": [
405-
"'########## foo ##########'"
406-
]
407-
},
408-
"execution_count": 2,
409-
"metadata": {},
410-
"output_type": "execute_result"
445+
"name": "stdout",
446+
"output_type": "stream",
447+
"text": [
448+
"########## foo ##########\n"
449+
]
411450
}
412451
],
413452
"source": [
@@ -417,7 +456,7 @@
417456
},
418457
{
419458
"cell_type": "code",
420-
"execution_count": 14,
459+
"execution_count": 44,
421460
"metadata": {},
422461
"outputs": [
423462
{
@@ -442,7 +481,7 @@
442481
},
443482
{
444483
"cell_type": "code",
445-
"execution_count": 25,
484+
"execution_count": 45,
446485
"metadata": {},
447486
"outputs": [
448487
{
@@ -469,7 +508,7 @@
469508
},
470509
{
471510
"cell_type": "code",
472-
"execution_count": 31,
511+
"execution_count": 46,
473512
"metadata": {
474513
"scrolled": true
475514
},
@@ -478,8 +517,8 @@
478517
"name": "stdout",
479518
"output_type": "stream",
480519
"text": [
481-
"Bitte etwas eingeben: 45\n",
482-
"45\n",
520+
"Bitte etwas eingeben: foo\n",
521+
"foo\n",
483522
"<class 'str'>\n"
484523
]
485524
}
@@ -500,7 +539,7 @@
500539
},
501540
{
502541
"cell_type": "code",
503-
"execution_count": 4,
542+
"execution_count": 47,
504543
"metadata": {},
505544
"outputs": [
506545
{
@@ -518,15 +557,15 @@
518557
},
519558
{
520559
"cell_type": "code",
521-
"execution_count": 1,
560+
"execution_count": 48,
522561
"metadata": {},
523562
"outputs": [
524563
{
525564
"ename": "SyntaxError",
526-
"evalue": "can't assign to keyword (<ipython-input-1-0cf028c02be4>, line 1)",
565+
"evalue": "can't assign to keyword (<ipython-input-48-0cf028c02be4>, line 1)",
527566
"output_type": "error",
528567
"traceback": [
529-
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-1-0cf028c02be4>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m True = 0 # Anzahl an Versuchen\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to keyword\n"
568+
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-48-0cf028c02be4>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m True = 0 # Anzahl an Versuchen\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to keyword\n"
530569
]
531570
}
532571
],
@@ -547,7 +586,7 @@
547586
},
548587
{
549588
"cell_type": "code",
550-
"execution_count": 10,
589+
"execution_count": 49,
551590
"metadata": {},
552591
"outputs": [
553592
{
@@ -575,7 +614,7 @@
575614
},
576615
{
577616
"cell_type": "code",
578-
"execution_count": 16,
617+
"execution_count": 1,
579618
"metadata": {},
580619
"outputs": [
581620
{

0 commit comments

Comments
 (0)