{"id":1594,"date":"2018-05-11T19:09:59","date_gmt":"2018-05-11T17:09:59","guid":{"rendered":"http:\/\/yarogniew.net\/arduino\/?page_id=1594"},"modified":"2018-05-11T19:11:17","modified_gmt":"2018-05-11T17:11:17","slug":"python-3-pierwsze-kroki","status":"publish","type":"page","link":"https:\/\/arduino.net.pl\/index.php\/python-3\/python-3-pierwsze-kroki\/","title":{"rendered":"Python 3 &#8211; pierwsze kroki"},"content":{"rendered":"<h6>Krok pierwszy:<\/h6>\n<p><em>funkcja print i type, stringi, listy, wy\u015bwietlanie znak\u00f3w specjalnych<\/em><\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n\r\n# tak piszemy komentarz\r\n\r\nprint(&quot;pierwsza linia\\ndruga linia&quot;)\r\n# pierwsza linia\r\n# druga linia\r\n\r\nprint(r&quot;pierwsza linia\\ndruga linia&quot;) # r (raw strings)\r\n# pierwsza linia\\ndruga linia\r\n\r\nnazwy_miesiecy = &#x5B;'Januari', 'Februari', 'Maart',      # These are the\r\n               'April',   'Mei',      'Juni',       # Dutch names\r\n               'Juli',    'Augustus', 'September',  # for the months\r\n               'Oktober', 'November', 'December']   # of the year\r\n\r\nprint(nazwy_miesiecy&#x5B;0])\r\nprint(type(nazwy_miesiecy&#x5B;0]))\r\n# Januari\r\n# &lt;class 'str'&gt;\r\n\r\nprint(nazwy_miesiecy&#x5B;3:6])\r\nprint(type(nazwy_miesiecy&#x5B;3:6]))\r\n# &#x5B;'April', 'Mei', 'Juni']\r\n# &lt;class 'list'&gt;\r\n\r\nprint(nazwy_miesiecy&#x5B;7:])\r\n# &#x5B;'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December']\r\n\r\nprint(nazwy_miesiecy&#x5B;-2:])\r\n# &#x5B;'November', 'December']\r\n\r\nprint(nazwy_miesiecy&#x5B;:])\r\n# &#x5B;'Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December']\r\n\r\ntekst = &quot;Python to wspania\u0142y j\u0119zyk programowania&quot;\r\nprint(tekst&#x5B;:9],tekst&#x5B;20:] )\r\nprint(type(tekst&#x5B;:9]))\r\n# Python to j\u0119zyk programowania\r\n# &lt;class 'str'&gt;\r\n<\/pre>\n<h6>Krok drugi:<\/h6>\n<p><em>funkcja ord i chr, warunek if else, p\u0119tle while i for, funkcje enumerate, range<\/em><\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n# Pierwsze kroki, cz\u0119\u015b\u01072\r\n\r\ntekst = &quot;Janina&quot;\r\n\r\nprint(tekst&#x5B;2])\r\n# n\r\nprint(ord(tekst&#x5B;2]))\r\n# 110\r\nprint(type(chr(110)))\r\n# &lt;class 'str'&gt;\r\n\r\n############# IF - ELSE #########\r\nx = 10 &gt; 5\r\n\r\nif (x):\r\n    \r\n    print(&quot;PRAWDA&quot;)\r\nelse:\r\n\r\n    \r\n    print(&quot;FA\u0141SZ&quot;)\r\n\r\n# PRAWDA    \r\nprint(type(x))\r\n# &lt;class 'bool'&gt;\r\n\r\n############ WHILE BREAK #############\r\ni = 8\r\nwhile i &gt; 0:\r\n    print(i)\r\n    i -= 1\r\n# 8 7 6 5 4 3 2 1\r\n############ FOR - IN ENUMERATE RANGE BREAK CONTINUE ##############\r\n\r\nlista_kolorow = &#x5B;&quot;bia\u0142y&quot;, &quot;czarny&quot;, &quot;czerwony&quot;, &quot;niebieski&quot;]\r\n\r\nfor kolor in lista_kolorow:\r\n    print(kolor)\r\n\r\n# bia\u0142y\r\n# czarny\r\n# czerwony\r\n# niebieski\r\n\r\nfor numer, kolor in enumerate(lista_kolorow, start=1):\r\n    if numer == 4:\r\n        break      # przerywa wykonywanie p\u0119tli\r\n    if kolor == &quot;czerwony&quot;:\r\n        continue         # opuszcza blok poni\u017cej i wraca do nag\u0142\u00f3wka p\u0119tli\r\n    print(numer,&quot; - &quot;, kolor)\r\n\r\n# 1  -  bia\u0142y\r\n# 2  -  czarny\r\n\r\nfor i in range(1, 10, 2):\r\n    print(i)\r\n# 1 3 5 7 9\r\n<\/pre>\n<h6>Krok trzeci:<\/h6>\n<p><em>if in, if not, and, or, True, False<\/em><\/p>\n<pre class=\"brush: python; light: false; title: Kod:; toolbar: true; notranslate\" title=\"Kod:\">\r\n\r\n# Pierwsze kroki, cz\u0119\u015b\u01073\r\n\r\n\r\nlista_kolorow = &#x5B;&quot;bia\u0142y&quot;, &quot;czarny&quot;, &quot;czerwony&quot;, &quot;niebieski&quot;]\r\n\r\ntekst = &quot;Lubi\u0119 kolor {} oraz {}&quot;   \r\nnowy_tekst = tekst.format(lista_kolorow&#x5B;0], lista_kolorow&#x5B;3])\r\nprint(nowy_tekst, &quot;\\n&quot;)\r\n\r\n# Lubi\u0119 kolor bia\u0142y oraz niebieski       \r\n\r\n# ------- IF - IN   ELIF-------------\r\n\r\nif &quot;czarny&quot; in lista_kolorow:\r\n    print(&quot;znaleziono&quot;)\r\nelse:\r\n    print(&quot;nie znaleziono&quot;)\r\n\r\nif not &quot;zielony&quot; in lista_kolorow:\r\n    print(&quot;nie znalaz\u0142am zielonego&quot;)\r\nelse:\r\n    print(&quot;znalaz\u0142am zielony&quot;)\r\n\r\n\r\nprint('Wpisz kolor:')\r\nkolor = input()\r\nif kolor in lista_kolorow:\r\n    print(&quot;znalaz\u0142am &quot;, kolor)\r\nelif &quot;czerwony&quot; in lista_kolorow:\r\n    print(&quot;nie znalaz\u0142am &quot;, kolor, &quot;ale mam czerwony, chcesz?&quot;)\r\nelse:\r\n    print(&quot;nic nie znaleziono&quot;)\r\n\r\n# ------- and, or, True, False -------------\r\n\r\nif True and True:\r\n    print(&quot;prawda&quot;)\r\n\r\nif True or False:\r\n    print(&quot;prawda&quot;)\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Krok pierwszy: funkcja print i type, stringi, listy, wy\u015bwietlanie znak\u00f3w specjalnych # tak piszemy komentarz print(&quot;pierwsza linia\\ndruga linia&quot;) # pierwsza linia # druga linia print(r&quot;pierwsza linia\\ndruga linia&quot;) # r (raw&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":1588,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-1594","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=1594"}],"version-history":[{"count":2,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1594\/revisions"}],"predecessor-version":[{"id":1596,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1594\/revisions\/1596"}],"up":[{"embeddable":true,"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/pages\/1588"}],"wp:attachment":[{"href":"https:\/\/arduino.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=1594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}