{"id":5522,"date":"2012-09-12T20:34:35","date_gmt":"2012-09-13T00:34:35","guid":{"rendered":"http:\/\/cscircles.cemc.uwaterloo.ca\/?page_id=5522"},"modified":"2022-06-01T05:18:57","modified_gmt":"2022-06-01T09:18:57","slug":"12-de","status":"publish","type":"page","link":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/12-de\/","title":{"rendered":"12: Tipps"},"content":{"rendered":"<p>Diese Lektion beinhaltet ein paar Fakten \u00fcber die Sprache Python, die wir in fr\u00fcheren Lektionen ausgelassen haben.<\/p>\n<h2><code>print<\/code> Optionen<\/h2>\n<p>Bis jetzt haben wir als einzige M\u00f6glichkeit zur Ausgabe die <code>print()<\/code> Funktion kennengelernt. Sie gibt normalerweise mehrere Elemente in einer Zeile aus und trennt die Elemente durch Leerzeichen. Es ist aber so, dass <code>print()<\/code> ein paar <em>Schl\u00fcsselwort-Argumente<\/em> akzeptiert, die du nutzen kannst, um dieses Verhalten nach deinen Bed\u00fcrfnissen zu modifizieren.<\/p>\n<ul>\n<li>Um die Elemente nicht mit einem Leerzeichen sondern mit einem anderen String <code>S<\/code> zu trennen, gib das Argument <code><\/code><code>sep = \u00abS\u00bb<\/code> an.<\/li>\n<li>Um nach der Ausgabe aller Elemente statt eines Zeilenwechsels einen anderen String <code>S<\/code> auszugeben, verwende das Argument <code><\/code><code>end = \u00abS\u00bb<\/code>.<\/li>\n<\/ul>\n<p>Diese neue Eigenschaft, die wir <em>Schl\u00fcsselwort-Argumente<\/em> nennen (engl: <em>keyword arguments<\/em>), ist am einfachsten mit ein paar Beispielen zu demonstrieren.<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform0\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox0'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Beispiele von <code>sep<\/code> und <code>end<\/code>. Schau dir den Effekt an, den jeder Aufruf von <code>print<\/code> hat.<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 136px;'><textarea wrap='off' name='usercode0' id='usercode0'  cols=10 rows=5 readonly='readonly'  style = 'height : 136px;'  class='pyboxCode RO'>\nprint('D', 'A', 'S', 'H', sep='-')\nprint('Der Preis ist $', 12*5, sep='')\nprint('Diese zwei Zeilen', end='')\nprint(' werden zusammen ausgedruckt.')\nprint('Great', end='!')<\/textarea><\/div>\n<div id='pbhistory0' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit0' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(0)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(0,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse0\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"0\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"6f8fb7f0f726c34b7e3aa8d74e26678e\"\/>\n<div id='pbresults0' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit0\").value = \"Run program\";document.getElementById(\"inputInUse0\").value = \"N\";<\/script>\n<\/p>\n<p>Diese Schl\u00fcsselwort-Argumente m\u00fcssen am Ende der Argumentliste stehen, oder ein <a href=\"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/console\/?consolecode=print%28end%3D%27%27%2C%205%29\" target=\"_blank\">error<\/a> wird auftreten. Die Reihenfolge der Schl\u00fcsselwort-Argumente untereinander ist aber egal.<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform1\" method=\"POST\">\n<div class='pybox modeNeutral ' id='pybox1'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Coding Exercise: <\/span><span class='title'>Alphabet Aerobics<\/span><\/div>Verwende, was wir gerade eingef\u00fchrt haben, und debugge das folgende Programm so, dass es das Alphabet in Gro\u00dfbuchstaben <em>in einer einzigen Zeile<\/em> ausgibt.<div class=\"helpOuter\" style=\"display: none;\"><div class=\"helpInner\"><div style=\"text-align: center\">You need to create an account and log in to ask a question.<\/div><\/div><\/div><div class='pyboxTextwrap pyboxCodewrap RW resizy'  style='height: 526px;'><textarea wrap='off' name='usercode1' id='usercode1'  cols=10 rows=20   class='pyboxCode RW'>\nfor c in range(0, 26):\n print(chr(ord('A')+c))\n<\/textarea><\/div>\n<div id='pbhistory1' class='flexcontain' style='display:none;'><\/div>\n<input type='hidden' id='defaultCode1' value='for c in range(0, 26):\\n print(chr(ord(\\u0027A\\u0027)+c))\\n'><\/input>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit1' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(1)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(1,'N')\" ><\/td>\n<td><input type='button' name='history' value=\"History\" onclick=\"historyClick(1,'12.alphabet')\" ><\/td>\n<\/tr><\/table><select id='pbSelect1' class='selectmore'><option name='more'>More actions...<\/option>\n<option name='default' data-pbonclick=\"pbSetText(1,descape($('#defaultCode1').val()))\" >Reset code to default<\/option>\n<option name='help' data-pbonclick=\"helpClick(1);\" >Help<\/option>\n<\/select><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse1\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"1\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"10370b99c2ad70623e6b0664ee756f9e\"\/>\n<div id='pbresults1' class='pbresults avoidline'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>jQuery(function(){pbToggleCodeMirror(1);});document.getElementById(\"submit1\").value = \"Run program\";document.getElementById(\"inputInUse1\").value = \"N\";<\/script>\n<\/p>\n<h2>Zul\u00e4ssige Variablen-\/Funktionennamen<\/h2>\n<ul>\n<li>Namen k\u00f6nnen Buchstaben, Zahlen und den Unterstrich (<code>_<\/code>) enthalten.<\/li>\n<li>Das erste Zeichen jedes Namen muss ein Buchstabe sein.<\/li>\n<li>Python unterscheidet zwischen Gro\u00df- und Kleinbuchstaben.<\/li>\n<\/ul>\n<p>So ist <code>my_3rd_int<\/code> ein zul\u00e4ssiger Variablenname, aber <code>3rd_int<\/code> ist keiner.<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform2\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox2'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Ein Beispiel davon, wie man zwischen Gro\u00df- und Kleinbuchstaben unterscheiden kann\/muss.<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 84px;'><textarea wrap='off' name='usercode2' id='usercode2'  cols=10 rows=3 readonly='readonly'  style = 'height : 84px;'  class='pyboxCode RO'>\ngreaterOde = \"Truth is beauty, beauty truth\"\ngreatErode = \"Wind erosion\"\nprint(greaterOde) # still poetry<\/textarea><\/div>\n<div id='pbhistory2' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit2' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(2)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(2,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse2\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"2\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"045208e9dc7dd2820a91bab0e459ef7b\"\/>\n<div id='pbresults2' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit2\").value = \"Run program\";document.getElementById(\"inputInUse2\").value = \"N\";<\/script>\n<\/p>\n<h2>Absteigende <code>for<\/code> Schleifen &amp; andere Abstufungen<\/h2>\n<p>Erinnere dich daran, dass wir gezeigt haben, wie <code>for<\/code> Schleifen Zahlen in aufsteigender Reihenfolge durchgehen k\u00f6nnen:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform3\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox3'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Eine <code>for<\/code> Schleife<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode3' id='usercode3'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nfor i in range(0, 5):\n print(i)<\/textarea><\/div>\n<div id='pbhistory3' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit3' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(3)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(3,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse3\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"3\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"48e0123a12ad2574217df6c6fcebe640\"\/>\n<div id='pbresults3' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit3\").value = \"Run program\";document.getElementById(\"inputInUse3\").value = \"N\";<\/script>\n<\/p>\n<p>Oft ist es notwendig, eine <code>for<\/code> Schleife zu schreiben, die die Zahlen in <em>absteigender<\/em> Reihenfolge durchl\u00e4uft (von der gr\u00f6\u00dften zur kleinsten Zahl). Um dies zu machen, rufen wir <code>range<\/code> auf, zusammen mit einem dritten Argument, das <em>step<\/em> genannt wird:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform4\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox4'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Negativer step f\u00fcr <code>range<\/code><div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode4' id='usercode4'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nfor i in range(5, 1, -1):\n print(i)<\/textarea><\/div>\n<div id='pbhistory4' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit4' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(4)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(4,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse4\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"4\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"61f7b1cfa7128b1075811c3bc806df3a\"\/>\n<div id='pbresults4' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit4\").value = \"Run program\";document.getElementById(\"inputInUse4\").value = \"N\";<\/script>\n<\/p>\n<p>Wenn du kurz nachdenkst, f\u00e4llt dir sicher auf, dass <code>range(0, 5)<\/code> das gleiche ist wie <code>range(0, 5, 1)<\/code>: die <em>Standardabstufung<\/em> ist 1. In beiden F\u00e4llen solltest du sicher stellen, dass <code>range(start, stop, step)<\/code> nur gerade so weit geht, <em>bis kurz bevor<\/em> es den Wert <code>stop<\/code> erreicht. Wenn du mehr Informationen brauchst, schaust du dir am besten das <a href=\"http:\/\/docs.python.org\/py3k\/library\/functions.html#range\">Python manual<\/a> an.<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform5\" method=\"POST\">\n<div class='pybox modeNeutral ' id='pybox5'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Coding Exercise: <\/span><span class='title'>Lucky Sevens<\/span><\/div>Schreibe ein Programm, bei dem du eine <code>for<\/code> Schleife verwendest mit der Stufengr\u00f6\u00dfe 10, um alle zweistelligen Zahlen aufzulisten, die auf 7 enden, in aufsteigender Reihenfolge.<div class=\"helpOuter\" style=\"display: none;\"><div class=\"helpInner\"><div style=\"text-align: center\">You need to create an account and log in to ask a question.<\/div><\/div><\/div><div class='pyboxTextwrap pyboxCodewrap RW resizy'  style='height: 526px;'><textarea wrap='off' name='usercode5' id='usercode5'  cols=10 rows=20   class='pyboxCode RW'>\n# delete this comment and enter your code here\n<\/textarea><\/div>\n<div id='pbhistory5' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit5' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(5)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(5,'N')\" ><\/td>\n<td><input type='button' name='history' value=\"History\" onclick=\"historyClick(5,'12.sevens')\" ><\/td>\n<\/tr><\/table><select id='pbSelect5' class='selectmore'><option name='more'>More actions...<\/option>\n<option name='help' data-pbonclick=\"helpClick(5);\" >Help<\/option>\n<\/select><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse5\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"5\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"3ddfe6a0b90f746bba2e0701b5b798d4\"\/>\n<div id='pbresults5' class='pbresults avoidline'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>jQuery(function(){pbToggleCodeMirror(5);});document.getElementById(\"submit5\").value = \"Run program\";document.getElementById(\"inputInUse5\").value = \"N\";<\/script>\n<\/p>\n<p>In \u00e4hnlicher Weise kannst du <code>string[x:y:-1]<\/code> verwenden, um einen umgekehrten Teil eines Strings zu erhalten, oder <code>string[x:y:2]<\/code>, f\u00fcr den Substring mit den Zeichen <code>x, x+2, x+4, ...<br \/>\n<\/code><\/p>\n<p>Mit einer <code>for<\/code> Schleife ist <code>reversed(range(x, y))<\/code> eine andere M\u00f6glichkeit, eine absteigende Reichweite zu erreichen, die von <code>y-1<\/code> bis <code>x<\/code> in absteigender Reihenfolge geht.<\/p>\n<h2>Kleineren Code schreiben<\/h2>\n<p>Python bietet unterschiedliche M\u00f6glichkeiten, um k\u00fcrzeren Code zu schreiben; wir f\u00fchren hier ein paar davon ein.<\/p>\n<p><table class='pywarn'><tr><td class='pywarnleft'><img src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/warning.png'\/><\/td><td class='pywarnright'><span> Auf dieser Seite werden wir nicht immer diese Eigenschaften benutzen, da es manchmal dazu f\u00fchrt, dass Code schwerer zu lesen ist. <\/span><\/td><\/table><\/p>\n<h3>\u00dcbertragungs-Operatoren<\/h3>\n<p>Python erlaubt es dir, \"<code>x += 1<\/code>\" zu schreiben, was bedeutet \"f\u00fcge eins zu <code>x<\/code> hinzu.\" Es ist gleichwertig mit \"<code>x = x + 1<\/code>\" wie wir unten zeigen:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform6\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox6'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Beispiele von <code>+=<\/code>, <code>-=<\/code>, <code>*=<\/code>, <code>\/=<\/code><div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 240px;'><textarea wrap='off' name='usercode6' id='usercode6'  cols=10 rows=9 readonly='readonly'  style = 'height : 240px;'  class='pyboxCode RO'>\nx = 8\nx += 2\nprint(x)\nx -= 1\nprint(x)\nx \/= 3\nprint(x)\nx *= 10\nprint(x)<\/textarea><\/div>\n<div id='pbhistory6' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit6' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(6)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(6,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse6\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"6\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"657dbfafceda6ebf4bb45614201a5a12\"\/>\n<div id='pbresults6' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit6\").value = \"Run program\";document.getElementById(\"inputInUse6\").value = \"N\";<\/script>\n<\/p>\n<p>Gleicherma\u00dfen gibt es Operatoren f\u00fcr die Division von ganzen Zahlen (<code>\/\/=<\/code>), Teilungsrest (<code>%=<\/code>), und Potenz (<code>**=<\/code>).<\/p>\n<h3>Inline Bl\u00f6cke<\/h3>\n<p>Wir haben mehrere Statements gesehen, auf die einger\u00fcckte \"Bl\u00f6cke\" von Code folgen: <code>for<\/code>, <code>if<\/code>, <code>else<\/code>, <code>elif<\/code>, <code>while<\/code>, und <code>def<\/code>, zum Beispiel:<\/p>\n<pre>if x==y:\n  \u00abblock\u00bb #indented, multiline<\/pre>Im Sonderfall. dass <code>\u00abblock\u00bb<\/code> nur eine Zeile lang ist, erlaubt es Python, die folgende alternative Syntax zu verwenden:<\/p>\n<pre>if x==y: \u00abblock\u00bb #single line<\/pre>Hier ist ein Beispiel:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform7\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox7'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Inline Block Statements<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode7' id='usercode7'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\ndef square(x): return x*x\nfor i in range(0, 6): print(square(i))<\/textarea><\/div>\n<div id='pbhistory7' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit7' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(7)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(7,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse7\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"7\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"b3ade191aee4175bf56777c569c34c2f\"\/>\n<div id='pbresults7' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit7\").value = \"Run program\";document.getElementById(\"inputInUse7\").value = \"N\";<\/script>\n<\/p>\n<p>Dies hat allerdings Grenzen: ein zusammenh\u00e4ngender Block mit einem Doppelpunkt (<code>if<\/code>, <code>for<\/code>, etc) kann nicht als Inline Block verwendet werden. Zum Beispiel, <code>if 2&gt;1: if 4&gt;3: print()<\/code> ergibt einen Syntax<a href=\"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/console\/?consolecode=if%202%26gt%3B1%3A%20if%204%26gt%3B3%3A%20print%28%29\" target=\"_blank\">fehler<\/a>.<\/p>\n<h3>Mehrere Aufgaben<\/h3>\n<p>Python erlaubt es dir, zwei Statements mit Aufgaben zu einem einzigen Statement zu kombinieren:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform8\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox8'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Mehrere Aufgaben<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode8' id='usercode8'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nx, y = 3, 4\nprint('x =', x, 'and y =', y)<\/textarea><\/div>\n<div id='pbhistory8' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit8' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(8)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(8,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse8\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"8\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"4c8e080f4888bb5c86d52fe2d2145597\"\/>\n<div id='pbresults8' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit8\").value = \"Run program\";document.getElementById(\"inputInUse8\").value = \"N\";<\/script>\n<\/p>\n<p>Beachte, dass dies es dir erlaubt, unsere <a href=\"https:\/\/cscircles.cemc.uwaterloo.ca\/1-de\/\">\u00dcbung mit dem Tausch<\/a> mit einer einzigen Zeile zu l\u00f6sen!<\/p>\n<h3>Verkettungen von Vergleichen<\/h3>\n<p>Python erlaubt es dir auch, mehrere Vergleiche zu einem einzigen zu kombinieren:<br \/>\n<form class=\"pbform\" action=\"#\" id=\"pbform9\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox9'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Mehrere Aufgaben<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 84px;'><textarea wrap='off' name='usercode9' id='usercode9'  cols=10 rows=3 readonly='readonly'  style = 'height : 84px;'  class='pyboxCode RO'>\nage = int(input())\nif 12 &lt; age &lt; 20: # same as (12 &lt; age) and (age &lt; 20) \n print('Du bist ein Teenager!')<\/textarea><\/div>\n<div id='pbhistory9' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit9' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(9)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(9,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse9\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"9\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"099cfccf6cbbf30479a6da0a6681cb3b\"\/>\n<div id='pbresults9' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit9\").value = \"Run program\";document.getElementById(\"inputInUse9\").value = \"N\";<\/script>\nJede Kette <code>v1 c1 v2 c2 v3 ...<\/code> bei der <code>v<\/code> Werte sind und <code>c<\/code> Vergleiche, wird genauso behandelt wie <code>(v1 c1 v2) and (v2 c2 v3) and...<\/code><\/p>\n<h3>Normale Werte f\u00fcr <code>[:]<\/code> und <code>range()<\/code><\/h3>\n<p>Du kannst einen oder beide der start\/end-Werte weglassen, wenn du den sub-string-Operator <code>[:]<\/code> benutzt.<br \/>\n(Dies gilt auch f\u00fcr Listen, wie wir sie in der n\u00e4chsten Lektion sehen werden.)<br \/>\nDer normale Wert des ersten Index ist <code>0<\/code> (Anfang des strings)<br \/>\nund der normale Wert des letzten Index ist die L\u00e4nge des strings. Ebenso ist <code>range(n)<\/code> kurz f\u00fcr <code>range(0, n)<\/code>.<br \/>\n<form class=\"pbform\" action=\"#\" id=\"pbform10\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox10'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Nutzt die normalen Werte f\u00fcr <code>[:]<\/code> und <code>range()<\/code><div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 110px;'><textarea wrap='off' name='usercode10' id='usercode10'  cols=10 rows=4 readonly='readonly'  style = 'height : 110px;'  class='pyboxCode RO'>\nS = \"Toronto\"\nprint(S[3:]) # rechter substring, \"onto\"\nprint(S[:2]) # linker substring, \"To\"\nfor i in range(5): print(i*i) # prints 0, 1, .. 16<\/textarea><\/div>\n<div id='pbhistory10' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit10' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(10)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(10,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse10\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"10\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"b1d75e1e0aac851f599363036d17e59d\"\/>\n<div id='pbresults10' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit10\").value = \"Run program\";document.getElementById(\"inputInUse10\").value = \"N\";<\/script>\n<\/p>\n<h1><code>None<\/code><\/h1>\n<p>Einige Funktionen sind haupts\u00e4chlich dazu da, einen Wert auszugeben, wie z.B. <code>abs(x)<\/code>. Andere Funktionen, die n\u00fctzlicher sind in ihren Auswirkungen, wie zum Beispiel <code>print()<\/code>, geben dennoch den 'Standardwert' <code>None<\/code> aus:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform11\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox11'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Der Wert von <code>print<\/code><div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 136px;'><textarea wrap='off' name='usercode11' id='usercode11'  cols=10 rows=5 readonly='readonly'  style = 'height : 136px;'  class='pyboxCode RO'>\nresult = print('Anything works here')\nprint(result)\ndef forgotToReturn(x):\n x*x\nprint(forgotToReturn(5))<\/textarea><\/div>\n<div id='pbhistory11' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit11' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(11)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(11,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse11\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"11\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"9b7f3f4bb01953a5fbbe924ce2aee475\"\/>\n<div id='pbresults11' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit11\").value = \"Run program\";document.getElementById(\"inputInUse11\").value = \"N\";<\/script>\n<\/p>\n<p>Hier ist <code>None<\/code> ein besonderer Wert, der von Python als Platzhalter verwendet wird. Wenn du <a href=\"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/console\/?consolecode=print%28type%28None%29%29\" target=\"_blank\">type(None) aufrufst<\/a>, wirst du herausfinden, dass <code>None<\/code> sogar seine eigene Type hat, <code>NoneType<\/code>. Und wenn wir schon dabei sind, lass uns herausfinden, was der Typ einer Typenvariable ist:<\/p>\n<p><form class=\"pbform\" action=\"#\" id=\"pbform12\" method=\"POST\">\n<div class='pybox modeNeutral  facultative' id='pybox12'>\n<div class=\"heading\"><span class=\"title\">Example<\/span><\/div>Die Type einer Type<div class='pyboxTextwrap pyboxCodewrap RO '  style='height: 58px;'><textarea wrap='off' name='usercode12' id='usercode12'  cols=10 rows=2 readonly='readonly'  style = 'height : 58px;'  class='pyboxCode RO'>\nx = 23432\nprint(x, type(x), type(type(x)), type(type(type(x))))<\/textarea><\/div>\n<div id='pbhistory12' class='flexcontain' style='display:none;'><\/div>\n<div class='pyboxbuttons'><table><tr>\n<td><input type='submit' name='submit' id='submit12' value=' '\/><\/td>\n<td><input type='button' name='consolecopy' value=\"Open in console\" onclick=\"pbConsoleCopy(12)\" ><\/td>\n<td><input type='button' name='visualize' value=\"Visualize\" onclick=\"pbVisualize(12,'N')\" ><\/td>\n<\/tr><\/table><\/div>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" id=\"inputInUse12\" name=\"inputInUse\" value=\"Y\"\/>\n<input type=\"hidden\" name=\"pyId\" value=\"12\"\/>\n<input type=\"hidden\" name=\"hash\" value=\"aea32d11990220cd2435630a82e7da88\"\/>\n<div id='pbresults12' class='pbresults'><\/div>\n<\/div>\n<\/form>\n<script type='text\/javascript'>document.getElementById(\"submit12\").value = \"Run program\";document.getElementById(\"inputInUse12\").value = \"N\";<\/script>\n<\/p>\n<p>In der n\u00e4chsten \u00dcbung bitten wir dich, die Ergebnisse eines langen Befehls zu \u00fcberpr\u00fcfen, bei dem sowohl <code>type<\/code> als auch <code>print<\/code> verwendet wird.<\/p>\n<div class='pybox modeNeutral multiscramble' id='pybox13'>\n<img title='You have not yet completed this problem.' src='https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-content\/plugins\/pybox\/files\/icon.png' class='pycheck'\/><div class=\"heading\"><span class='type'>Scramble Exercise: <\/span><span class='title'>One None<\/span><\/div>Der Output von <code>print(type(print(type(type(print(print()))))))<\/code> besteht aus 4 Zeilen. Ordne sie in der richtigen Reihenfolge.<ul class=\"pyscramble\" name=\"pyscramble\" id=\"pyscramble13\">\n<li id=\"pyli13_3\" class=\"pyscramble\" >&lt;class 'NoneType'&gt;<\/li>\n<li id=\"pyli13_1\" class=\"pyscramble\" >None<\/li>\n<li id=\"pyli13_0\" class=\"pyscramble\" ><i>&laquo;blank line&raquo;<\/i><\/li>\n<li id=\"pyli13_2\" class=\"pyscramble\" >&lt;class 'type'&gt;<\/li>\n<\/ul>\n<div class=\"pyboxbuttons\"><input type='button' value='Check answer' onclick='pbMultiscrambleCheck(13)'\/>\n<input type=\"hidden\" name=\"lang\" value=\"\"\/><input type=\"hidden\" name=\"slug\" value=\"12.ordering\"\/>\n<\/div><div id=\"pbresults13\" class=\"pbresults\"><\/div><div class=\"epilogue\">Correct!<\/div><\/div>\n<p>Das sind erstmal alle Tipps. Du bist jetzt soweit, zur n\u00e4chsten Lektion zu gehen!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Diese Lektion beinhaltet ein paar Fakten \u00fcber die Sprache Python, die wir in fr\u00fcheren Lektionen ausgelassen haben. print Optionen Bis jetzt haben wir als einzige M\u00f6glichkeit zur Ausgabe die print() Funktion kennengelernt. Sie gibt normalerweise mehrere Elemente in einer Zeile &hellip; <a href=\"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/12-de\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2653,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5522","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages\/5522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/users\/2653"}],"replies":[{"embeddable":true,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/comments?post=5522"}],"version-history":[{"count":24,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages\/5522\/revisions"}],"predecessor-version":[{"id":15728,"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/pages\/5522\/revisions\/15728"}],"wp:attachment":[{"href":"https:\/\/cscircles.cemc.uwaterloo.ca\/dev\/wp-json\/wp\/v2\/media?parent=5522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}