<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Unat on Medium]]></title>
        <description><![CDATA[Stories by Unat on Medium]]></description>
        <link>https://medium.com/@robuno?source=rss-e085a0d35848------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p1oX3S9KsbQciYJyP04Iqg.jpeg</url>
            <title>Stories by Unat on Medium</title>
            <link>https://medium.com/@robuno?source=rss-e085a0d35848------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:07:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@robuno/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[pycharm unresolved reference error hatası]]></title>
            <link>https://medium.com/@robuno/pycharm-unresolved-reference-error-hatas%C4%B1-13e6a839bc92?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/13e6a839bc92</guid>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Sat, 06 Feb 2021 12:31:32 GMT</pubDate>
            <atom:updated>2021-02-06T12:31:32.026Z</atom:updated>
            <content:encoded><![CDATA[<p>bu uyarının sebebi eklediğiniz global/dış paketlerin python environment’ına dahil edilmemesinden ya da pycharm’ın bu paketleri görmemesinden kaynaklanıyor.</p><p>iki çözüm yolu var. ilk yol tek tek tüm paketleri “pythonpath” çevre değişkenine eklemek. diğer yol ise daha kolay ve kurduğunuz tüm paketleri yeni çevre değişkeni oluşturarak kurmanızı sağlıyor.</p><p>“<em>file-&gt;settings-&gt;project: [project name] -&gt; project interpreter”</em> sayfasını açıyoruz ve derleyicinin ayarlarını düzenlediğimiz teker butonu ile “add python interpreter” sayesinde varsayılan olarak seçilmiş “virtualenv environment” yerine “inherit global site-packages” kutusuna tik atıyoruz. kurulum yapıldıktan sonra tüm paketler pycharm üzerinden erişilebilir/kullanılabilir hale gelecektir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13e6a839bc92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Listeler Onemli Notlar]]></title>
            <link>https://medium.com/@robuno/listeler-onemli-notlar-566472358aae?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/566472358aae</guid>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Thu, 16 Apr 2020 20:00:42 GMT</pubDate>
            <atom:updated>2020-04-16T20:00:42.131Z</atom:updated>
            <content:encoded><![CDATA[<p>Aşağıdaki döngü her elemanı tek tek ayırarak listeye ekliyor.</p><pre>isimler = [&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;]<br>numaralar = [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;]<br>liste =[]</pre><pre>for i in isimler:<br>    for j in numaralar:<br>        kart = j +&quot; of &quot;+ i<br>        <strong>liste +=kart</strong></pre><pre>print(liste)<br><strong>----------------------------------------<br></strong>[&#39;1&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;X&#39;, &#39;2&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;X&#39;, &#39;3&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;X&#39;, &#39;1&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;Y&#39;, &#39;2&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;Y&#39;, &#39;3&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;Y&#39;, &#39;1&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;Z&#39;, &#39;2&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;Z&#39;, &#39;3&#39;, &#39; &#39;, &#39;o&#39;, &#39;f&#39;, &#39; &#39;, &#39;Z&#39;]</pre><p>Aşağıdaki döngü her elemanı tek tek ayırarak listeye ekliyor.</p><pre>isimler = [&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;]<br>numaralar = [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;]<br>liste =[]</pre><pre>for i in isimler:<br>    for j in numaralar:<br>        kart = j +&quot; of &quot;+ i<br>        <strong>liste +=[kart]</strong></pre><pre>print(liste)<br>-------------------------------------<br>[<strong>&#39;1 of X&#39;</strong>, &#39;2 of X&#39;, &#39;3 of X&#39;, &#39;1 of Y&#39;, &#39;2 of Y&#39;, &#39;3 of Y&#39;, &#39;1 of Z&#39;, &#39;2 of Z&#39;, &#39;3 of Z&#39;]</pre><h4><strong>Listeyi karıştırmak</strong></h4><p><strong>1.</strong>listenin ilk elemanından başlayacak şekilde index alan bir döngü oluştur:<br><strong>for i in range(n)<br>2.</strong> random sıra indexi oluştur random.randrange(i,n)<br>!!! duplicate eleman olmaması için random sayıyı i’den başlat<br>!!! n = len(listen)<br>3. yapacağımız şey “i’nci” elemanı <strong>“randsıra”</strong> elemanıyla yer değiştirmek ama bu işlemi yaparken <strong>“randsıra”</strong> elemanınını kaybedeceğiz çünkü <strong>“i’nci” </strong>elemanı <strong>“randsıra”</strong>ya yapıştıracağız ve listede 2 tane <strong>“i’nci”</strong> eleman olacak.</p><p>bunu önlemek için<strong> liste[randsıra] = temp </strong>diyoruz. bu <strong>temp</strong>’i <strong>liste[i]</strong>’ye en son’da atıyoruz.</p><pre>import random</pre><pre>isimler = [&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;]<br>numaralar = [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;]<br>liste =[]</pre><pre>for i in isimler:<br>    for j in numaralar:<br>        kart = j +&quot; of &quot;+ i<br>        liste +=[kart]</pre><pre>n = len (liste)<br>for i in range(n):<br>    <strong>randsıra = random.randrange (i, n)  #i&#39;den başlayarak, r. eleman</strong><br>    <strong>temp = liste[randsıra]              #r. elemanı akılda tutmak</strong><br>    <strong>liste[randsıra] = liste[i]          #swap1</strong><br>    <strong>liste[i] = temp                     #swap2</strong><br>    <br>print(liste)<br><strong>--------------------------------------------------</strong><br>[&#39;1 of Y&#39;, &#39;1 of Z&#39;, &#39;2 of Z&#39;, &#39;1 of X&#39;, &#39;2 of Y&#39;, &#39;3 of X&#39;, &#39;3 of Y&#39;, &#39;2 of X&#39;, &#39;3 of Z&#39;]</pre><h4>n kişiye m tane kart dağıtmak</h4><p>toplam kart: n*m<br>n kişiye m tane kart dağıtmak için ilk kişinin alacağı son karttan sonra boşluk koymak gerekir. <strong>ilk kartımızın indexi “0”</strong> olduğuna göre:</p><p>örneğin 1 kişinin 3 kart alacağı bir sistemde oyunda;<br>ilk kişi indexi <strong>“0,1,2” </strong>olan kartları almalı ardından boşluk gelmeli. <strong>“indexi 3 “ </strong>olan karttan önce boşluk koymak için <strong>“indexi 2”</strong>olan karttan sonra boşluk koyabiliriz.</p><pre>import random<br>import sys<br>import stdio</pre><pre>x = int(sys.argv[1])<br>isimler = [&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;,&quot;T&quot;,&quot;A&quot;,&quot;M&quot;,&quot;B&quot;]<br>numaralar = [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;]<br>liste =[]</pre><pre>for i in isimler:<br>    for j in numaralar:<br>        kart = j +&quot; of &quot;+ i<br>        liste +=[kart]</pre><pre><strong>#kart karıştırma</strong><br>n = len (liste)<br>for i in range(n):<br>    randsıra = random.randrange (i, n)<br>    temp = liste[randsıra]<br>    liste[randsıra] = liste[i]<br>    liste[i] = temp</pre><pre><strong><em>#karıştırılmış kartları bastırma her bir kişiden sonra boşluklu</em></strong><br>for i in range(<strong>x*3</strong>):<br>    <strong>if (i+1) % 3 ==0:</strong><br>        stdio.writeln(liste[i])<br>        stdio.writeln()<br>    else:<br>        stdio.writeln(liste[i])<br><strong>--------------------------------------------<br><em>x=4 için</em><br>4 of B<br>5 of A<br>3 of Y</strong></pre><pre><strong>2 of Z<br>5 of X<br>4 of M</strong></pre><pre><strong>1 of A<br>2 of T<br>1 of Y</strong></pre><pre><strong>2 of X<br>4 of T<br>1 of X</strong></pre><p>print’le yazımı:</p><pre>import random<br>import sys<br>import stdio</pre><pre>x = int(sys.argv[1])<br>isimler = [&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;,&quot;T&quot;,&quot;A&quot;,&quot;M&quot;,&quot;B&quot;]<br>numaralar = [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;]<br>liste =[]</pre><pre>for i in isimler:<br>    for j in numaralar:<br>        kart = j +&quot; of &quot;+ i<br>        liste +=[kart]</pre><pre><strong>#kart karıştırma</strong><br>n = len (liste)<br>for i in range(n):<br>    randsıra = random.randrange (i, n)<br>    temp = liste[randsıra]<br>    liste[randsıra] = liste[i]<br>    liste[i] = temp</pre><pre><strong><em>#karıştırılmış kartları bastırma her bir kişiden sonra boşluklu</em></strong><br>for i in range<strong>(x*3):</strong><br>    <strong>if (i+1) % 3 == 0:</strong><br>        print<strong>(liste[i],&quot;\n&quot;)      </strong><br>    else:<br>        print(liste[i])<br><strong>--------------------------------------------<br><em>x=4 için</em><br>4 of B<br>5 of A<br>3 of Y</strong></pre><pre><strong>2 of Z<br>5 of X<br>4 of M</strong></pre><pre><strong>1 of A<br>2 of T<br>1 of Y</strong></pre><pre><strong>2 of X<br>4 of T<br>1 of X</strong></pre><p>i+1 yazımı kafa karıştırıcı geliyorsa ilk elemanı 1&#39;den başlatıp range’i değiştirebiliriz. print’le yazımı:</p><pre>import random<br>import sys<br>import stdio</pre><pre>x = int(sys.argv[1])<br>isimler = [&quot;X&quot;,&quot;Y&quot;,&quot;Z&quot;,&quot;T&quot;,&quot;A&quot;,&quot;M&quot;,&quot;B&quot;]<br>numaralar = [&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;]<br>liste =[]</pre><pre>for i in isimler:<br>    for j in numaralar:<br>        kart = j +&quot; of &quot;+ i<br>        liste +=[kart]</pre><pre><strong>#kart karıştırma</strong><br>n = len (liste)<br>for i in range(n):<br>    randsıra = random.randrange (i, n)<br>    temp = liste[randsıra]<br>    liste[randsıra] = liste[i]<br>    liste[i] = temp</pre><pre><strong><em>#karıştırılmış kartları bastırma her bir kişiden sonra boşluklu</em></strong><br>for i in range<strong>(1,(x*3)+1):</strong><br>    if <strong>i % 3</strong> == 0:<br>        print<strong>(liste[i],&quot;\n&quot;)</strong><br>    else:<br>        print(liste[i])</pre><p><strong>Matrix Transposition</strong></p><pre>a =[ [99 , 85, 98] ,<br>     [98 , 57, 78] ,<br>     [92 , 77, 76] ,<br>     [94 , 32, 11] ,<br>     [99 , 34, 22] ,<br>     [90 , 46, 54] ,<br>     [76 , 59, 88] ,<br>     [92 , 66, 89] ,<br>     [97 , 71, 24] ,<br>     [89 , 29, 38] ]</pre><pre>numberofrows = len(a)<br>numberofcolumns = len(a[0])</pre><pre>transposeda = []</pre><pre><strong>for i in range(numberofcolumns</strong>):<br>    newrow = []<br>    <strong>for j in range(numberofrows):</strong><br>        temp= a[j][i]<br>        newrow.append(temp)<br>    transposeda.append(newrow)</pre><pre>print(transposeda)<br><strong>-----------------------------------------------<br>[[99, 98, 92, 94, 99, 90, 76, 92, 97, 89], [85, 57, 77, 32, 34, 46, 59, 66, 71, 29], [98, 78, 76, 11, 22, 54, 88, 89, 24, 38]]</strong></pre><pre><strong><em>#Satır olarak yazdırmak için:</em></strong></pre><pre><strong>for i in range(len(transposeda)):</strong><br>    print(transposeda[i])<br><strong>-----------------------------------------------<br></strong>[99, 98, 92, 94, 99, 90, 76, 92, 97, 89]<br>[85, 57, 77, 32, 34, 46, 59, 66, 71, 29]<br>[98, 78, 76, 11, 22, 54, 88, 89, 24, 38]</pre><p><strong>Matrix Transposition Boşluklu Yazdırma</strong></p><pre>a =[ [99 , 85, 98] ,<br>     [98 , 57, 78] ,<br>     [92 , 77, 76] ,<br>     [94 , 32, 11] ,<br>     [99 , 34, 22] ,<br>     [90 , 46, 54] ,<br>     [76 , 59, 88] ,<br>     [92 , 66, 89] ,<br>     [97 , 71, 24] ,<br>     [89 , 29, 38] ]</pre><pre>numberofrows = len(a)<br>numberofcolumns = len(a[0])</pre><pre>transposeda = []</pre><pre>for i in range(numberofcolumns):<br>    newrow = []<br>    for j in range(numberofrows):<br>        temp = a[j][i]<br>        newrow.append(temp)<br>    transposeda.append(newrow)</pre><pre>for i in range<strong>(len(transposeda))</strong>:<br>    for j in range<strong>(len(transposeda[0]))</strong>:<br>        print(<strong>transposeda[i][j]</strong>, end=&quot; &quot;)<br>    print(&quot;&quot;)<br>--------------------------------------------------<br><strong>99 98 92 94 99 90 76 92 97 89<br>85 57 77 32 34 46 59 66 71 29<br>98 78 76 11 22 54 88 89 24 38</strong></pre><p><strong>Matrix Transposition Boşluklu Yazdırma</strong></p><pre>import random<br>import sys<br>import stdio</pre><pre>a =[ [99 , 85, 98] ,<br>     [98 , 57, 78] ,<br>     [92 , 77, 76] ,<br>     [94 , 32, 11] ,<br>     [99 , 34, 22] ,<br>     [90 , 46, 54] ,<br>     [76 , 59, 88] ,<br>     [92 , 66, 89] ,<br>     [97 , 71, 24] ,<br>     [89 , 29, 38] ]</pre><pre>numberofrows = len(a)<br>numberofcolumns = len(a[0])</pre><pre>transposeda = []</pre><pre>for i in range(numberofcolumns):<br>    newrow = []<br>    for j in range(numberofrows):<br>        temp = a[j][i]<br>        newrow.append(temp)<br>    transposeda.append(newrow)<br>    <br><strong>print(&quot;matrix:&quot;)<br>for i in range(numberofrows):<br>    for j in range(numberofcolumns):<br>        print(a[i][j],end =&quot; &quot;)<br>    print(&quot;&quot;)</strong><br>print(&quot;\n&quot;)</pre><pre>print(&quot;transpose of matrix:&quot;)<strong><br></strong>for i in range<strong>(len(transposeda)):          #ilk loop row<br>    </strong>for j in range<strong>(len(transposeda[0])):  <br>        print(transposeda[i][j], end=&quot; &quot;)<br>    print(&quot;&quot;)<br>--------------------------------------------------<br></strong>matrix:<br>99 85 98<br>98 57 78<br>92 77 76<br>94 32 11<br>99 34 22<br>90 46 54<br>76 59 88<br>92 66 89<br>97 71 24<br>89 29 38</pre><pre>transpose of matrix:<br>99 98 92 94 99 90 76 92 97 89<br>85 57 77 32 34 46 59 66 71 29<br>98 78 76 11 22 54 88 89 24 38</pre><p><strong>Matrix Çarpım</strong></p><pre>import random<br>import sys<br>import stdio<br>import stdarray</pre><pre>a =[ [1 , 2, 3] ,<br>     [1 , 4, 7] ,<br>     [2 , 7, 6] ,<br>     [4 , 3, 1] ]</pre><pre>b =[ [2 , 1, 3, 4] ,<br>     [7 , 5, 1, 2] ,<br>     [2 , 6, 6, 1] ]</pre><pre><strong>newmatrix= stdarray.create2D(len(a),len(b[0]),0)<br>#row&#39;u 1.matrixin row sayısı, col&#39;u 2.nin column sayısına eş liste</strong></pre><pre>if len(a[0]) == len(b):      <strong><em>#1.matrixin column = 2.nin row&#39;u</em></strong><br>    for i in range<strong>(len(a)):</strong>              <strong><em>#1.matrixin row sayısı</em></strong><br>        for j in range<strong>(len(b[0])):</strong>       <strong><em>#2.matrixin col sayısı</em></strong><br>            for t in range<strong>(len(b)):  </strong>    <strong><em>#2.matrixin rowsayısı</em></strong><br>                <strong>newmatrix[i][j] += a[i][t] * b[t][j]</strong><br>else:<br>    print(&quot;şartı sağlamıyor&quot;)</pre><pre>for i in range(len(newmatrix)):<br>    print(newmatrix[i])<br><strong>-------------------------------------------------<br>[22, 29, 23, 11]<br>[44, 63, 49, 19]<br>[65, 73, 49, 28]<br>[31, 25, 21, 23]</strong></pre><p><strong>Matrix Çarpım</strong></p><pre>import random<br>import sys<br>import stdio<br>import stdarray</pre><pre>a =[ [1 , 2, 3] ,<br>     [1 , 4, 7] ,<br>     [2 , 7, 6] ,<br>     [4 , 3, 1] ]</pre><pre>b =[ [2 , 1, 3, 4] ,<br>     [7 , 5, 1, 2] ,<br>     [2 , 6, 6, 1] ]</pre><pre><strong>newmatrix= stdarray.create2D(len(a),len(b[0]),0)<br>#row&#39;u 1.matrixin row sayısı, col&#39;u 2.nin column sayısına eş liste</strong></pre><pre>if len(a[0]) == len(b):      <strong><em>#1.matrixin column = 2.nin row&#39;u</em></strong><br>    for i in range<strong>(len(a)):</strong>              <strong><em>#1.matrixin row sayısı</em></strong><br>        for j in range<strong>(len(b[0])):</strong>       <strong><em>#2.matrixin col sayısı</em></strong><br>            for t in range<strong>(len(b)):  </strong>    <strong><em>#2.matrixin rowsayısı</em></strong><br>                <strong>newmatrix[i][j] += a[i][t] * b[t][j]</strong><br>else:<br>    print(&quot;şartı sağlamıyor&quot;)</pre><pre>for i in range<strong>(len(newmatrix)):</strong><br>    for j in range<strong>(len(newmatrix[0])):</strong><br>       <strong> print(newmatrix[i][j], end= &quot; &quot;)</strong><br>    print()<br><strong>-------------------------------------------------<br>22 29 23 11<br>44 63 49 19<br>65 73 49 28<br>31 25 21 23</strong></pre><p><strong>Pascal Ücgen</strong></p><pre>import sys</pre><pre>n = int(sys.argv[1])<br><strong>a = [[]] * (n+1)</strong>        <strong>#[[], [], [], [], []]</strong></pre><pre>for i in range(n+1):        <strong>#for n=4</strong><br>    a[i] =[1]*(i+1)     <br><strong><em>#[[1], [1, 1], [1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1, 1]]</em></strong></pre><pre>for <strong>i</strong> in <strong>range(n+1):</strong><br>    for <strong>j</strong> in <strong>range(1,i):</strong><br>        <strong>a[i][j] = a[i - 1][j - 1] + a[i - 1][j]</strong><br><strong>#[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]]</strong></pre><pre>for i in <strong>range(n+1):</strong><br>    for j in<strong> range(i+1):</strong><br>        print(<strong>a[i][j]</strong>, end=&quot; &quot;)<br>    print(&quot;&quot;)<br>------------------------------------------------<br><strong>python ass4deneme.py 10<br>1<br>1 1<br>1 2 1<br>1 3 3 1<br>1 4 6 4 1<br>1 5 10 10 5 1<br>1 6 15 20 15 6 1<br>1 7 21 35 35 21 7 1<br>1 8 28 56 70 56 28 8 1<br>1 9 36 84 126 126 84 36 9 1<br>1 10 45 120 210 252 210 120 45 10 1</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=566472358aae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dicts, Sets, Tuple]]></title>
            <link>https://medium.com/@robuno/dicts-sets-tuple-3295fc5c9d2f?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/3295fc5c9d2f</guid>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 20:06:41 GMT</pubDate>
            <atom:updated>2020-04-15T20:06:41.160Z</atom:updated>
            <content:encoded><![CDATA[<p>sozluk[“key”] tek başına value değerini verir. <br>sozluk[“key”] = xyz yeni bir pair tanımlar ve sözlüğün sonuna ekler<br>del sozluk[“key”] pair’i siler.</p><p>sorted(sozluk) listeye çevirir, keyleri alfabetik sıralar.<br>list(sozluk) listeye, tuple(sozluk) tuple’a çevirir.</p><pre>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;falcao&quot;:9,&quot;arda&quot;:66}<br>print(&quot;value of lebron&quot;, sozluk[&quot;lebron&quot;])  <strong>#value of lebron 23</strong></pre><pre><strong>sozluk[&quot;onyekuru&quot;] = 7  </strong><br>print(sozluk)<br><strong>#{&#39;belhanda&#39;: 10, &#39;lebron&#39;: 23, &#39;falcao&#39;: 9, &#39;arda&#39;: 66, &#39;onyekuru&#39;: 7}</strong></pre><pre><strong>del</strong> sozluk[&quot;falcao&quot;]<br>print(sozluk)<br><strong>#{&#39;belhanda&#39;: 10, &#39;lebron&#39;: 23, &#39;arda&#39;: 66, &#39;onyekuru&#39;: 7}</strong></pre><pre>print(<strong>sorted(sozluk)</strong>) <strong>#[&#39;arda&#39;, &#39;belhanda&#39;, &#39;lebron&#39;, &#39;onyekuru&#39;]</strong><br>print(<strong>list(sozluk)</strong>)   <strong>#[&#39;belhanda&#39;, &#39;lebron&#39;, &#39;arda&#39;, &#39;onyekuru&#39;]</strong><br>print(<strong>tuple(sozluk)</strong>)  <strong>#(&#39;belhanda&#39;, &#39;lebron&#39;, &#39;arda&#39;, &#39;onyekuru&#39;)<br></strong>print<strong>(&quot;feguli&quot; in sozluk)            #Boolean: False</strong></pre><p>listenin “[]” içine, tuple ile “(key,value)” yazarak pair tanımlayıp dict() içine alıp sözlüğe çevirebilirsin.</p><pre>x = <strong>dict([</strong>(&#39;belhanda&#39;, 10), (&#39;fegu&#39;, 89), (&#39;cagne&#39;, 91)<strong>])</strong><br>print(x)<br><strong>----------------------------------------</strong><br><strong>{&#39;belhanda&#39;: 10, &#39;fegu&#39;: 89, &#39;cagne&#39;: 91}</strong></pre><p>x’i key alıp “:” ardından işlemlerini de tanımlayabilirsin</p><pre>y= {x: x**3 for x in (2, 4, 6)}<br>print(y)<br><strong>----------------------------------------<br>{2: 8, 4: 64, 6: 216}</strong></pre><p>dict() içinde<strong><em> “key=value, key =value,…”</em></strong> formatıyla da yapabilirsin</p><pre><strong>takim=dict(belhanda=10, lebron=23, lines=14)</strong><br>for <strong>isim,numara</strong> in <strong>takim.items():</strong><br>    print(isim,numara)<br><strong>----------------------------------------<br>belhanda 10<br>lebron 23<br>lines 14</strong></pre><p>list(sozluk) listeye, tuple(sozluk) tuple’a çevirir.</p><pre>sozluk = {&#39;age&#39;: 51, &#39;spouse&#39;: &#39;Edna&#39;,<br>          &#39;children&#39;: [&#39;ali&#39;, &#39;veli&#39;, &#39;Joey&#39;],<br>          &#39;pets&#39;: {&#39;dog&#39;: &#39;it&#39;, &#39;cat&#39;: &#39;tekin&#39;}}</pre><pre>print<strong>(sozluk[&quot;children&quot;][-1])</strong><br>print<strong>(sozluk[&quot;pets&quot;][&quot;cat&quot;])</strong><br><strong>------------------------------------------<br>Joey<br>tekin</strong></pre><p>Dict Metodları</p><pre>ssozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;falcao&quot;:9,&quot;arda&quot;:66}<br><strong>sozluk.clear()</strong><br>print(sozluk)             <strong>#{}          #Sözlüğü temizler</strong></pre><pre><strong>---------------------------------------------------------------</strong></pre><pre>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;falcao&quot;:9,&quot;arda&quot;:66}<br>for no <strong>in sozluk</strong>:<br>    <strong>y = sozluk.get(no)</strong><br>    print(y)</pre><pre><strong>------------------------------------------<br>10<br>23<br>9<br>66<br>-----------------------------------------------------------------</strong></pre><pre>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;arda&quot;:66}<br><strong>y = sozluk.items()<br>listy = list(y)</strong><br>print(y)   <strong>#dict_items([(&#39;belhanda&#39;, 10), (&#39;lebron&#39;, 23), (&#39;arda&#39;, 66)])</strong><br>print(listy)  <strong>#[(&#39;belhanda&#39;, 10), (&#39;lebron&#39;, 23), (&#39;arda&#39;, 66)]</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><pre>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;arda&quot;:66}<br>keyslist = list(sozluk.keys())<br>print(keylist)         <strong>#[&#39;belhanda&#39;, &#39;lebron&#39;, &#39;arda&#39;]</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><pre>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;arda&quot;:66}<br>valueslist = list(sozluk.values())<br>print(valueslist)       <strong>#[10, 23, 66]</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><pre>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;arda&quot;:66}<br>print<strong>(sozluk.pop(&quot;lebron&quot;))</strong>     <strong>#23</strong><br>print<strong>(sozluk)</strong>                   <strong>#{&#39;belhanda&#39;: 10, &#39;arda&#39;: 66}</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><pre><strong>-----------popitem() = random eleman siler ve döndürür----------</strong><br>sozluk = {&quot;belhanda&quot;: 10,&quot;lebron&quot;:23,&quot;arda&quot;:66}<br>print<strong>(sozluk.popitem())</strong>         <strong>#(&#39;arda&#39;, 66)</strong><br>print<strong>(sozluk)</strong>                   <strong>#{&#39;belhanda&#39;: 10, &#39;lebron&#39;: 23}</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><pre>sozluk = {<strong>&quot;sneijder&quot;: 10</strong>,&quot;lebron&quot;:6}<br>sozluk2 = {<strong>&quot;belhanda&quot;: 10</strong>,&quot;onyekuru&quot;:7}<br><strong>sozluk.update(sozluk2)</strong><br>print(sozluk)</pre><pre><strong>#{&#39;sneijder&#39;: 10, &#39;lebron&#39;: 6, &#39;belhanda&#39;: 10, &#39;onyekuru&#39;: 7}</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><pre><strong>sozluk = {&quot;sneijder&quot;: 14,&quot;lebron&quot;:6}<br>sozluk.update([(&quot;sneijder&quot;, 10),(&quot;onyekuru&quot;,7)])</strong><br>print(sozluk)</pre><pre><strong>#{&#39;sneijder&#39;: 10, &#39;lebron&#39;: 6, &#39;onyekuru&#39;: 7}</strong></pre><pre><strong>----------------------------------------------------------------</strong></pre><h3><strong>LİSTELER</strong></h3><p>extend() metodu sona ekler. argument <strong>mutable</strong> olmalıdır.</p><pre>a = [&quot;a&quot;,&quot;b&quot;]<br><strong>a.extend(&quot;2&quot;,&quot;3&quot;)</strong><br>print(a)                      <strong>#ERROR</strong><br>----------------------------------------------------------------<br>a = [&quot;a&quot;,&quot;b&quot;]<br><strong>a.extend([&quot;2&quot;,&quot;3&quot;])</strong><br>print(a)                      <strong>#[&#39;a&#39;, &#39;b&#39;, &#39;2&#39;, &#39;3&#39;]<br>----------------------------------------------------------------<br></strong>a = [&quot;a&quot;,&quot;b&quot;]<br><strong>a.extend(&quot;2&quot;)</strong><br>print(a)                     <strong> #[&#39;a&#39;, &#39;b&#39;, &#39;2&#39;]</strong></pre><p>örnekler</p><pre>a = [&#39;a&#39;, &#39;b&#39;]<br>a += [1, 2, 3]                   <strong> #[&#39;a&#39;, &#39;b&#39;, 1, 2, 3]<br>-----------------------------------------------------------<br></strong>tuple1 = (&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;)<br>(x,y,z,t) = tuple1                <strong>#a</strong><br>print(x)                          <strong>#a b c d<br></strong><strong>-----------------------------------------------------------<br></strong></pre><h4>liste kopyalama</h4><p>listeyi kopyalarken farklı bir id ile kopyalamak için 2 seçenek var<br>1. yeniliste = eskiliste [:]<br>2.döngüyle boş bir listeye eski listenin her elemanını tek tek atmak<br>!!! yenliste = eskiliste yapmak yeni id yaratmaz. yenilisteye yapılan değişikliklerden eskisi de etkilenir.</p><pre>a = [&quot;x&quot;,&quot;y&quot;,&quot;z&quot;]<br>b = a<br>c = a[:]</pre><pre>d = []<br>for i in a:<br>    d.append(i)</pre><pre>print(id(a))       #51804296<br>print(id(b))      <strong> #51804296</strong><br>print(id(c))       <strong>#51804328</strong><br>print(id(d))       <strong>#51804424</strong></pre><p>print(liste.sort()) hiçbir şey yazdırmaz. <br>sorted(liste) asıl listeyi mutate etmez. yeni liste oluşturur onu yazdırır.</p><pre>a = [&quot;x&quot;,&quot;z&quot;,&quot;y&quot;,&quot;a&quot;,&quot;c&quot;,&quot;b&quot;]<br><strong>sıralıa = a.sort()</strong><br>print(a)               #[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;x&#39;, &#39;y&#39;, &#39;z&#39;]<br>print(sıralıa)         #None</pre><pre>aaa = [&quot;x&quot;,&quot;z&quot;,&quot;y&quot;,&quot;a&quot;,&quot;c&quot;,&quot;b&quot;]<br><strong>sıralıaaa = sorted(aaa)</strong><br>print(aaa)            #[&#39;x&#39;, &#39;z&#39;, &#39;y&#39;, &#39;a&#39;, &#39;c&#39;, &#39;b&#39;]<br>print(sıralıaaa)      #[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;x&#39;, &#39;y&#39;, &#39;z&#39;]</pre><p>iki listeden ilk listedeki elemanlardan ikinci listede olmayanları yazdırma</p><pre>L1 = [1,2,3,4]<br>L2 = [1,2,5,6]</pre><pre>newl1= []<br>for i in L1:<br>    if i not in L2:<br>        newl1.append(i)<br>print(newl1)</pre><p>listedeki duplicate elemanları silme</p><pre>L1 = [1,1,2,3,4,2,2,3,4,10]<br>L2 = []<br>for i in L1:<br>    if i not in L2:<br>        L2.append(i)</pre><pre>print(L2)      #[1,2,3,4,10] <br>#istiyorsan en sonda L1= L2 de L1&#39;i L2 yap</pre><p>iki listeyi birleştirmek ve aynı indexe sahip elemanlarını kullanmak için <strong>zip(liste1,liste2)</strong></p><pre><strong>isim = [&#39;belhanda&#39;, &#39;falcao&#39;, &#39;feguli&#39;]<br>numara = [&#39;10&#39;, &#39;9&#39;, &#39;8&#39;]</strong><br>for no, i in <strong>zip(numara, isim)</strong>:<br>    print(<strong>&#39;numara: {0}, isim: {1}.&#39;</strong>.format(no, i))<br><strong>---------------------------------------<br>numara: 10, isim: belhanda.<br>numara: 9, isim: falcao.<br>numara: 8, isim: feguli.</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3295fc5c9d2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Input Output Lists Ornekler]]></title>
            <link>https://medium.com/@robuno/input-output-lists-ornekler-ca5868ba5c9?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca5868ba5c9</guid>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 20:06:32 GMT</pubDate>
            <atom:updated>2020-04-15T20:06:32.631Z</atom:updated>
            <content:encoded><![CDATA[<p>komut satırında art arda verilen inputları almak</p><pre>a = []<br>count= 0<br><strong>while not stdio .isEmpty ():     <em>#isEmpty is boolean function</em></strong><br>    value = stdio <strong>.readFloat()  <em> #ve ctrz yazılana kadar input alır</em></strong><br>    a.append(value)<br>    count +=1</pre><pre>stdio.writeln(a)<br>stdio.writeln(&quot;number of numbers:&quot;+str(count))<br><strong>-----------------------<br>1 1 1 1 1<br>2 2 2 2<br>3 3 3<br>4 4<br>5</strong><br><strong>^Z  #ctrlz ctrld</strong><br>[1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0, 4.0, 5.0]<br>number of numbers:15</pre><p>Bir sayının tam bölenleri-liste versiyon:</p><pre>b= []<br>count2 = 0<br><strong>while not stdio.isEmpty ():</strong><br>   <strong> </strong>value = stdio.<strong>readString()</strong><br>    b.append(value)<br>    count2 +=1<br>stdio.writeln(b)<br>stdio.writeln(&quot;number of str&#39;s:&quot;+str(count2))<br><strong>-----------------------<br>aaa bbb ccc ddd<br>ee ff gg<br>x y<br>z<br>^Z</strong><br>[&#39;aaa&#39;, &#39;bbb&#39;, &#39;ccc&#39;, &#39;ddd&#39;, &#39;ee&#39;, &#39;ff&#39;, &#39;gg&#39;, &#39;x&#39;, &#39;y&#39;, &#39;z&#39;]<br>number of str&#39;s:10<br></pre><p>txt’den input alma</p><pre>import stdio<br>total = 0.0<br>count = 0<br>while not stdio . isEmpty ():<br>    value = stdio . readFloat ()<br>    total += value<br>    count += 1<br>avg = total / count<br>stdio . writeln (&#39;Average is &#39; + str ( avg ))<br><strong>----------------------</strong><br><strong>deneme2.py &lt; data.txt</strong><br>Average is 5.0<br><strong>----------------------<br>data.txt içeriği:<br>3<br>5<br>7</strong></pre><p>output’u txt’e yazdırıp txt’den input alma</p><pre><strong>-------------&gt;average.py</strong><br>import stdio<br>total = 0.0<br>count = 0<br><strong>while not stdio . isEmpty ():</strong><br>    <strong>value = stdio . readFloat ()</strong><br>    total += value<br>    count += 1<br>avg = total / count<br>stdio . writeln (&#39;Average is &#39; + str ( avg ))<br><strong>-------------&gt;sequence.py</strong><br>import sys<br>import stdarray</pre><pre>n = int(sys.argv[1])<br>lo = float(sys.argv[2])<br>hi = float(sys.argv[3])<br>for i in range(n):<br>    x =<strong> stdrandom.uniformFloat(lo,hi)</strong><br>    <strong>stdio.writef</strong>(&quot;%.<strong>2f\n&quot;</strong>, x)<br><strong>---------------------------------------------<br>python sequence.py 10 100 200 | python average.py<br>Average is 152.45999999999998</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca5868ba5c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Read]]></title>
            <link>https://medium.com/@robuno/read-8964c89e85e4?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/8964c89e85e4</guid>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 20:06:20 GMT</pubDate>
            <atom:updated>2020-04-15T20:06:20.767Z</atom:updated>
            <content:encoded><![CDATA[<p>readLine() her satırı 1 eleman alır</p><pre>import stdio<br>a = []<br>count = 0<br><strong>while not stdio.isEmpty ():<br>    value = stdio.readLine ()</strong><br>    a.append(value)<br>    count += 1<br>stdio.writeln(&quot;count:&quot;+str(count))<br>stdio.writeln(a)<br>------------------------<br>python deneme3.py<br><strong>1 2 3 4<br>5 6 7 8<br>9 10 11 12<br>^Z<br>count:3<br>[&#39;1 2 3 4&#39;, &#39;5 6 7 8&#39;, &#39;9 10 11 12&#39;]</strong></pre><p>readAll() tüm komut satırını 1 “<strong><em>str”</em></strong> eleman olarak alır.</p><pre>import stdio<br>a = []<br>count = 0<br><strong>while not stdio.isEmpty ():<br>    value = stdio.readAll ()</strong><br>    a.append(value)<br>    count += 1<br>stdio.writeln(count)<br>stdio.writeln(a)<br>------------------------<br>python deneme3.py<br><strong>1 2 3 4 5<br>6 7 8 9 10<br>^Z<br>^Z<br></strong>count:1<br>[&#39;1 2 3 4 5\n6 7 8 9 10\n&#39;]</pre><p>readAllInts() tüm komut satırındaki “int” elemanları liste içine ayrı elemanlar olarak atar. str varsa kod hata verir. liste içine atıldığına dikkat etmelisin.</p><pre>import stdio<br>a = []<br>count = 0<br>while not stdio.isEmpty ():<br>    value = stdio.readAllInts ()<br>    a.append(value)<br>    count += 1<br>stdio.writeln(&quot;count:&quot;+str(count))<br>stdio.writeln(a)<br>------------------------<br>python deneme3.py<br><strong>1 2 3 4<br>6 7 8 9<br>123 2141 125 12421<br>^Z<br>^Z</strong><br>count:1<br>[<strong>[1, 2, 3, 4, 6, 7, 8, 9, 123, 2141, 125, 12421]</strong>]</pre><p>readAllInts() tüm komut satırındaki “int” elemanları liste içine ayrı elemanlar olarak atar. str varsa kod hata verir. liste içine atıldığına dikkat etmelisin.</p><pre>import stdio<br>a = []<br>count = 0<br>while not stdio.isEmpty ():<br>    value = stdio.readAllLines()<br>    a.append(value)<br>    count += 1<br>stdio.writeln(&quot;count:&quot;+str(count))<br>stdio.writeln(a)<br>------------------------<br>python deneme3.py<br><strong>seri 6 falkao 9<br>lemina 8 feguli 89<br>belhanda 10<br>12381249124<br>^Z<br>^Z</strong><br>count:1<br>[[&#39;seri 6 falkao 9&#39;, &#39;lemina 8 feguli 89&#39;, &#39;belhanda 10&#39;, &#39;12381249124&#39;]]</pre><ol><li>komut satırından eleman sayısını al</li><li>komut satırında alt satırda white space ile ayrılmış sayıları 1. listeye at</li><li>komut satırında alt satırda white space ile ayrılmış listeleri 2. listeye at</li></ol><pre>import stdio<br>import sys</pre><pre>n =int(sys.argv[1])<br>a= []<br>b= []<br>while not stdio.isEmpty ():<br>    if <strong>len(a) &lt; n:</strong><br>        <strong>value = stdio.readFloat()</strong><br>        a.append(value)<br>    if <strong>(len(a) == n) and (len(b) &lt; n):</strong><br>        <strong>value2 = stdio.readFloat()</strong><br>        b.append(value2)</pre><pre>distance = 0<br>for i in range(n):<br>    distance += (a[i] - b[i])**2</pre><pre>distance= distance**(1/2)<br>print(distance)<br>------------------------<br>python deneme3.py<br><strong>-9 1 10 -1 1               #print(a) = [-9.0, 1.0, 10.0, -1.0, 1.0]<br>-5 9 6 7 4                 #print(b) = [-5.0, 9.0, 6.0, 7.0, 4.0]<br>^Z<br>13.0</strong></pre><ol><li>komut satırından eleman sayısını al</li><li>komut satırında alt satırda white space ile ayrılmış sayıları 1. listeye at. split() kullanarak her boşluk gördüğünde elemana çevirmesini sağla.</li><li>komut satırında alt satırda white space ile ayrılmış listeleri 2. listeye at. split() kullanarak her boşluk gördüğünde elemana çevirmesini sağla.</li></ol><p>readline() tek başına “<strong>-9 1 10 -1 1”</strong> olarak yani str alır. Split’le bölüp listeye at.</p><pre>n =int(sys.argv[1])<br>a= []<br>b= []<br><strong>while not stdio.isEmpty ():</strong><br>    <strong>values1 = stdio.readLine().split()</strong><br>    for i in values1:<br>        a.append(i)<br>    <strong>values2 = stdio.readLine().split()</strong><br>    for i in values2:<br>        b.append(i)<br>print(a)<br>print(b)</pre><pre>distance = 0<br>for i in range(n):<br>    distance += (<strong>int(</strong>a[i]<strong>)</strong> - <strong>int(</strong>b[i]<strong>)</strong>)**2</pre><pre>distance= distance**(1/2)<br>print(distance)<br>------------------------<br>python deneme3.py<br><strong>-9 1 10 -1 1               #print(a) = [-9.0, 1.0, 10.0, -1.0, 1.0]<br>-5 9 6 7 4                 #print(b) = [-5.0, 9.0, 6.0, 7.0, 4.0]<br>^Z<br>13.0</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8964c89e85e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ornekler]]></title>
            <link>https://medium.com/@robuno/ornekler-d7171dd84ade?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7171dd84ade</guid>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Tue, 14 Apr 2020 17:29:28 GMT</pubDate>
            <atom:updated>2020-04-14T17:29:28.836Z</atom:updated>
            <content:encoded><![CDATA[<p>Bir sayının tam bölenleri-liste versiyon:</p><pre>import sysn <strong>= </strong>int(sys.argv[1])<br>listem <strong>= </strong>[]<br>factor <strong>= </strong>2<br><strong>while </strong>n <strong>!= </strong>1<strong>:<br>    while </strong>n <strong>% </strong>factor <strong>== </strong>0<strong>:<br>        </strong>listem.append(factor)<br>        n <strong>= </strong>n <strong>/ </strong>factor<br>    factor <strong>+=</strong>1Output:<br>python program.py 3757208<br>[2, 2, 2, 7, 13, 13, 397]</pre><p>Bir sayının tam bölenleri-write:</p><pre>import stdio<br>import sysn = int(sys.argv[1])<br>listem = []<br>factor = 2<br><strong>while</strong> n <strong>!=</strong> 1:<br>   <strong> while</strong> n % factor<strong> ==</strong> 0:<br>        n = n / factor<br>        stdio.write(str(factor)+ &quot; &quot;)<br>    factor +=1<br>Output:<br>python program.py 3757208<br>2 2 2 7 13 13 397</pre><p>Asal sayı testi</p><pre>import stdio<br>import sys<strong>n = int(sys.argv[1])</strong><br><strong>i = 2</strong><br><strong>primecheck = 1while</strong> i &lt;= <strong><em>(n/i)</em></strong>:<br>   <strong> if</strong> n % i == 0:<br>        primecheck = 0<br>        break<br>    i +=1<strong>if </strong>n&gt;=2 and primecheck == 1:<br>    stdio.writeln(True)<br><strong>else:</strong><br>    stdio.writeln(False)Output:<br>python program.py 13<br>True</pre><p>Alt satıra geçme ve aynı satırdan devam etme</p><pre>import stdioi = 100while i != 200:<br>    i+=1<br>    if i % 5 == 0:<br>        stdio.writeln(str(i)+&quot; &quot;)<br>    else:<br>        stdio.write(str(i)+&quot; &quot;)---------------------------------------------------<br>while i != 200:<br>    i+=1<br>    if i % 5 == 0:<br>        print(str(i))<br>    else:<br>        print(str(i), end = &quot; &quot;)          <strong>#Aynı satıra yazar</strong><br>-------------------------<br>101 102 103 104 105<br>106 107 108 109 110<br>111 112 113 114 115<br>116 117 118 119 120<br>121 122 123 124 125<br>126 127 128 129 130<br>131 132 133 134 135<br>136 137 138 139 140<br>141 142 143 144 145<br>146 147 148 149 150<br>151 152 153 154 155<br>156 157 158 159 160<br>161 162 163 164 165<br>166 167 168 169 170<br>171 172 173 174 175<br>176 177 178 179 180<br>181 182 183 184 185<br>186 187 188 189 190<br>191 192 193 194 195<br>196 197 198 199 200</pre><p>Asal sayı sayma</p><pre>import stdio<br>import sys</pre><pre>n = int(sys.argv[1])<br>count = 0<br>primenumbers = []<br><strong>for i in range(2,n+1):</strong><br>    j = 2<br>    flag = 0<br>    <strong>while j &lt;= i-1 :</strong><br>        <strong>if i % j == 0:</strong><br>            flag = 1<br>            break<br>        j +=1<br>    <strong>if flag == 0:</strong><br>        count +=1<br>        primenumbers.append(j)<br>print(&quot;count:&quot;,count,&quot;-&gt;&quot;, end = &quot; &quot;)<br>print(&quot;list:&quot;,primenumbers)<br>-------------------------<br><em>Output:</em><br><strong>count: 25 -&gt; list: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97</strong>]</pre><p>Asal sayı sayma</p><pre>import stdio<br>import sys</pre><pre>n = int(sys.argv[1])<br>count = 0</pre><pre><strong>for i in range(2,n+1):</strong><br>    j = 2<br>    primecheck= 1<br>    <strong>while j &lt;= (i/j):</strong><br>        <strong>if i % j == 0:</strong><br>            primecheck = 0<br>            break<br>        j +=1<br>    <strong>if primecheck ==1:</strong><br>        count += 1<br>        <br>stdio.writeln(count)<br>-------------------------<br><em>Output:</em><br><strong>python asal.py 100<br>25</strong></pre><p>Asal sayı sayma</p><pre>import stdarray<br>import stdio<br>import sys</pre><pre><strong>n = int(sys.argv[1])</strong><br><strong>isPrime = stdarray.create1D(n + 1,True)</strong></pre><pre><strong>for i in range (2, n):<br>    if (isPrime[i]):</strong><br>    <em># assign False to all elements<br>    # whose indices are multiples of i</em><br>         <strong> for j in range (2, n // i + 1):<br>                isPrime [i * j] = False</strong><br>count = 0<br><strong>for i in range (2, n + 1):</strong><br><strong>    if isPrime[i]:<br>        count += 1</strong><br><strong>stdio.writeln(count)</strong><br>-------------------------<br><em>Output:</em><br><strong>python asal.py 100<br>25</strong></pre><p>Üçgen Desen Yazdırma</p><pre><strong>&quot;&quot;&quot;<br>1 <br>1 1 <br>1 1 1 <br>1 1 1 1 <br>1 1 1 1 1<br>&quot;&quot;</strong>&quot;<strong>---------------------------------------------</strong><br>n = int(sys.argv[1])<br>for i in <strong>range( n ):</strong><br>    for j in <strong>range( i+1 ):</strong><br>        stdio.write(str(1)+&quot; &quot;)<br>    stdio.writeln()<br>stdio.writeln()<br><strong><em>-------------------------------------------------</em></strong><br>for i in <strong>range(1,n+1)</strong>:<br>    for j in <strong>range(i)</strong>:  <br>        stdio.write( &quot;1&quot; +  &quot; &quot;)<br>    stdio.writeln(&quot;&quot;)<br>stdio.writeln()<br><strong>-------------------------------------------------</strong><br>for i in <strong>range(n):</strong><br>    for j in <strong>range(n):</strong><br>        if<strong> i&gt;= j:</strong><br>            stdio.write(&quot;1 &quot;)<br>    stdio.writeln()</pre><p>Üçgen Desen Yazdırma2</p><pre><strong>&quot;&quot;&quot;<br>1 1 1 1 1<br>1 1 1 1 <br>1 1 1 <br>1 1 <br>1 <br>&quot;&quot;&quot;-------------------------------------------------</strong><br>for i in<strong> range(n,0,-1):</strong><br>    for j in <strong>range(i)</strong>:  <br>        stdio.write( &quot;1&quot; +  &quot; &quot;)<br>    stdio.writeln(&quot;&quot;)<br>stdio.writeln()<br><strong>-------------------------------------------------</strong></pre><pre>n = int(sys.argv[1])<br>for i in <strong>range(n):</strong><br>    for j in <strong>range(n-i):</strong><br>        stdio.write(str(1)+&quot; &quot;)<br>    stdio.writeln()<br>stdio.writeln()<br><strong>-------------------------------------------------</strong><br>for i in <strong>range(n):</strong><br>    for j in <strong>range(n):</strong><br>        if<strong> i&lt;= j:</strong><br>            stdio.write(&quot;1 &quot;)<br>    stdio.writeln()</pre><p>Nested loops-lists-Break Örneği</p><pre>A =[[1,2,3],[4,5,6],[7,8,9]]<br>f= 1<br><strong>for i in range(0,3):</strong><br>    f *=10<br>    <strong>for j in range(0,3):</strong><br>        A[i][j] *= f<br>       <strong> if A[i][j] &gt;= 400</strong>:<br>            break<br>        A[i][j] += 1<br>print(A)<br><strong>----------------------------<br>[[11, 21, 31], [400, 5, 6], [7000, 8, 9]]  #7000&#39;e dikkat!</strong></pre><p>loop</p><pre>n= int(sys.argv[1])<br>for i in range(n):<br>    for j in range(i):<br>        <strong>stdio.write(i)</strong><br>    stdio.writeln()<br>stdio.writeln()<br><strong>--------------------------<br>1<br>22<br>333<br>4444<br>55555</strong></pre><p>loop</p><pre>n= int(sys.argv[1])<br>count= 1<br>for i in range(n):<br>    for j in range(i):<br>        stdio.write(count)<br>        count +=1<br>    stdio.writeln()<br>stdio.writeln()<br><strong>--------------------------<br>1<br>23<br>456<br>78910<br>1112131415</strong></pre><p>loop</p><pre>n= int(sys.argv[1])<br>count= 1<br>for i in range(n):<br>    for j in range(i):<br>        stdio.write(count)<br>        count +=1<br>    stdio.writeln()<br>stdio.writeln()<br><strong>--------------------------<br>1<br>23<br>456<br>78910<br>1112131415</strong></pre><p>reverse list</p><pre>a=[1,2,3,4,5]<br>n = len (a)<br>for i in range <strong>(n // 2):</strong><br>   <strong> temp = a[i]<br>    a[i] = a[n - 1 - i]<br>    a[n - 1 - i] = temp</strong><br>print(a)<br><strong>--------------------------<br>[5, 4, 3, 2, 1]</strong></pre><p>reverse list</p><pre>a=[1,2,3,4,5]<br>n = len (a)<br>for i in range <strong>(n // 2):</strong><br>   <strong> temp = a[i]<br>    a[i] = a[n - 1 - i]<br>    a[n - 1 - i] = temp</strong><br>print(a)<br><strong>--------------------------<br>[5, 4, 3, 2, 1]</strong></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7171dd84ade" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python split() Metodu]]></title>
            <link>https://medium.com/@robuno/python-split-metodu-6066ef795d0d?source=rss-e085a0d35848------2</link>
            <guid isPermaLink="false">https://medium.com/p/6066ef795d0d</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[methods]]></category>
            <dc:creator><![CDATA[Unat]]></dc:creator>
            <pubDate>Sun, 12 May 2019 22:50:35 GMT</pubDate>
            <atom:updated>2019-05-12T22:50:35.375Z</atom:updated>
            <content:encoded><![CDATA[<p>split() metodu listeyi belirtilen ayıracı kullanarak yeniden döndürür. yani split() karakter dizilerini istenen şekilde böler.</p><p><strong>bu metot 2 parametre alır: str.split(<em>ayırıcı</em>,<em>ayırma sayısı</em>)</strong><br>-ayırıcı diye tanımladığımız <strong><em>ilk parametre,</em></strong> karakter dizisinin nereden bölüneceğini seçer. eğer ayırıcı tanımlanmazsa karakter dizisi her boşluk gördüğünde ayırır.</p><p>örneğin karakter diziniz virgüllerle ayrılmış ve siz her elemanı ayrı şekilde yazdırmak istiyorsanız. <strong>str.split(“,”) </strong>metodunu<strong> </strong>kullanmalısınız.</p><pre>liste<strong>= &quot;python, c, java&quot;<br></strong>print(liste.split(<strong>&quot;,&quot;</strong>))</pre><pre>[&#39;python&#39;, &#39;c&#39;, &#39;java&#39;]</pre><p>not: eğer girdiğimiz parametre değeri, karakter dizisi içinde yer almıyorsa dizi değiştirilmeden bastırılır. <em>liste</em><strong><em>= “python, c, java”</em></strong><em> </em>içerisinde “e” harfi yok. eğer biz “e” harfinden ayırmak isteseydik liste aynen yazdırılacaktı.</p><pre>dizi <strong>=</strong> &#39;python java c&#39;<br><strong>print</strong>(dizi.split())</pre><pre>[&#39;python&#39;, &#39;java&#39;, &#39;c&#39;]</pre><p>-<strong><em>ikinci parametre </em></strong>ise dizinin kaç kez bölüneceği ile ilgilidir.</p><pre>N<strong>= &quot;python c java&quot;<br></strong>print(N.split(<strong>&quot; &quot;</strong>,1))</pre><p>aynı şekilde ayırma sayısı girilmezse metot karakter dizisinin tamamına uygulanır.</p><pre>dizi <strong>=</strong> &#39;python java c&#39;<br><strong>print</strong>(dizi.split())</pre><pre>[&#39;python&#39;, &#39;java&#39;, &#39;c&#39;]</pre><p>kullanıcının girdiği karakter dizisindeki kelimelerin ilk harflerini almayı sağlayan kod dizisi yazmak gerekirse:</p><pre>giris = input(&quot;Baş harflerini almak istediğiniz kelimeler:&quot;)</pre><pre>for i in <strong><em>giris.split()</em></strong>:<br>    print(i[0])</pre><pre>#çıktıyı tek satırda yazmak için<strong> <em>print(i[0],end= &quot;&quot;)</em></strong> şeklinde kullanabiliriz.</pre><pre>giris = input(&quot;Baş harflerini almak istediğiniz kelimeler:&quot;)</pre><pre>for i in <strong><em>giris.split()</em></strong>:<br>    print(i[0],end= &quot;&quot;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6066ef795d0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>