Page 230 - Bilgisayar Bilimi | Kur 1
P. 230

•   List: liste değişkeni
                 •   begin: listenin başlangıç indeksi

                 •   end: listenin son elemanının indeksi
                 •   Step: verilen aralıktaki eleman sayısını belirtir.

               1st= [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
               print(1st)            #  [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]

               print(1st[0:3])       #  [10, 20, 30]
               print(1st[4:8])       #  [50, 60, 70, 80]
               print(1st[2:5])       #  [30, 40, 50]
               print(1st[-5:-3])  # [80, 90]

               print(1st[:3])        #  [10, 20, 30]
               print(1st[4:])        #  [50, 60, 70, 80, 90, 100, 110, 120]

               print(1st[:])         #  [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]
               print(1st[-100:3]) # [10, 20, 30]
               print(1st[4:100])  # [50, 60, 70, 80, 90, 100, 110, 120]
               print(1st[2:-2:2]) # [30, 50, 70, 90]

               print(1st[::])        #  [10, 30, 50, 70, 90, 110]
               print(1st[::-1])      #  [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]

            10.14. Dilimleme İçin Farklı Kullanımlar

                  >>>a=[34,-19,20,8,12]

                  >>>print(a)
                  [34,-19,20,8,12]
                  >>>print(a[0:1])
                  [34]

                  >>>print(a[0])
                  34

                  >>>b=[[2,5],7,[11,4]]
                  >>>print(b)
                  [[2,5],7,[11,4]]
                  >>>print(b[0:1])

                  [[2,5]]
                  >>>print(b[0])

                  [2,5]



                                                                                                     229
   225   226   227   228   229   230   231   232   233   234   235