{"id":19972,"date":"2022-12-15T00:00:48","date_gmt":"2022-12-14T23:00:48","guid":{"rendered":"https:\/\/annaf34.sg-host.com\/?p=19972"},"modified":"2022-11-30T10:34:58","modified_gmt":"2022-11-30T09:34:58","slug":"zmienne-stosowane-w-pythonie","status":"publish","type":"post","link":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/","title":{"rendered":"Zmienne stosowane w Pythonie"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"19972\" class=\"elementor elementor-19972\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2fc49cf elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2fc49cf\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a7beb05\" data-id=\"a7beb05\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-8fd51fd elementor-widget elementor-widget-text-editor\" data-id=\"8fd51fd\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong>Zmienna to miejsce w pami\u0119ci, kt\u00f3re wskazuje na jak\u0105\u015b warto\u015b\u0107.<\/strong>Cho\u0107 samo poj\u0119cie zmiennych trudno zrozumie\u0107 \u201cna sucho\u201d, w edytorze kodu szybko wszystko staje si\u0119 jasne, bo ze zmiennymi mamy do czynienia ca\u0142y czas!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1d8bb79 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1d8bb79\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-23be850\" data-id=\"23be850\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-55de693 elementor-widget elementor-widget-image\" data-id=\"55de693\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"540\" height=\"540\" src=\"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/IMG_1999_ok_resize-540x540-1.jpg\" class=\"attachment-large size-large wp-image-19973\" alt=\"\" srcset=\"https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/IMG_1999_ok_resize-540x540-1.jpg 540w, https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/IMG_1999_ok_resize-540x540-1-300x300.jpg 300w, https:\/\/codecool.com\/wp-content\/uploads\/2021\/12\/IMG_1999_ok_resize-540x540-1-150x150.jpg 150w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-832a9d5 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"832a9d5\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4dc8339\" data-id=\"4dc8339\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1fdf5b4 elementor-widget elementor-widget-heading\" data-id=\"1fdf5b4\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Zmienne i ich typy<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-566aa14 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"566aa14\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-953c270\" data-id=\"953c270\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1a2495d elementor-widget elementor-widget-text-editor\" data-id=\"1a2495d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Zmiennych u\u017cywamy, \u017ceby nie operowa\u0107 na konkretnych warto\u015bciach. Poj\u0119cie zmiennej t\u0142umaczymy naszym studentom obrazowo jako pude\u0142ko na buty oznaczone symbolem X, w kt\u00f3rym schowane s\u0105 potrzebne nam dane. Inaczej mo\u017cemy obja\u015bni\u0107 zmienne jako wydzielone miejsce w pami\u0119ci komputera, w kt\u00f3rym mo\u017cemy przechowywa\u0107 jak\u0105\u015b warto\u015b\u0107: liczb\u0119, string ( \u0142a\u0144cuch znak\u00f3w, czyli s\u0142owo albo zdanie), kolekcj\u0119, list\u0119 lub s\u0142ownik.<\/p><p><strong>Istnieje pi\u0119\u0107 typ\u00f3w zmiennych w Pythonie, z kt\u00f3rych korzystaj\u0105 programi\u015bci:<\/strong><\/p><ul><li>Najbardziej og\u00f3lny to none, czyli nic,<\/li><li>Typ boolean \u2013 czyli tak albo nie, prawda albo fa\u0142sz, 0 albo 1<\/li><li>Typ liczbowy \u2013 integer (typ ca\u0142kowity) albo float (typ zmiennoprzecinkowy)<\/li><li>Typ string \u2013 typ znakowy (jedna litera lub ci\u0105g znak\u00f3w)<\/li><li>Kolekcja \u2013 lista, tupla, s\u0142ownik<\/li><li>Funkcja<\/li><\/ul><p>\u00a0<\/p><p>Je\u017celi masz do\u015bwiadczenie w typowanych j\u0119zykach programowania takich jak <a href=\"https:\/\/codecool.com\/pl\/wiedza\/javascript-gdzie-wykorzystuje-sie-js-codecool-pl\/\" target=\"_blank\" rel=\"noopener\">Java<\/a> czy C#, to w <a href=\"https:\/\/codecool.com\/pl\/wiedza\/programowanie-w-python\/\" target=\"_blank\" rel=\"noopener\">Pythonie<\/a> zaskoczy Ci\u0119, \u017ce programuj\u0105c, nie b\u0119dziesz musia\u0142 okre\u015bla\u0107 typu zmiennej. Oznacza to, \u017ce Python jest j\u0119zykiem typowanym dynamicznie. Ma to swoje plusy i minusy &#8211; zdecydowan\u0105 zalet\u0105 jest, \u017ce pisanie kodu w Pythonie jest przyjemniejsze. Minus? Mo\u017cemy si\u0119 dowiedzie\u0107, \u017ce co\u015b nie dzia\u0142a, dopiero po uruchomieniu, a nie od razu. Jak si\u0119 nie pomyli\u0107? Dobry edytor kodu, taki jak <a href=\"https:\/\/codecool.com\/pl\/wiedza\/pycharm-czym-jest-codecool-pl\/\" target=\"_blank\" rel=\"noopener\">PyCharm<\/a>, pomo\u017ce nam w programowaniu bez b\u0142\u0119d\u00f3w.<\/p><p><strong>Zainteresuje Ci\u0119 r\u00f3wnie\u017c:<\/strong><a href=\"https:\/\/codecool.com\/pl\/wiedza\/funkcje-i-ich-deklarowanie-w-pythonie\/\" target=\"_blank\" rel=\"noopener\"> Funkcje Pythona<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-f21072a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"f21072a\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-eec3e6e\" data-id=\"eec3e6e\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-23af6e7 elementor-widget elementor-widget-heading\" data-id=\"23af6e7\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Deklaracja zmiennych w Pythonie<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-859b644 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"859b644\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-60ea6c1\" data-id=\"60ea6c1\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f9914df elementor-widget elementor-widget-text-editor\" data-id=\"f9914df\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Zadaniem programisty jest rozpoznanie, kt\u00f3ry typ zmiennej musi zastosowa\u0107.<\/p><p>Przyk\u0142adowo, gdy chcieliby\u015bmy policzy\u0107 ilo\u015b\u0107 student\u00f3w w klasie, tworzymy zmienn\u0105 o nazwie <i>Liczba student\u00f3w<\/i>, kt\u00f3r\u0105 potem sukcesywnie powi\u0119kszamy o +1, gdy w naszej klasie pojawia si\u0119 nowy student. Taka zmienna b\u0119dzie <strong>zmienn\u0105 liczbow\u0105.<\/strong><\/p><p>Z kolei w zmiennej typu string mo\u017cemy przechowywa\u0107 s\u0142owa, napisy. W naszym przypadku b\u0119d\u0105 to imiona student\u00f3w. Kolejnym typem zmiennej jest <strong>lista<\/strong>&#8211; zbi\u00f3r zmiennych. Lista to taka zmienna, kt\u00f3ra przechowuje wiele innych zmiennych. Mo\u017ce zawiera\u0107 duplikaty (dwie takie same pozycje). Inaczej jest w przypadku s\u0142ownika, w kt\u00f3rym ka\u017cda pozycja mo\u017ce wyst\u0105pi\u0107 tylko raz. W szkole mo\u017ce si\u0119 przecie\u017c zdarzy\u0107, \u017ce b\u0119dziemy mieli dw\u00f3ch Jan\u00f3w Kowalskich. R\u00f3\u017cni\u0107 ich b\u0119dzie numer PESEL, kt\u00f3ry zapiszemy w S\u0142owniku o nazwie \u201c<i>Dziennik uczni\u00f3w<\/i>\u201d.<\/p><p><strong>Deklaracj\u0105 zmiennej w Pythonie<\/strong> okre\u015blamy nazwanie zmiennej i przypisanie do niej warto\u015bci.<\/p><pre>imi\u0119 = Jan<br \/>nazwisko = Kowalski<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-6aab03a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"6aab03a\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-63c2fde\" data-id=\"63c2fde\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-b646923 elementor-widget elementor-widget-heading\" data-id=\"b646923\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Napisy jako zmienne<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-89c6ead elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"89c6ead\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-cdc7feb\" data-id=\"cdc7feb\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f276dd7 elementor-widget elementor-widget-text-editor\" data-id=\"f276dd7\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<pre>Na liczbach i stringach mo\u017cna wykonywa\u0107 proste operacje, np. je \u0142\u0105czy\u0107: &lt;--- To nie powinno by\u0107 sformatowane tak jak kod, tylko zwyk\u0142ym tekstem<br \/><br \/>witaj = \"witaj\"<br \/>swiecie = \"swiecie\"<br \/>witajswiecie = witaj + \" \" + swiecie<\/pre><p>Dodanie do siebie r\u00f3\u017cnych typ\u00f3w zmiennych zazwyczaj spowoduje b\u0142\u0105d programu. Jak temu zaradzi\u0107? Je\u017celi chcemy doda\u0107 liczb\u0119 do stringu, to musimy j\u0105 \u201cprzerzutowa\u0107\u201d, czyli zamieni\u0107 liczb\u0119 na string. Aby zamieni\u0107 liczb\u0119 na string, musimy u\u017cy\u0107 funkcji <i>str<\/i><b>, <\/b>kt\u00f3ra rzutuje warto\u015b\u0107.<\/p><pre>dziennik = [(90,\"Piotr\"),(91,\"Katarzyna\")]<br \/>iloscUczniow = len(dziennik)<br \/>text = \"W naszej klasie jest \" + str(iloscUczniow) + \" uczniow.\"<br \/>print(text)<\/pre>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2fe8d12 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2fe8d12\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-cc9b591\" data-id=\"cc9b591\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fffc04d elementor-widget elementor-widget-heading\" data-id=\"fffc04d\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Liczby jako zmienne<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2e5b113 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2e5b113\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-cb0197c\" data-id=\"cb0197c\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f4d620e elementor-widget elementor-widget-text-editor\" data-id=\"f4d620e\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Liczby mog\u0105 by\u0107 ca\u0142kowite albo zmiennoprzecinkowe. Nale\u017cy uwa\u017ca\u0107, aby do zmiennoprzecinkowych nie wpisywa\u0107 warto\u015bci pieni\u0119\u017cnych, bo liczba zmiennoprzecinkowa jest liczb\u0105, kt\u00f3ra ma zmienn\u0105 precyzj\u0119. Od lat funkcjonuje s\u0142ynny \u017cart programist\u00f3w \u201cIle to jest 0.1+0.2\u201d. Dzieje si\u0119 tak dlatego, \u017ce w komputerach mamy system binarny (0 i 1), kt\u00f3ry nie radzi sobie z zaokr\u0105gleniem dziesi\u0119tnym.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1cca84e elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1cca84e\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d441c75\" data-id=\"d441c75\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-647ed78 elementor-widget elementor-widget-heading\" data-id=\"647ed78\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Przyk\u0142adowe \u0107wiczenia na zmienne<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c112872 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"c112872\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4bad943\" data-id=\"4bad943\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-edafc7a elementor-widget elementor-widget-text-editor\" data-id=\"edafc7a\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Zmienne pojawiaj\u0105 si\u0119 we wszystkich programistycznych zadaniach i nasz <a href=\"https:\/\/codecool.com\/pl\/okursach\/\" target=\"_blank\" rel=\"noopener\">kurs programowania<\/a> nie jest tu wyj\u0105tkiem. Najprostsze \u0107wiczenia na zmienne w Pythonie to:<\/p><ul><li>Wypisz najwi\u0119ksz\u0105 liczb\u0119 z ci\u0105gu znak\u00f3w<\/li><li>Wypisz liter\u0119, kt\u00f3ra najcz\u0119\u015bciej wyst\u0119puje w zdaniu<\/li><\/ul><p>Aby wykona\u0107 takie zadanie, studenci kursu programowania musz\u0105 wymy\u015bli\u0107 algorytm post\u0119powania- jak najprostszy, kt\u00f3ry b\u0119d\u0105 w stanie wyt\u0142umaczy\u0107 \u017c\u00f3\u0142tej kaczuszce lub dziecku. Algorytm taki b\u0119dzie uniwersalny dla wszystkich j\u0119zyk\u00f3w programowania. Oczywi\u015bcie w ka\u017cdym j\u0119zyku zakoduje go si\u0119 inaczej, bo u\u017cyje si\u0119 innych struktur w j\u0119zyku, ale opis b\u0119dzie taki sam.<\/p><p>Najciekawszym \u0107wiczeniem na zmienne w Pythonie jest Hangman, czyli wisielec &#8211; prosta gra, w kt\u00f3rej trzeba odgadn\u0105\u0107 s\u0142owo. Gdy zgadujemy \u017ale, program zaczyna rysowa\u0107 kolejne elementy wisielca.<\/p><p>Dowiedz si\u0119 wi\u0119cej: <a href=\"https:\/\/codecool.com\/pl\/wiedza\/srodowisko-programistyczne-czym-jest-codecool-pl\/\" target=\"_blank\" rel=\"noopener\">Czym jest \u015brodowisko developerskie?<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-065d0c1 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"065d0c1\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8609291\" data-id=\"8609291\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5a93c36 elementor-widget elementor-widget-heading\" data-id=\"5a93c36\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Podsumowanie<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3877d10 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3877d10\" data-element_type=\"section\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-97b8f93\" data-id=\"97b8f93\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-0079385 elementor-widget elementor-widget-text-editor\" data-id=\"0079385\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Zmienna to jedno z podstawowych poj\u0119\u0107 w programowaniu w Python, a tak\u017ce w innych j\u0119zykach. Zmienna jest etykiet\u0105, do kt\u00f3rej przypisuje si\u0119 jak\u0105\u015b warto\u015b\u0107. Ka\u017cda zmienna w Pythonie jest obiektem. Programi\u015bci na ka\u017cdym kroku maj\u0105 do czynienia ze zmiennymi. Ich zadaniem jest rozpoznanie typu zmiennej i prawid\u0142owe jej zastosowanie.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Zmienna to miejsce w pami\u0119ci, kt\u00f3re wskazuje na jak\u0105\u015b warto\u015b\u0107.Cho\u0107 samo poj\u0119cie zmiennych trudno zrozumie\u0107 \u201cna sucho\u201d, w edytorze kodu szybko wszystko staje si\u0119 jasne, bo ze zmiennymi mamy do czynienia ca\u0142y czas! Zmienne i ich typy Zmiennych u\u017cywamy, \u017ceby nie operowa\u0107 na konkretnych warto\u015bciach. Poj\u0119cie zmiennej t\u0142umaczymy naszym studentom obrazowo jako pude\u0142ko na buty [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":51817,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[133],"tags":[],"class_list":["post-19972","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wiedza"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.4 (Yoast SEO v24.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Zmienne stosowane w Pythonie - Codecool<\/title>\n<meta name=\"description\" content=\"Poj\u0119cie zmiennych pojawia si\u0119 niemal w ka\u017cdym j\u0119zyku, a w Pythonie oznacza obiekt. Przeczytaj artyku\u0142 i dowiedz si\u0119 wiecej o zmiennych w Pythonie.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/\" \/>\n<meta property=\"og:locale\" content=\"pl_PL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Zmienne stosowane w Pythonie\" \/>\n<meta property=\"og:description\" content=\"Poj\u0119cie zmiennych pojawia si\u0119 niemal w ka\u017cdym j\u0119zyku, a w Pythonie oznacza obiekt. Przeczytaj artyku\u0142 i dowiedz si\u0119 wiecej o zmiennych w Pythonie.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/\" \/>\n<meta property=\"og:site_name\" content=\"Codecool\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/CodecoolOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-14T23:00:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codecool.com\/wp-content\/uploads\/2019\/02\/33.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dora Hoffman\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Codecool_global\" \/>\n<meta name=\"twitter:site\" content=\"@Codecool_global\" \/>\n<meta name=\"twitter:label1\" content=\"Napisane przez\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dora Hoffman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Szacowany czas czytania\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minuty\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Zmienne stosowane w Pythonie - Codecool","description":"Poj\u0119cie zmiennych pojawia si\u0119 niemal w ka\u017cdym j\u0119zyku, a w Pythonie oznacza obiekt. Przeczytaj artyku\u0142 i dowiedz si\u0119 wiecej o zmiennych w Pythonie.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/","og_locale":"pl_PL","og_type":"article","og_title":"Zmienne stosowane w Pythonie","og_description":"Poj\u0119cie zmiennych pojawia si\u0119 niemal w ka\u017cdym j\u0119zyku, a w Pythonie oznacza obiekt. Przeczytaj artyku\u0142 i dowiedz si\u0119 wiecej o zmiennych w Pythonie.","og_url":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/","og_site_name":"Codecool","article_publisher":"https:\/\/www.facebook.com\/CodecoolOfficial\/","article_published_time":"2022-12-14T23:00:48+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/codecool.com\/wp-content\/uploads\/2019\/02\/33.jpg","type":"image\/jpeg"}],"author":"Dora Hoffman","twitter_card":"summary_large_image","twitter_creator":"@Codecool_global","twitter_site":"@Codecool_global","twitter_misc":{"Napisane przez":"Dora Hoffman","Szacowany czas czytania":"4 minuty"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#article","isPartOf":{"@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/"},"author":{"name":"Dora Hoffman","@id":"https:\/\/codecool.com\/pl\/#\/schema\/person\/622e226c942203940586ef2dceca8365"},"headline":"Zmienne stosowane w Pythonie","datePublished":"2022-12-14T23:00:48+00:00","mainEntityOfPage":{"@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/"},"wordCount":766,"commentCount":0,"publisher":{"@id":"https:\/\/codecool.com\/pl\/#organization"},"image":{"@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#primaryimage"},"thumbnailUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2019\/02\/33.jpg","articleSection":["Wiedza"],"inLanguage":"pl-PL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/","url":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/","name":"Zmienne stosowane w Pythonie - Codecool","isPartOf":{"@id":"https:\/\/codecool.com\/pl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#primaryimage"},"image":{"@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#primaryimage"},"thumbnailUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2019\/02\/33.jpg","datePublished":"2022-12-14T23:00:48+00:00","description":"Poj\u0119cie zmiennych pojawia si\u0119 niemal w ka\u017cdym j\u0119zyku, a w Pythonie oznacza obiekt. Przeczytaj artyku\u0142 i dowiedz si\u0119 wiecej o zmiennych w Pythonie.","breadcrumb":{"@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#breadcrumb"},"inLanguage":"pl-PL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/"]}]},{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#primaryimage","url":"https:\/\/codecool.com\/wp-content\/uploads\/2019\/02\/33.jpg","contentUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2019\/02\/33.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/codecool.com\/pl\/zmienne-stosowane-w-pythonie\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codecool.com\/pl\/"},{"@type":"ListItem","position":2,"name":"Zmienne stosowane w Pythonie"}]},{"@type":"WebSite","@id":"https:\/\/codecool.com\/pl\/#website","url":"https:\/\/codecool.com\/pl\/","name":"Codecool","description":"Next gen coding school &amp; career hub","publisher":{"@id":"https:\/\/codecool.com\/pl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codecool.com\/pl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pl-PL"},{"@type":"Organization","@id":"https:\/\/codecool.com\/pl\/#organization","name":"Codecool","alternateName":"Codecool","url":"https:\/\/codecool.com\/pl\/","logo":{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/codecool.com\/pl\/#\/schema\/logo\/image\/","url":"https:\/\/codecool.com\/wp-content\/uploads\/2023\/09\/Codecool-logo-app.svg","contentUrl":"https:\/\/codecool.com\/wp-content\/uploads\/2023\/09\/Codecool-logo-app.svg","width":1,"height":1,"caption":"Codecool"},"image":{"@id":"https:\/\/codecool.com\/pl\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/CodecoolOfficial\/","https:\/\/x.com\/Codecool_global","https:\/\/www.instagram.com\/codecool_official\/","https:\/\/www.linkedin.com\/school\/codecool\/"]},{"@type":"Person","@id":"https:\/\/codecool.com\/pl\/#\/schema\/person\/622e226c942203940586ef2dceca8365","name":"Dora Hoffman","image":{"@type":"ImageObject","inLanguage":"pl-PL","@id":"https:\/\/codecool.com\/pl\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/13d568fb246033721321e216b8f5f06457e373d046558ceccec33b2e0dc025bc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/13d568fb246033721321e216b8f5f06457e373d046558ceccec33b2e0dc025bc?s=96&d=mm&r=g","caption":"Dora Hoffman"}}]}},"_links":{"self":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts\/19972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/comments?post=19972"}],"version-history":[{"count":8,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts\/19972\/revisions"}],"predecessor-version":[{"id":58586,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/posts\/19972\/revisions\/58586"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/media\/51817"}],"wp:attachment":[{"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/media?parent=19972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/categories?post=19972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codecool.com\/pl\/wp-json\/wp\/v2\/tags?post=19972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}