├── README.md ├── VeriYapilari_Ders4.ipynb ├── VeriYapilari_Ders7.ipynb └── VeriYapilari_Ders6.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # VeriYapilari 2 | 3 | 2020-2021 Veri Yapıları Dersi Ders Örneklerini içerir.. 4 | -------------------------------------------------------------------------------- /VeriYapilari_Ders4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "VeriYapilari_Ders4.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyMUX1/6vdXg994a4cTG2amF" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "code", 21 | "metadata": { 22 | "id": "WhUBSvP_aqS6" 23 | }, 24 | "source": [ 25 | "class personel:\n", 26 | " tipi=\"insan\"\n", 27 | " def __init__(self,ad,no):\n", 28 | " self.ad=ad\n", 29 | " self.no=no\n", 30 | " print('Personel Eklendi...')\n", 31 | " def adinNe(self):\n", 32 | " return(\"ad: \"+self.ad)\n", 33 | " def numaraNe(self):\n", 34 | " return(\"no: \"+str(self.no))" 35 | ], 36 | "execution_count": 1, 37 | "outputs": [] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "metadata": { 42 | "colab": { 43 | "base_uri": "https://localhost:8080/" 44 | }, 45 | "id": "Z0wh0dOibpmC", 46 | "outputId": "963c4db0-335d-42ae-ad55-cab55179f9c5" 47 | }, 48 | "source": [ 49 | "kisi1=personel(\"ali\",101)\n", 50 | "kisi2=personel(\"veli\",102)\n", 51 | "kisi3=personel(\"zeki\",103)" 52 | ], 53 | "execution_count": 3, 54 | "outputs": [ 55 | { 56 | "output_type": "stream", 57 | "text": [ 58 | "Personel Eklendi...\n", 59 | "Personel Eklendi...\n", 60 | "Personel Eklendi...\n" 61 | ], 62 | "name": "stdout" 63 | } 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "metadata": { 69 | "colab": { 70 | "base_uri": "https://localhost:8080/" 71 | }, 72 | "id": "a26w8utCb1W8", 73 | "outputId": "b38d72fa-f99e-4582-ba45-447661e2aee3" 74 | }, 75 | "source": [ 76 | "print(kisi3.adinNe())\n", 77 | "print(kisi3.numaraNe())" 78 | ], 79 | "execution_count": 5, 80 | "outputs": [ 81 | { 82 | "output_type": "stream", 83 | "text": [ 84 | "ad: zeki\n", 85 | "no: 103\n" 86 | ], 87 | "name": "stdout" 88 | } 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "metadata": { 94 | "id": "o3lCsntMcTIU" 95 | }, 96 | "source": [ 97 | "class Ogrenci:\n", 98 | " 'Tüm öğrenciler için temel sınıf'\n", 99 | " Ogrenci_sayisi = 0\n", 100 | " \n", 101 | " def __init__(self, adi, numarasi):\n", 102 | " self.adi = adi\n", 103 | " self.numarasi = numarasi\n", 104 | " Ogrenci.Ogrenci_sayisi += 1\n", 105 | " \n", 106 | " def OgrenciSayisiGoster(self):\n", 107 | " print(\"Toplam öğrenci: %d\" % Ogrenci.Ogrenci_sayisi)\n", 108 | " \n", 109 | " def OgrenciGoster(self):\n", 110 | " print(\"Adi : \", self.adi, \", Numarası: \", self.numarasi)" 111 | ], 112 | "execution_count": 10, 113 | "outputs": [] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "metadata": { 118 | "id": "flZ4vXpXcW-L" 119 | }, 120 | "source": [ 121 | "ogr1 = Ogrenci(\"Öğrenci1\", 1000)\n", 122 | "ogr2 = Ogrenci(\"Öğrenci2\", 2000)\n", 123 | "ogr3 = Ogrenci(\"Öğrenci3\", 3000)" 124 | ], 125 | "execution_count": 11, 126 | "outputs": [] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "metadata": { 131 | "colab": { 132 | "base_uri": "https://localhost:8080/" 133 | }, 134 | "id": "xBG1f6efcbPp", 135 | "outputId": "65e55f41-35a5-421e-dcc6-3d763807f5e8" 136 | }, 137 | "source": [ 138 | "ogr1.OgrenciGoster()\n", 139 | "ogr2.OgrenciGoster()\n", 140 | "ogr3.OgrenciGoster()\n", 141 | "print(\"Toplam öğrenci %d\" % Ogrenci.Ogrenci_sayisi)" 142 | ], 143 | "execution_count": 12, 144 | "outputs": [ 145 | { 146 | "output_type": "stream", 147 | "text": [ 148 | "Adi : Öğrenci1 , Numarası: 1000\n", 149 | "Adi : Öğrenci2 , Numarası: 2000\n", 150 | "Adi : Öğrenci3 , Numarası: 3000\n", 151 | "Toplam öğrenci 3\n" 152 | ], 153 | "name": "stdout" 154 | } 155 | ] 156 | }, 157 | { 158 | "cell_type": "markdown", 159 | "metadata": { 160 | "id": "35iroBRlhK_S" 161 | }, 162 | "source": [ 163 | "__dict__ : Sınıfın ad alanını içeren sözlük.\n", 164 | "\n", 165 | "__doc__ : Tanımlanmamışsa, sınıf belgelendirme metni içerir.\n", 166 | "\n", 167 | "__name__ : Sınıf adı.\n", 168 | "\n", 169 | "__module__ : Sınıfın tanımlandığı modül adı. Bu özellik, etkileşimli modda “__main__” şeklindedir.\n", 170 | "\n", 171 | "__bases__ : Temel sınıf listesindeki oluşum sırasına göre, temel sınıflarda muhtemelen boş bir tüpledir." 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "metadata": { 177 | "colab": { 178 | "base_uri": "https://localhost:8080/" 179 | }, 180 | "id": "CAWrsQa_hKlJ", 181 | "outputId": "8f5d07de-51ba-4cbb-d46b-aabf54997341" 182 | }, 183 | "source": [ 184 | "print(\"Ogrenci.__doc__:\", Ogrenci.__doc__)\n", 185 | "print(\"Ogrenci.__name__:\", Ogrenci.__name__)\n", 186 | "print(\"Ogrenci.__module__:\", Ogrenci.__module__)\n", 187 | "print(\"Ogrenci.__bases__:\", Ogrenci.__bases__)\n", 188 | "print(\"Ogrenci.__dict__:\", Ogrenci.__dict__)" 189 | ], 190 | "execution_count": 13, 191 | "outputs": [ 192 | { 193 | "output_type": "stream", 194 | "text": [ 195 | "Ogrenci.__doc__: Tüm öğrenciler için temel sınıf\n", 196 | "Ogrenci.__name__: Ogrenci\n", 197 | "Ogrenci.__module__: __main__\n", 198 | "Ogrenci.__bases__: (,)\n", 199 | "Ogrenci.__dict__: {'__module__': '__main__', '__doc__': 'Tüm öğrenciler için temel sınıf', 'Ogrenci_sayisi': 3, '__init__': , 'OgrenciSayisiGoster': , 'OgrenciGoster': , '__dict__': , '__weakref__': }\n" 200 | ], 201 | "name": "stdout" 202 | } 203 | ] 204 | }, 205 | { 206 | "cell_type": "markdown", 207 | "metadata": { 208 | "id": "9Za6HZuOh6DH" 209 | }, 210 | "source": [ 211 | "Özelliklere erişmek için normal ifadeleri kullanmak yerine, aşağıdaki fonksiyonları kullanabilirsiniz:\n", 212 | "\n", 213 | "getattr (obj, name [, default]): nesnenin özelliğine erişmek için kullanılır.\n", 214 | "\n", 215 | "hasattr (obj, name): bir özellik var olup olmadığını kontrol etmek için kullanılır. (True / False)\n", 216 | "setattr (obj, name, value) – bir özellik belirlemek için kullanılır. Özellik yoksa, o zaman yaratılır.\n", 217 | "\n", 218 | "delattr (obj, name) – bir özelliği silmek için kullanılır." 219 | ] 220 | }, 221 | { 222 | "cell_type": "code", 223 | "metadata": { 224 | "colab": { 225 | "base_uri": "https://localhost:8080/" 226 | }, 227 | "id": "Kcs6bcLJh-Vk", 228 | "outputId": "cdd0a563-3c9d-4e61-cbf6-f17359ea71b9" 229 | }, 230 | "source": [ 231 | "class Ana: # ana sinif\n", 232 | " AnaAttr = 100\n", 233 | " def __init__(self):\n", 234 | " print(\"Ana constructor'ı çağırma\")\n", 235 | " \n", 236 | " def AnaMethod(self):\n", 237 | " print('Ana metotu çağırma')\n", 238 | " \n", 239 | " def setAttr(self, attr):\n", 240 | " Ana.AnaAttr = attr\n", 241 | " \n", 242 | " def getAttr(self):\n", 243 | " print('Ana attribute :', Ana.AnaAttr)\n", 244 | " \n", 245 | "class Cocuk(Ana): # cocuk sinif\n", 246 | " def __init__(self):\n", 247 | " print(\"Cocuk constructor'ı çağırma\")\n", 248 | " def CocukMethod(self):\n", 249 | " print('Cocuk methotu çağırma')\n", 250 | " \n", 251 | "c = Cocuk() # Cocuk ornegi\n", 252 | "c.CocukMethod() # Cocuk metodu cagirma\n", 253 | "c.AnaMethod() # Ana'nin metodunu cagirma\n", 254 | "c.setAttr(200) # Ana'nin metodunu set icin cagirma\n", 255 | "c.getAttr() # Ana'nin metodunu get icin cagirma" 256 | ], 257 | "execution_count": 16, 258 | "outputs": [ 259 | { 260 | "output_type": "stream", 261 | "text": [ 262 | "Cocuk constructor'ı çağırma\n", 263 | "Cocuk methotu çağırma\n", 264 | "Ana metotu çağırma\n", 265 | "Ana attribute : 200\n" 266 | ], 267 | "name": "stdout" 268 | } 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "metadata": { 274 | "colab": { 275 | "base_uri": "https://localhost:8080/" 276 | }, 277 | "id": "FQgnf0_ZilZt", 278 | "outputId": "67ee62e8-b047-409e-e145-c181f2e5aec1" 279 | }, 280 | "source": [ 281 | "class Sayac:\n", 282 | " __priSayac = 0 #lokal __ den dolayı \n", 283 | " priSayac=0 #global\n", 284 | " \n", 285 | " def say(self):\n", 286 | " self.__priSayac += 1\n", 287 | " self.priSayac+=2\n", 288 | " print(self.__priSayac)\n", 289 | " \n", 290 | "syc = Sayac()\n", 291 | "syc.say()\n", 292 | "syc.say()\n", 293 | "print(syc.priSayac)" 294 | ], 295 | "execution_count": 19, 296 | "outputs": [ 297 | { 298 | "output_type": "stream", 299 | "text": [ 300 | "1\n", 301 | "2\n", 302 | "4\n" 303 | ], 304 | "name": "stdout" 305 | } 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "metadata": { 311 | "colab": { 312 | "base_uri": "https://localhost:8080/" 313 | }, 314 | "id": "YK0PTDKr_VKS", 315 | "outputId": "d7c89a86-a81e-452d-ea98-9d1875f21004" 316 | }, 317 | "source": [ 318 | "class Person:\n", 319 | " def __init__(self, name, age):\n", 320 | " self.name = name\n", 321 | " self.age = age\n", 322 | " \n", 323 | " def myfunc(self):\n", 324 | " print(\"Merhaba. Benim adım \" + self.name)\n", 325 | " print(\"Yaşım : \"+ str(self.age))\n", 326 | " \n", 327 | "p1 = Person(\"Ali\", 36)\n", 328 | "print(p1.age)\n", 329 | "\n", 330 | "del p1.age\n", 331 | " \n", 332 | "#print(p1.age) 'Person' object has no attribute 'age' hatası alırız." 333 | ], 334 | "execution_count": 25, 335 | "outputs": [ 336 | { 337 | "output_type": "stream", 338 | "text": [ 339 | "36\n" 340 | ], 341 | "name": "stdout" 342 | } 343 | ] 344 | }, 345 | { 346 | "cell_type": "markdown", 347 | "metadata": { 348 | "id": "wctdy2K5bqEB" 349 | }, 350 | "source": [ 351 | "KAYNAKÇA\n", 352 | "\n", 353 | "1-https://dev.to/aciklab/python-da-sinif-kavrami-27je\n", 354 | "\n", 355 | "2-https://erdincuzun.com/python/12-nesne-yonelimli-programlama-python/\n", 356 | "\n", 357 | "3-https://www.algoritmaornekleri.com/python/python-siniflar-objeler/" 358 | ] 359 | } 360 | ] 361 | } -------------------------------------------------------------------------------- /VeriYapilari_Ders7.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "VeriYapilari_Ders7.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyMS7YKFpTxCCpzj92vzT81O" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "code", 21 | "metadata": { 22 | "colab": { 23 | "base_uri": "https://localhost:8080/" 24 | }, 25 | "id": "NydjIjxgYWre", 26 | "outputId": "4f9350a2-5508-4881-d41a-30312bcd8124" 27 | }, 28 | "source": [ 29 | "while True: #while i<5:\n", 30 | " x = input(\"Bir sayı girin: \") #x= str türünde \n", 31 | " if not x:\n", 32 | " break\n", 33 | " try:\n", 34 | " y = float(x)\n", 35 | " except ValueError:\n", 36 | " print(\"Geçersiz sayı\")\n", 37 | " continue\n", 38 | " print(y**2)\n", 39 | "\n", 40 | "k=input(\"Mesajınızı giriniz..\")\n", 41 | "print(k)" 42 | ], 43 | "execution_count": 2, 44 | "outputs": [ 45 | { 46 | "output_type": "stream", 47 | "text": [ 48 | "Bir sayı girin: 5\n", 49 | "25.0\n", 50 | "Bir sayı girin: akhisar\n", 51 | "Geçersiz sayı\n", 52 | "Bir sayı girin: \n", 53 | "Mesajınızı giriniz..Merhaba\n", 54 | "Merhaba\n" 55 | ], 56 | "name": "stdout" 57 | } 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "metadata": { 63 | "colab": { 64 | "base_uri": "https://localhost:8080/", 65 | "height": 813 66 | }, 67 | "id": "Vch1SrJTX0AJ", 68 | "outputId": "41d50249-dfa6-448c-e656-a416e02603bb" 69 | }, 70 | "source": [ 71 | "def switch(deger):\n", 72 | " case={}\n", 73 | " while True:\n", 74 | " try:\n", 75 | " case = {\n", 76 | " \n", 77 | " 0:'Case 0\\'ın değeri', #Birinci seçenek\n", 78 | " 1:'Case 1\\'ın değeri', #İkinci seçenek\n", 79 | " 2: 'Case 2\\'ın değeri',#Üçüncü seçenek\n", 80 | " 3: 'Case 3\\'ın değeri',#Dördüncü seçenek\n", 81 | " 4: 'Case 4\\'ın değeri', #Beşinci seçenek\n", 82 | " 'default':'yanlış bir değer girdiniz' # diğer dillerde olduğu gibi default case değerini oluşturma\n", 83 | " }\n", 84 | " print(case[deger]) # parametreden gelen değeri basıyoruz\n", 85 | " break #programın döngüden çıkmasını sağlıyoruz\n", 86 | " except KeyError:\n", 87 | " print(case['default']) #hatalı giriş olduğu anda default değeri basıyoruz .\n", 88 | " break #programın döngüden çıkmasını sağlıyoruz\n", 89 | " except ValueError:\n", 90 | " print(\"Girdiğiniz değer bir tam sayı değil\")\n", 91 | " break\n", 92 | "def main():\n", 93 | " \n", 94 | " while True:\n", 95 | " try:\n", 96 | " deger = int(input(\"Lütfen bir tam sayı girin ... : \"))\n", 97 | " switch(deger)\n", 98 | " except ValueError:\n", 99 | " print(\"Girdiğiniz değer bir tam sayı değil\")\n", 100 | " continue\n", 101 | "main()" 102 | ], 103 | "execution_count": 3, 104 | "outputs": [ 105 | { 106 | "output_type": "stream", 107 | "text": [ 108 | "Lütfen bir tam sayı girin ... : 5\n", 109 | "yanlış bir değer girdiniz\n", 110 | "Lütfen bir tam sayı girin ... : 2\n", 111 | "Case 2'ın değeri\n", 112 | "Lütfen bir tam sayı girin ... : manisa\n", 113 | "Girdiğiniz değer bir tam sayı değil\n", 114 | "Lütfen bir tam sayı girin ... : 3.2\n", 115 | "Girdiğiniz değer bir tam sayı değil\n", 116 | "Lütfen bir tam sayı girin ... : \n", 117 | "Girdiğiniz değer bir tam sayı değil\n", 118 | "Lütfen bir tam sayı girin ... : akhisar\n", 119 | "Girdiğiniz değer bir tam sayı değil\n", 120 | "Lütfen bir tam sayı girin ... : xyz45\n", 121 | "Girdiğiniz değer bir tam sayı değil\n", 122 | "Lütfen bir tam sayı girin ... : 56\n", 123 | "yanlış bir değer girdiniz\n" 124 | ], 125 | "name": "stdout" 126 | }, 127 | { 128 | "output_type": "error", 129 | "ename": "KeyboardInterrupt", 130 | "evalue": "ignored", 131 | "traceback": [ 132 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 133 | "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", 134 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 728\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 729\u001b[0;31m \u001b[0mident\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreply\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msession\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstdin_socket\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 730\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 135 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/jupyter_client/session.py\u001b[0m in \u001b[0;36mrecv\u001b[0;34m(self, socket, mode, content, copy)\u001b[0m\n\u001b[1;32m 802\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 803\u001b[0;31m \u001b[0mmsg_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msocket\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv_multipart\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 804\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mzmq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mZMQError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 136 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/zmq/sugar/socket.py\u001b[0m in \u001b[0;36mrecv_multipart\u001b[0;34m(self, flags, copy, track)\u001b[0m\n\u001b[1;32m 582\u001b[0m \"\"\"\n\u001b[0;32m--> 583\u001b[0;31m \u001b[0mparts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrecv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mflags\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcopy\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtrack\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtrack\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 584\u001b[0m \u001b[0;31m# have first part already, only loop while more to receive\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 137 | "\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket.Socket.recv\u001b[0;34m()\u001b[0m\n", 138 | "\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket.Socket.recv\u001b[0;34m()\u001b[0m\n", 139 | "\u001b[0;32mzmq/backend/cython/socket.pyx\u001b[0m in \u001b[0;36mzmq.backend.cython.socket._recv_copy\u001b[0;34m()\u001b[0m\n", 140 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/zmq/backend/cython/checkrc.pxd\u001b[0m in \u001b[0;36mzmq.backend.cython.checkrc._check_rc\u001b[0;34m()\u001b[0m\n", 141 | "\u001b[0;31mKeyboardInterrupt\u001b[0m: ", 142 | "\nDuring handling of the above exception, another exception occurred:\n", 143 | "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", 144 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Girdiğiniz değer bir tam sayı değil\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0;32mcontinue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 31\u001b[0;31m \u001b[0mmain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 145 | "\u001b[0;32m\u001b[0m in \u001b[0;36mmain\u001b[0;34m()\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0mdeger\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Lütfen bir tam sayı girin ... : \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0mswitch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdeger\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 146 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 702\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 703\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 704\u001b[0;31m \u001b[0mpassword\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 705\u001b[0m )\n\u001b[1;32m 706\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", 147 | "\u001b[0;32m/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 732\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 733\u001b[0m \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 734\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 735\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 736\u001b[0m \u001b[0;32mbreak\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 148 | "\u001b[0;31mKeyboardInterrupt\u001b[0m: " 149 | ] 150 | } 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "metadata": { 156 | "colab": { 157 | "base_uri": "https://localhost:8080/" 158 | }, 159 | "id": "zXZrXxR2XFdo", 160 | "outputId": "0dc2b053-d4bf-4f8c-e129-885637e47ef6" 161 | }, 162 | "source": [ 163 | "class Doviz:\n", 164 | " kur={'EURO':10,\n", 165 | " 'USD':8,\n", 166 | " 'CHF':3.87\n", 167 | " }\n", 168 | " def __init__(self,kur,miktar): #yapıcı metot\n", 169 | " self.kur=kur\n", 170 | " self.miktar=miktar\n", 171 | " \n", 172 | " def __add__(self, other):\n", 173 | " s=self.miktar*Doviz.kur[self.kur]\n", 174 | " o=other.miktar*Doviz.kur[other.kur]\n", 175 | " return s+o\n", 176 | " \n", 177 | " def __str__(self): #to.string()\n", 178 | " return (\"%s %s\"%(self.miktar,self.kur))\n", 179 | " \n", 180 | "def main():\n", 181 | " print(\"Kur Hesaplama\\n\")\n", 182 | " dolar=Doviz(\"USD\",2.5)\n", 183 | " euro=Doviz(\"EURO\",3)\n", 184 | " toplam=dolar+euro\n", 185 | " print(dolar,\"+\" , euro,\"=\",toplam ,\"TL \")\n", 186 | " \n", 187 | " print(\"\\n\\n**********************\\n\")\n", 188 | " \n", 189 | " chf = Doviz(\"CHF\", 50)\n", 190 | " euro = Doviz(\"EURO\", 35)\n", 191 | " toplam2 = chf + euro\n", 192 | " print(chf, \"+\", euro, \"=\", toplam2, \"TL \")\n", 193 | " \n", 194 | "main()" 195 | ], 196 | "execution_count": 4, 197 | "outputs": [ 198 | { 199 | "output_type": "stream", 200 | "text": [ 201 | "Kur Hesaplama\n", 202 | "\n", 203 | "2.5 USD + 3 EURO = 50.0 TL \n", 204 | "\n", 205 | "\n", 206 | "**********************\n", 207 | "\n", 208 | "50 CHF + 35 EURO = 543.5 TL \n" 209 | ], 210 | "name": "stdout" 211 | } 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "metadata": { 217 | "colab": { 218 | "base_uri": "https://localhost:8080/" 219 | }, 220 | "id": "iYcxdd-LXWKx", 221 | "outputId": "b97e7f86-619f-4a26-9b9c-039a24f6824d" 222 | }, 223 | "source": [ 224 | "class Kutu:\n", 225 | " \n", 226 | " def __init__(self,uzunluk,genislik,yukseklik): #yapıcı method\n", 227 | " \n", 228 | " self.uzunluk=uzunluk\n", 229 | " self.genislik=genislik\n", 230 | " self.yukseklik=yukseklik\n", 231 | " \n", 232 | " def __str__(self): #nesnelerin toString edilmiş hali\n", 233 | " return \" [ uzunluk = \" + str(self.uzunluk) + \" genislik = \" + str(self.genislik) + \" yukseklik = \" + str(self.yukseklik)\\\n", 234 | " +\" hacim = \"+str(self.hacim())+ \" ]\"\n", 235 | " \n", 236 | " def hacim(self):\n", 237 | " return self.uzunluk*self.genislik*self.yukseklik\n", 238 | " \n", 239 | " def __lt__(self,other): #nesnelerin karşılaştırılması\n", 240 | " \n", 241 | " if (self.hacim() < other.hacim()):\n", 242 | " \n", 243 | " return \"Sonuç \\n1.Parametredeki Kutu Büyüktür\"\n", 244 | " \n", 245 | " elif(self.hacim() > other.hacim()):\n", 246 | " \n", 247 | " return \"Sonuç \\n2.Parametredeki Kutu Büyüktür\"\n", 248 | " \n", 249 | " else:\n", 250 | " \n", 251 | " return \"Sonuç \\nKutular Eşittir!\"\n", 252 | " \n", 253 | " \n", 254 | "kutu1=Kutu(3,4,5)#60\n", 255 | "kutu2=Kutu(4,5,6)#120\n", 256 | "kutu3=Kutu(4,5,6)#120\n", 257 | " \n", 258 | "print(\"\\nkutu1=\", kutu1) #toString burada çalışır\n", 259 | "print(\"kutu2=\", kutu2) #toString burada çalışır\n", 260 | "print(kutu1>kutu2) #nesneler burada karşılaştırılır\n", 261 | " \n", 262 | "print(\"\\n********************************************************************\\n\")\n", 263 | " \n", 264 | "print(\"kutu2=\", kutu2) #toString burada çalışır\n", 265 | "print(\"kutu3=\", kutu3) #toString burada çalışır\n", 266 | "print(kutu2>kutu3) #nesneler burada karşılaştırılır" 267 | ], 268 | "execution_count": 5, 269 | "outputs": [ 270 | { 271 | "output_type": "stream", 272 | "text": [ 273 | "\n", 274 | "kutu1= [ uzunluk = 3 genislik = 4 yukseklik = 5 hacim = 60 ]\n", 275 | "kutu2= [ uzunluk = 4 genislik = 5 yukseklik = 6 hacim = 120 ]\n", 276 | "Sonuç \n", 277 | "2.Parametredeki Kutu Büyüktür\n", 278 | "\n", 279 | "********************************************************************\n", 280 | "\n", 281 | "kutu2= [ uzunluk = 4 genislik = 5 yukseklik = 6 hacim = 120 ]\n", 282 | "kutu3= [ uzunluk = 4 genislik = 5 yukseklik = 6 hacim = 120 ]\n", 283 | "Sonuç \n", 284 | "Kutular Eşittir!\n" 285 | ], 286 | "name": "stdout" 287 | } 288 | ] 289 | }, 290 | { 291 | "cell_type": "markdown", 292 | "metadata": { 293 | "id": "4g0EY9e9YmTT" 294 | }, 295 | "source": [ 296 | "**Collections**" 297 | ] 298 | }, 299 | { 300 | "cell_type": "code", 301 | "metadata": { 302 | "colab": { 303 | "base_uri": "https://localhost:8080/" 304 | }, 305 | "id": "5MLma2JlYpuZ", 306 | "outputId": "911d4d33-b7aa-4985-ec03-4611f5a648e7" 307 | }, 308 | "source": [ 309 | "from collections import deque\n", 310 | "\n", 311 | "dq = deque([1,2,3,4,5]) #maxlen = None\n", 312 | "dq_maxlen = deque([1,2,3,4,5,6],4) #maxlen = 4\n", 313 | "print(\"dq: \",dq)\n", 314 | "print(\"dq_maxlen: \",dq_maxlen)\n", 315 | "print(\"dq maxlen: \",dq_maxlen.maxlen)" 316 | ], 317 | "execution_count": 6, 318 | "outputs": [ 319 | { 320 | "output_type": "stream", 321 | "text": [ 322 | "dq: deque([1, 2, 3, 4, 5])\n", 323 | "dq_maxlen: deque([3, 4, 5, 6], maxlen=4)\n", 324 | "dq maxlen: 4\n" 325 | ], 326 | "name": "stdout" 327 | } 328 | ] 329 | }, 330 | { 331 | "cell_type": "code", 332 | "metadata": { 333 | "colab": { 334 | "base_uri": "https://localhost:8080/" 335 | }, 336 | "id": "VV1rIfuXY3fa", 337 | "outputId": "a7c30da1-54fb-4670-c657-8223a94947c7" 338 | }, 339 | "source": [ 340 | "dq_maxlen = deque([1,2,3], 3)\n", 341 | "dq_maxlen.append(4) #Sağa ekleme\n", 342 | "print(\"dq_maxlen: \", dq_maxlen) # 2 ,3 ,4" 343 | ], 344 | "execution_count": 7, 345 | "outputs": [ 346 | { 347 | "output_type": "stream", 348 | "text": [ 349 | "dq_maxlen: deque([2, 3, 4], maxlen=3)\n" 350 | ], 351 | "name": "stdout" 352 | } 353 | ] 354 | }, 355 | { 356 | "cell_type": "code", 357 | "metadata": { 358 | "colab": { 359 | "base_uri": "https://localhost:8080/" 360 | }, 361 | "id": "qv2zyyaVY9Qn", 362 | "outputId": "c4a2de4b-82a4-46e2-eac4-bd8e4ff940f9" 363 | }, 364 | "source": [ 365 | "dq_maxlen.appendleft(5) # Sola ekleme 5, 2 ,3\n", 366 | "print(\"dq_maxlen: \", dq_maxlen)" 367 | ], 368 | "execution_count": 8, 369 | "outputs": [ 370 | { 371 | "output_type": "stream", 372 | "text": [ 373 | "dq_maxlen: deque([5, 2, 3], maxlen=3)\n" 374 | ], 375 | "name": "stdout" 376 | } 377 | ] 378 | }, 379 | { 380 | "cell_type": "code", 381 | "metadata": { 382 | "colab": { 383 | "base_uri": "https://localhost:8080/" 384 | }, 385 | "id": "xRLMo0E_ZCvq", 386 | "outputId": "1a0e9a44-76b3-4d6d-93ac-add603ddd11b" 387 | }, 388 | "source": [ 389 | "dq = deque(\"deque\")\n", 390 | "print(\"dq: \", dq)" 391 | ], 392 | "execution_count": 12, 393 | "outputs": [ 394 | { 395 | "output_type": "stream", 396 | "text": [ 397 | "dq: deque(['d', 'e', 'q', 'u', 'e'])\n" 398 | ], 399 | "name": "stdout" 400 | } 401 | ] 402 | }, 403 | { 404 | "cell_type": "code", 405 | "metadata": { 406 | "colab": { 407 | "base_uri": "https://localhost:8080/" 408 | }, 409 | "id": "J3DjZQjhZHEq", 410 | "outputId": "f71a9158-1f19-477d-b6d9-07fcc27ca489" 411 | }, 412 | "source": [ 413 | "dq.extend(\"extend\")\n", 414 | "print(\"dq: \", dq)" 415 | ], 416 | "execution_count": 13, 417 | "outputs": [ 418 | { 419 | "output_type": "stream", 420 | "text": [ 421 | "dq: deque(['d', 'e', 'q', 'u', 'e', 'e', 'x', 't', 'e', 'n', 'd'])\n" 422 | ], 423 | "name": "stdout" 424 | } 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "metadata": { 430 | "colab": { 431 | "base_uri": "https://localhost:8080/" 432 | }, 433 | "id": "beVS3zIMZKrn", 434 | "outputId": "db0e90ec-6f5e-4463-b7b7-730557a6e04c" 435 | }, 436 | "source": [ 437 | "dq = deque([1,2,3]) # 1 2 3 ==> 3 1 2 ==>2 3 1\n", 438 | "\n", 439 | "dq.rotate(1)\n", 440 | "print(\"dq: \", dq)" 441 | ], 442 | "execution_count": 14, 443 | "outputs": [ 444 | { 445 | "output_type": "stream", 446 | "text": [ 447 | "dq: deque([3, 1, 2])\n" 448 | ], 449 | "name": "stdout" 450 | } 451 | ] 452 | }, 453 | { 454 | "cell_type": "code", 455 | "metadata": { 456 | "colab": { 457 | "base_uri": "https://localhost:8080/" 458 | }, 459 | "id": "1Htak8vrBXCm", 460 | "outputId": "fbf6f9e9-4a2d-48a5-9639-d0a902d6730f" 461 | }, 462 | "source": [ 463 | "dq.rotate(2) # 2 3 1 ==> 3 1 2\n", 464 | "print(\"dq: \", dq)" 465 | ], 466 | "execution_count": 16, 467 | "outputs": [ 468 | { 469 | "output_type": "stream", 470 | "text": [ 471 | "dq: deque([3, 1, 2])\n" 472 | ], 473 | "name": "stdout" 474 | } 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "metadata": { 480 | "id": "RlLb9N2yZZJy", 481 | "colab": { 482 | "base_uri": "https://localhost:8080/" 483 | }, 484 | "outputId": "bf50bad7-c1c8-4845-d7da-8b00eb42d1b1" 485 | }, 486 | "source": [ 487 | "dq.rotate(-2) # 3 1 2 ==> 2 3 1\n", 488 | "print(\"dq: \", dq)" 489 | ], 490 | "execution_count": 17, 491 | "outputs": [ 492 | { 493 | "output_type": "stream", 494 | "text": [ 495 | "dq: deque([2, 3, 1])\n" 496 | ], 497 | "name": "stdout" 498 | } 499 | ] 500 | }, 501 | { 502 | "cell_type": "code", 503 | "metadata": { 504 | "colab": { 505 | "base_uri": "https://localhost:8080/" 506 | }, 507 | "id": "_y-yt1myB48O", 508 | "outputId": "6e489e41-66a1-42af-88a6-a684f3a93160" 509 | }, 510 | "source": [ 511 | "dq.rotate(-1) # 3 1 2 ==> 2 3 1 ==> 3 1 2\n", 512 | "print(\"dq: \", dq)" 513 | ], 514 | "execution_count": 18, 515 | "outputs": [ 516 | { 517 | "output_type": "stream", 518 | "text": [ 519 | "dq: deque([3, 1, 2])\n" 520 | ], 521 | "name": "stdout" 522 | } 523 | ] 524 | }, 525 | { 526 | "cell_type": "code", 527 | "metadata": { 528 | "colab": { 529 | "base_uri": "https://localhost:8080/" 530 | }, 531 | "id": "Tuy0CYQhC2b8", 532 | "outputId": "e22834c5-487b-4ed1-9ee7-9bbe017e2839" 533 | }, 534 | "source": [ 535 | "dq1= deque([1,2,3,4,5]) #==>4 5 1 2 3\n", 536 | "dq1.rotate(2)\n", 537 | "print(\"dq1: \", dq1)" 538 | ], 539 | "execution_count": 21, 540 | "outputs": [ 541 | { 542 | "output_type": "stream", 543 | "text": [ 544 | "dq1: deque([4, 5, 1, 2, 3])\n" 545 | ], 546 | "name": "stdout" 547 | } 548 | ] 549 | }, 550 | { 551 | "cell_type": "code", 552 | "metadata": { 553 | "colab": { 554 | "base_uri": "https://localhost:8080/" 555 | }, 556 | "id": "K9ydvTQaDOCn", 557 | "outputId": "90072f24-c6dc-4c00-bd03-1abc8cabdee0" 558 | }, 559 | "source": [ 560 | "dq1.rotate(-3) #==> 2 3 4 5 1\n", 561 | "print(\"dq1: \", dq1)" 562 | ], 563 | "execution_count": 22, 564 | "outputs": [ 565 | { 566 | "output_type": "stream", 567 | "text": [ 568 | "dq1: deque([2, 3, 4, 5, 1])\n" 569 | ], 570 | "name": "stdout" 571 | } 572 | ] 573 | }, 574 | { 575 | "cell_type": "markdown", 576 | "metadata": { 577 | "id": "i-ip-Z7GXkLo" 578 | }, 579 | "source": [ 580 | "KAYNAKÇA\n", 581 | "\n", 582 | "1-https://www.yilmazmehmet.com\n", 583 | "\n", 584 | "2-http://www.veridefteri.com/2018/06/25/python-programlamaya-giris-22-hata-yakalama-try-except/\n", 585 | "\n", 586 | "3-https://medium.com/datarunner/python-koleksiyonlar-566af81b97d6\n", 587 | "\n" 588 | ] 589 | } 590 | ] 591 | } -------------------------------------------------------------------------------- /VeriYapilari_Ders6.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "VeriYapilari_Ders6.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyMccgb3kRKrzhg5IQ3uHQMY" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | }, 14 | "language_info": { 15 | "name": "python" 16 | } 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "code", 21 | "metadata": { 22 | "colab": { 23 | "base_uri": "https://localhost:8080/" 24 | }, 25 | "id": "ost3zIzh4z5a", 26 | "outputId": "7eea33d8-4ef0-4564-a5df-aaab6d02a6e0" 27 | }, 28 | "source": [ 29 | "kelime=input(\"Bir kelime girin :\")\n", 30 | "sozluk ={\"Computer\":\"Bilgisayar\",\n", 31 | " \"Driver\":\"Sürücü\",\n", 32 | " \"Memory\":\"Hafıza\",\n", 33 | " \"Output\":\"Çıktı\",\n", 34 | " \"Software\":\"Yazılım\",\n", 35 | " \"Printer\":\"Yazıcı\"}\n", 36 | " \n", 37 | "if kelime in sozluk:\n", 38 | " print(sozluk[kelime])\n", 39 | "else:\n", 40 | " print(\"Aradığınız kelime Sözlükte bulunamadı\")" 41 | ], 42 | "execution_count": 3, 43 | "outputs": [ 44 | { 45 | "output_type": "stream", 46 | "text": [ 47 | "Bir kelime girin :Driver\n", 48 | "Sürücü\n" 49 | ], 50 | "name": "stdout" 51 | } 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "metadata": { 57 | "colab": { 58 | "base_uri": "https://localhost:8080/" 59 | }, 60 | "id": "NzPLJwOm5CMP", 61 | "outputId": "54cee547-f961-4d43-e3a7-2ad66bb34705" 62 | }, 63 | "source": [ 64 | "kelime=input(\"Bir kelime girin :\")\n", 65 | "sozluk ={\"Computer\":\"Bilgisayar\",\n", 66 | " \"Driver\":\"Sürücü\",\n", 67 | " \"Memory\":\"Hafıza\",\n", 68 | " \"Output\":\"Çıktı\",\n", 69 | " \"Software\":\"Yazılım\",\n", 70 | " \"Printer\":\"Yazıcı\"}\n", 71 | "print(sozluk.get(kelime,\"Aradığınız kelime Sözlük içinde bulunmamaktadır\"))" 72 | ], 73 | "execution_count": 8, 74 | "outputs": [ 75 | { 76 | "output_type": "stream", 77 | "text": [ 78 | "Bir kelime girin :Computer\n", 79 | "Bilgisayar\n" 80 | ], 81 | "name": "stdout" 82 | } 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "metadata": { 88 | "colab": { 89 | "base_uri": "https://localhost:8080/" 90 | }, 91 | "id": "pddIWgrs5W5W", 92 | "outputId": "c153fab7-1c19-489a-cd4f-3257ed0e8332" 93 | }, 94 | "source": [ 95 | "sozluk ={\"Driver\":\"Sürücü\",\n", 96 | " \"Memory\":\"Hafıza\",\n", 97 | " \"Output\":\"Çıktı\",\n", 98 | " \"Software\":\"Yazılım\",\n", 99 | " \"Printer\":\"Yazıcı\"}\n", 100 | " \n", 101 | "sozluk.pop(\"Driver\") #kendisine parametre olarak gelen key'i siler...\n", 102 | "print(sozluk)" 103 | ], 104 | "execution_count": 6, 105 | "outputs": [ 106 | { 107 | "output_type": "stream", 108 | "text": [ 109 | "{'Memory': 'Hafıza', 'Output': 'Çıktı', 'Software': 'Yazılım', 'Printer': 'Yazıcı'}\n" 110 | ], 111 | "name": "stdout" 112 | } 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "metadata": { 118 | "colab": { 119 | "base_uri": "https://localhost:8080/" 120 | }, 121 | "id": "Ww0gvrgNfF-c", 122 | "outputId": "505640db-b67e-4a14-afa9-6c3d5ec2571e" 123 | }, 124 | "source": [ 125 | "ogrenci = {\n", 126 | " \"numara\": \"120\",\n", 127 | " \"ad\": \"Ahmet\",\n", 128 | " \"soyad\": \"Yılmaz\"\n", 129 | "}\n", 130 | "\n", 131 | "print(ogrenci[\"numara\"]) # 120\n", 132 | "print(ogrenci[\"ad\"]) # Ahmet\n", 133 | "print(ogrenci[\"soyad\"]) # Yılmaz" 134 | ], 135 | "execution_count": 9, 136 | "outputs": [ 137 | { 138 | "output_type": "stream", 139 | "text": [ 140 | "120\n", 141 | "Ahmet\n", 142 | "Yılmaz\n" 143 | ], 144 | "name": "stdout" 145 | } 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "metadata": { 151 | "colab": { 152 | "base_uri": "https://localhost:8080/" 153 | }, 154 | "id": "t4Crl4RGfJdd", 155 | "outputId": "5987a43d-d79c-4c74-8d7c-c594ec62a1fa" 156 | }, 157 | "source": [ 158 | "ogrenci = {\n", 159 | " \"numara\": \"120\",\n", 160 | " \"ad\": \"Ahmet\",\n", 161 | " \"soyad\": \"Yılmaz\"\n", 162 | "}\n", 163 | "\n", 164 | "numara = ogrenci.get(\"numara\")\n", 165 | "ad = ogrenci.get(\"ad\")\n", 166 | "soyad = ogrenci.get(\"soyad\")\n", 167 | "\n", 168 | "print(numara,ad,soyad)" 169 | ], 170 | "execution_count": 10, 171 | "outputs": [ 172 | { 173 | "output_type": "stream", 174 | "text": [ 175 | "120 Ahmet Yılmaz\n" 176 | ], 177 | "name": "stdout" 178 | } 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "metadata": { 184 | "colab": { 185 | "base_uri": "https://localhost:8080/" 186 | }, 187 | "id": "IxYod32RfW7v", 188 | "outputId": "577788e2-7aca-41bf-ac1f-95e32b837cad" 189 | }, 190 | "source": [ 191 | "ogrenciler = {}\n", 192 | "\n", 193 | "number = input(\"öğrenci no: \")\n", 194 | "name = input(\"öğrenci adı: \")\n", 195 | "surname = input(\"öğrenci soyad: \")\n", 196 | "phone = input(\"öğrenci telefon: \")\n", 197 | "\n", 198 | "ogrenciler.update({\n", 199 | " number: {\n", 200 | " 'ad': name,\n", 201 | " 'soyad': surname,\n", 202 | " 'telefon':phone \n", 203 | " }\n", 204 | "})" 205 | ], 206 | "execution_count": 13, 207 | "outputs": [ 208 | { 209 | "output_type": "stream", 210 | "text": [ 211 | "öğrenci no: 234\n", 212 | "öğrenci adı: XXX\n", 213 | "öğrenci soyad: YYY\n", 214 | "öğrenci telefon: 234234\n" 215 | ], 216 | "name": "stdout" 217 | } 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "metadata": { 223 | "colab": { 224 | "base_uri": "https://localhost:8080/" 225 | }, 226 | "id": "6Uc_dRAxtZ7c", 227 | "outputId": "6e2447a6-c962-49a2-b3f0-a56ef6212a3c" 228 | }, 229 | "source": [ 230 | "print(ogrenciler)" 231 | ], 232 | "execution_count": 14, 233 | "outputs": [ 234 | { 235 | "output_type": "stream", 236 | "text": [ 237 | "{'123': {'ad': 'Volkan', 'soyad': 'Altıntaş', 'telefon': '123123'}, '234': {'ad': 'XXX', 'soyad': 'YYY', 'telefon': '234234'}}\n" 238 | ], 239 | "name": "stdout" 240 | } 241 | ] 242 | }, 243 | { 244 | "cell_type": "code", 245 | "metadata": { 246 | "colab": { 247 | "base_uri": "https://localhost:8080/" 248 | }, 249 | "id": "SlP-dMJmfepY", 250 | "outputId": "720b3552-b4db-4c0c-d29d-99bc092c8575" 251 | }, 252 | "source": [ 253 | "ogrNo = input('öğrenci no: ')\n", 254 | "ogrenci = ogrenciler[ogrNo]\n", 255 | "print(ogrenci)\n", 256 | "\n", 257 | "print(f\"Aradığınız {ogrNo} nolu öğrencinin adı: {ogrenci['ad']} soyadı: {ogrenci['soyad']} ve telefonu ise {ogrenci['telefon']}\")" 258 | ], 259 | "execution_count": 16, 260 | "outputs": [ 261 | { 262 | "output_type": "stream", 263 | "text": [ 264 | "öğrenci no: 234\n", 265 | "{'ad': 'XXX', 'soyad': 'YYY', 'telefon': '234234'}\n", 266 | "Aradığınız 234 nolu öğrencinin adı: XXX soyadı: YYY ve telefonu ise 234234\n" 267 | ], 268 | "name": "stdout" 269 | } 270 | ] 271 | }, 272 | { 273 | "cell_type": "markdown", 274 | "metadata": { 275 | "id": "GrfRHIyS6uXx" 276 | }, 277 | "source": [ 278 | "**Set(Küme) Nedir ?**" 279 | ] 280 | }, 281 | { 282 | "cell_type": "code", 283 | "metadata": { 284 | "id": "EQuoVHbl50om", 285 | "colab": { 286 | "base_uri": "https://localhost:8080/" 287 | }, 288 | "outputId": "8d65e36a-604a-499c-ac0e-f0cfcbf96bd2" 289 | }, 290 | "source": [ 291 | "kume= {\"Python\",'c',4,\"Akhisar\"}\n", 292 | "print(kume)" 293 | ], 294 | "execution_count": 26, 295 | "outputs": [ 296 | { 297 | "output_type": "stream", 298 | "text": [ 299 | "{'c', 'Akhisar', 'Python', 4}\n" 300 | ], 301 | "name": "stdout" 302 | } 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "metadata": { 308 | "colab": { 309 | "base_uri": "https://localhost:8080/" 310 | }, 311 | "id": "vECAPgIq64u5", 312 | "outputId": "52f81743-f480-48c9-c392-28cddb07959b" 313 | }, 314 | "source": [ 315 | "kume={} #dict()\n", 316 | "print(type(kume))" 317 | ], 318 | "execution_count": 27, 319 | "outputs": [ 320 | { 321 | "output_type": "stream", 322 | "text": [ 323 | "\n" 324 | ], 325 | "name": "stdout" 326 | } 327 | ] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "metadata": { 332 | "colab": { 333 | "base_uri": "https://localhost:8080/" 334 | }, 335 | "id": "vXuQGlK87Aqp", 336 | "outputId": "d3c97a09-92b8-4254-8010-6130e7b4020d" 337 | }, 338 | "source": [ 339 | "kume=set()\n", 340 | "print(type(kume))" 341 | ], 342 | "execution_count": 28, 343 | "outputs": [ 344 | { 345 | "output_type": "stream", 346 | "text": [ 347 | "\n" 348 | ], 349 | "name": "stdout" 350 | } 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "metadata": { 356 | "colab": { 357 | "base_uri": "https://localhost:8080/" 358 | }, 359 | "id": "HruiJhhgyeHm", 360 | "outputId": "f3b27d4c-07af-4b08-9662-b73639bf48a9" 361 | }, 362 | "source": [ 363 | "x={\"1\":\"bir\",\"2\":\"iki\"}\n", 364 | "print(type(x)) #sözlük,dictionary,dict\n", 365 | "y={\"1\",\"2\",\"3\"}\n", 366 | "print(type(y)) #set, küme" 367 | ], 368 | "execution_count": 30, 369 | "outputs": [ 370 | { 371 | "output_type": "stream", 372 | "text": [ 373 | "\n", 374 | "\n" 375 | ], 376 | "name": "stdout" 377 | } 378 | ] 379 | }, 380 | { 381 | "cell_type": "code", 382 | "metadata": { 383 | "colab": { 384 | "base_uri": "https://localhost:8080/" 385 | }, 386 | "id": "gnFPhaID7GdK", 387 | "outputId": "2306aef1-1cae-4011-9cad-ece829153fac" 388 | }, 389 | "source": [ 390 | "kume= {\"Python\",'c',4,\"Akhisar\",4}\n", 391 | "print(kume)" 392 | ], 393 | "execution_count": 29, 394 | "outputs": [ 395 | { 396 | "output_type": "stream", 397 | "text": [ 398 | "{'c', 'Akhisar', 'Python', 4}\n" 399 | ], 400 | "name": "stdout" 401 | } 402 | ] 403 | }, 404 | { 405 | "cell_type": "code", 406 | "metadata": { 407 | "colab": { 408 | "base_uri": "https://localhost:8080/" 409 | }, 410 | "id": "kp_nWghrdLMd", 411 | "outputId": "ad12600e-5ec6-4dee-99db-1234a46addfa" 412 | }, 413 | "source": [ 414 | "kume= {\"Python\",'c',4,\"Cahit\",\"4\",\"python\"}\n", 415 | "print(len(kume))" 416 | ], 417 | "execution_count": 33, 418 | "outputs": [ 419 | { 420 | "output_type": "stream", 421 | "text": [ 422 | "6\n" 423 | ], 424 | "name": "stdout" 425 | } 426 | ] 427 | }, 428 | { 429 | "cell_type": "code", 430 | "metadata": { 431 | "colab": { 432 | "base_uri": "https://localhost:8080/" 433 | }, 434 | "id": "DDlb51c7dOdY", 435 | "outputId": "cb223491-9df2-4c39-e6fa-070ef0757e87" 436 | }, 437 | "source": [ 438 | "kume ={1,2,3,4,5}\n", 439 | "kume.add(6)\n", 440 | "print(kume)" 441 | ], 442 | "execution_count": 34, 443 | "outputs": [ 444 | { 445 | "output_type": "stream", 446 | "text": [ 447 | "{1, 2, 3, 4, 5, 6}\n" 448 | ], 449 | "name": "stdout" 450 | } 451 | ] 452 | }, 453 | { 454 | "cell_type": "code", 455 | "metadata": { 456 | "colab": { 457 | "base_uri": "https://localhost:8080/" 458 | }, 459 | "id": "gEPN-MuedU1L", 460 | "outputId": "b9b3d855-a23b-44a3-9b1f-6d2af0351de4" 461 | }, 462 | "source": [ 463 | "kume ={1,2,3,4,5,6}\n", 464 | "kume_yedek =set()\n", 465 | "kume_yedek=kume.copy()\n", 466 | "print(kume_yedek)" 467 | ], 468 | "execution_count": 35, 469 | "outputs": [ 470 | { 471 | "output_type": "stream", 472 | "text": [ 473 | "{1, 2, 3, 4, 5, 6}\n" 474 | ], 475 | "name": "stdout" 476 | } 477 | ] 478 | }, 479 | { 480 | "cell_type": "code", 481 | "metadata": { 482 | "colab": { 483 | "base_uri": "https://localhost:8080/" 484 | }, 485 | "id": "QtzJl5AWdgyw", 486 | "outputId": "c431ab99-b8e7-4353-99c8-df449098336e" 487 | }, 488 | "source": [ 489 | "kume ={1,2,3,4,5,6}\n", 490 | "kume_2={6,7,8,9,10}\n", 491 | "kume.update(kume_2)\n", 492 | "print(kume)" 493 | ], 494 | "execution_count": 37, 495 | "outputs": [ 496 | { 497 | "output_type": "stream", 498 | "text": [ 499 | "{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}\n" 500 | ], 501 | "name": "stdout" 502 | } 503 | ] 504 | }, 505 | { 506 | "cell_type": "code", 507 | "metadata": { 508 | "id": "TJHQ4IGKdlmB", 509 | "colab": { 510 | "base_uri": "https://localhost:8080/" 511 | }, 512 | "outputId": "025f9e7b-8b02-435c-b058-c1220165fd28" 513 | }, 514 | "source": [ 515 | "kume ={1,2,3,4,5,6}\n", 516 | "kume.remove(4)\n", 517 | "print(kume)" 518 | ], 519 | "execution_count": 40, 520 | "outputs": [ 521 | { 522 | "output_type": "stream", 523 | "text": [ 524 | "{1, 2, 3, 5, 6}\n" 525 | ], 526 | "name": "stdout" 527 | } 528 | ] 529 | }, 530 | { 531 | "cell_type": "code", 532 | "metadata": { 533 | "id": "ZVmjATFWdySC" 534 | }, 535 | "source": [ 536 | "A = {1,2,3,4,9}\n", 537 | "B = {3,4,5,6,10}\n", 538 | "C = {4,7,8,9,10}" 539 | ], 540 | "execution_count": 41, 541 | "outputs": [] 542 | }, 543 | { 544 | "cell_type": "code", 545 | "metadata": { 546 | "colab": { 547 | "base_uri": "https://localhost:8080/" 548 | }, 549 | "id": "IXo6pqBnd3eo", 550 | "outputId": "a7e7e329-846b-4afa-f752-ce0d7e7d92e8" 551 | }, 552 | "source": [ 553 | "print(A.union(B))" 554 | ], 555 | "execution_count": 42, 556 | "outputs": [ 557 | { 558 | "output_type": "stream", 559 | "text": [ 560 | "{1, 2, 3, 4, 5, 6, 9, 10}\n" 561 | ], 562 | "name": "stdout" 563 | } 564 | ] 565 | }, 566 | { 567 | "cell_type": "code", 568 | "metadata": { 569 | "colab": { 570 | "base_uri": "https://localhost:8080/" 571 | }, 572 | "id": "GG42w8RPd84e", 573 | "outputId": "7ee8cc02-24bd-4ac8-e06e-4f484ce6587c" 574 | }, 575 | "source": [ 576 | "print(A.intersection(C))" 577 | ], 578 | "execution_count": 43, 579 | "outputs": [ 580 | { 581 | "output_type": "stream", 582 | "text": [ 583 | "{9, 4}\n" 584 | ], 585 | "name": "stdout" 586 | } 587 | ] 588 | }, 589 | { 590 | "cell_type": "code", 591 | "metadata": { 592 | "colab": { 593 | "base_uri": "https://localhost:8080/" 594 | }, 595 | "id": "K7se7P1yeCAo", 596 | "outputId": "de0b2941-0844-45ce-f5a4-4195ee9a0073" 597 | }, 598 | "source": [ 599 | "print(A.intersection(B.intersection(C)))" 600 | ], 601 | "execution_count": 44, 602 | "outputs": [ 603 | { 604 | "output_type": "stream", 605 | "text": [ 606 | "{4}\n" 607 | ], 608 | "name": "stdout" 609 | } 610 | ] 611 | }, 612 | { 613 | "cell_type": "code", 614 | "metadata": { 615 | "colab": { 616 | "base_uri": "https://localhost:8080/" 617 | }, 618 | "id": "LNuyz-L7eI96", 619 | "outputId": "20358c70-d04b-4cf1-c44e-04c6274a1fcb" 620 | }, 621 | "source": [ 622 | "print(A.difference(B))" 623 | ], 624 | "execution_count": 45, 625 | "outputs": [ 626 | { 627 | "output_type": "stream", 628 | "text": [ 629 | "{1, 2, 9}\n" 630 | ], 631 | "name": "stdout" 632 | } 633 | ] 634 | }, 635 | { 636 | "cell_type": "code", 637 | "metadata": { 638 | "colab": { 639 | "base_uri": "https://localhost:8080/" 640 | }, 641 | "id": "cg7RAG-aeNcU", 642 | "outputId": "7ff74a89-fe6a-4e19-db64-89ad0b874bd3" 643 | }, 644 | "source": [ 645 | "A = {1,2,5,8,9,12}\n", 646 | "B = {1,2,5}\n", 647 | " \n", 648 | "print(B.issubset(A))" 649 | ], 650 | "execution_count": 46, 651 | "outputs": [ 652 | { 653 | "output_type": "stream", 654 | "text": [ 655 | "True\n" 656 | ], 657 | "name": "stdout" 658 | } 659 | ] 660 | }, 661 | { 662 | "cell_type": "code", 663 | "metadata": { 664 | "colab": { 665 | "base_uri": "https://localhost:8080/" 666 | }, 667 | "id": "Dqrz1dZ28fXm", 668 | "outputId": "b644fe0a-1da6-4391-b8c1-d6737d7774af" 669 | }, 670 | "source": [ 671 | "meyveler={\"elma\",\"armut\",\"karpuz\"}\n", 672 | "for meyve in meyveler:\n", 673 | " print(meyve)" 674 | ], 675 | "execution_count": 47, 676 | "outputs": [ 677 | { 678 | "output_type": "stream", 679 | "text": [ 680 | "armut\n", 681 | "karpuz\n", 682 | "elma\n" 683 | ], 684 | "name": "stdout" 685 | } 686 | ] 687 | }, 688 | { 689 | "cell_type": "code", 690 | "metadata": { 691 | "colab": { 692 | "base_uri": "https://localhost:8080/" 693 | }, 694 | "id": "IOQUyxtJ8z7l", 695 | "outputId": "61e748fd-934f-473e-d551-8680759b0608" 696 | }, 697 | "source": [ 698 | "iller={\"Manisa\",\"Denizli\",\"İzmir\",\"Balıkesir\"}\n", 699 | "print(\"İzmir\" in iller)" 700 | ], 701 | "execution_count": 51, 702 | "outputs": [ 703 | { 704 | "output_type": "stream", 705 | "text": [ 706 | "True\n" 707 | ], 708 | "name": "stdout" 709 | } 710 | ] 711 | }, 712 | { 713 | "cell_type": "code", 714 | "metadata": { 715 | "colab": { 716 | "base_uri": "https://localhost:8080/", 717 | "height": 35 718 | }, 719 | "id": "LNn_VPzA9uHk", 720 | "outputId": "48f81ab8-1eae-45ef-f023-0d94e40fd541" 721 | }, 722 | "source": [ 723 | "iller={\"Manisa\",\"Denizli\",\"İzmir\",\"Balıkesir\"}\n", 724 | "iller.pop()" 725 | ], 726 | "execution_count": 57, 727 | "outputs": [ 728 | { 729 | "output_type": "execute_result", 730 | "data": { 731 | "application/vnd.google.colaboratory.intrinsic+json": { 732 | "type": "string" 733 | }, 734 | "text/plain": [ 735 | "'Balıkesir'" 736 | ] 737 | }, 738 | "metadata": { 739 | "tags": [] 740 | }, 741 | "execution_count": 57 742 | } 743 | ] 744 | }, 745 | { 746 | "cell_type": "code", 747 | "metadata": { 748 | "colab": { 749 | "base_uri": "https://localhost:8080/" 750 | }, 751 | "id": "yGjDKICM-L-0", 752 | "outputId": "15f18718-b269-46d1-b03e-b33ad21eb75a" 753 | }, 754 | "source": [ 755 | "iller.clear() #içerisindeki bilgiler silinir.\n", 756 | "iller" 757 | ], 758 | "execution_count": 59, 759 | "outputs": [ 760 | { 761 | "output_type": "execute_result", 762 | "data": { 763 | "text/plain": [ 764 | "set()" 765 | ] 766 | }, 767 | "metadata": { 768 | "tags": [] 769 | }, 770 | "execution_count": 59 771 | } 772 | ] 773 | }, 774 | { 775 | "cell_type": "code", 776 | "metadata": { 777 | "colab": { 778 | "base_uri": "https://localhost:8080/", 779 | "height": 198 780 | }, 781 | "id": "QvtZn57l-R9M", 782 | "outputId": "325652c9-eac7-4fb7-a128-5f016e311cc4" 783 | }, 784 | "source": [ 785 | "iller={\"Manisa\",\"Denizli\",\"İzmir\",\"Balıkesir\"}\n", 786 | "del iller #tüm set listesi tamamen silinir.\n", 787 | "iller" 788 | ], 789 | "execution_count": 61, 790 | "outputs": [ 791 | { 792 | "output_type": "error", 793 | "ename": "NameError", 794 | "evalue": "ignored", 795 | "traceback": [ 796 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 797 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", 798 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0miller\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m\"Manisa\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"Denizli\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"İzmir\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"Balıkesir\"\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0miller\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0miller\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 799 | "\u001b[0;31mNameError\u001b[0m: name 'iller' is not defined" 800 | ] 801 | } 802 | ] 803 | }, 804 | { 805 | "cell_type": "code", 806 | "metadata": { 807 | "colab": { 808 | "base_uri": "https://localhost:8080/" 809 | }, 810 | "id": "Cg4E85JHBBmy", 811 | "outputId": "61f9f4e2-8c7e-4d13-88af-db3bbcaee373" 812 | }, 813 | "source": [ 814 | "A={1,2,3}\n", 815 | "B={3,2,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}#{1,2,3}\n", 816 | "print(A==B) #true, false" 817 | ], 818 | "execution_count": 71, 819 | "outputs": [ 820 | { 821 | "output_type": "stream", 822 | "text": [ 823 | "True\n" 824 | ], 825 | "name": "stdout" 826 | } 827 | ] 828 | }, 829 | { 830 | "cell_type": "markdown", 831 | "metadata": { 832 | "id": "CeSKQcF3efAz" 833 | }, 834 | "source": [ 835 | "**Frozenset(Kısıtlanmış Küme)**" 836 | ] 837 | }, 838 | { 839 | "cell_type": "code", 840 | "metadata": { 841 | "colab": { 842 | "base_uri": "https://localhost:8080/" 843 | }, 844 | "id": "a5AJogs6ePnF", 845 | "outputId": "1c8411c1-cbab-4013-eb2f-c93e9f9934c2" 846 | }, 847 | "source": [ 848 | "kisitli_kume = frozenset([\"Python\",3.14,5,'A'])\n", 849 | "print(kisitli_kume)\n", 850 | "#mutable (değiştirebilir , immutable (değiştirilemez)\n", 851 | "frozenset({5, 3.14, 'Python', 'A'})" 852 | ], 853 | "execution_count": 62, 854 | "outputs": [ 855 | { 856 | "output_type": "stream", 857 | "text": [ 858 | "frozenset({'A', 3.14, 'Python', 5})\n" 859 | ], 860 | "name": "stdout" 861 | }, 862 | { 863 | "output_type": "execute_result", 864 | "data": { 865 | "text/plain": [ 866 | "frozenset({3.14, 5, 'A', 'Python'})" 867 | ] 868 | }, 869 | "metadata": { 870 | "tags": [] 871 | }, 872 | "execution_count": 62 873 | } 874 | ] 875 | }, 876 | { 877 | "cell_type": "code", 878 | "metadata": { 879 | "colab": { 880 | "base_uri": "https://localhost:8080/", 881 | "height": 164 882 | }, 883 | "id": "HsP30Tx7etX0", 884 | "outputId": "8699833d-4c16-4bab-d3c8-0596d1113bf3" 885 | }, 886 | "source": [ 887 | "kisitli_kume.remove(\"Python\")" 888 | ], 889 | "execution_count": 63, 890 | "outputs": [ 891 | { 892 | "output_type": "error", 893 | "ename": "AttributeError", 894 | "evalue": "ignored", 895 | "traceback": [ 896 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 897 | "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", 898 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mkisitli_kume\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mremove\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Python\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 899 | "\u001b[0;31mAttributeError\u001b[0m: 'frozenset' object has no attribute 'remove'" 900 | ] 901 | } 902 | ] 903 | }, 904 | { 905 | "cell_type": "code", 906 | "metadata": { 907 | "id": "oGPfqceXeufK", 908 | "colab": { 909 | "base_uri": "https://localhost:8080/", 910 | "height": 164 911 | }, 912 | "outputId": "a961d4cb-d593-406a-facb-02ab184b6e4e" 913 | }, 914 | "source": [ 915 | "kisitli_kume.add(\"Bilgisayar\")" 916 | ], 917 | "execution_count": 64, 918 | "outputs": [ 919 | { 920 | "output_type": "error", 921 | "ename": "AttributeError", 922 | "evalue": "ignored", 923 | "traceback": [ 924 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 925 | "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", 926 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mkisitli_kume\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Bilgisayar\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 927 | "\u001b[0;31mAttributeError\u001b[0m: 'frozenset' object has no attribute 'add'" 928 | ] 929 | } 930 | ] 931 | }, 932 | { 933 | "cell_type": "code", 934 | "metadata": { 935 | "colab": { 936 | "base_uri": "https://localhost:8080/" 937 | }, 938 | "id": "VZZXNEUSAMdB", 939 | "outputId": "0c7dc2ce-f2bb-4980-a075-181ca64fb515" 940 | }, 941 | "source": [ 942 | "for bilgi in kisitli_kume:\n", 943 | " bilgi=3\n", 944 | " print(\"Değiştirildi..\")" 945 | ], 946 | "execution_count": 68, 947 | "outputs": [ 948 | { 949 | "output_type": "stream", 950 | "text": [ 951 | "Değiştirildi..\n", 952 | "Değiştirildi..\n", 953 | "Değiştirildi..\n", 954 | "Değiştirildi..\n" 955 | ], 956 | "name": "stdout" 957 | } 958 | ] 959 | }, 960 | { 961 | "cell_type": "code", 962 | "metadata": { 963 | "colab": { 964 | "base_uri": "https://localhost:8080/" 965 | }, 966 | "id": "-ElI5eeKApVZ", 967 | "outputId": "54bd54f1-babb-4e77-fd00-f558e0f33977" 968 | }, 969 | "source": [ 970 | "kisitli_kume" 971 | ], 972 | "execution_count": 69, 973 | "outputs": [ 974 | { 975 | "output_type": "execute_result", 976 | "data": { 977 | "text/plain": [ 978 | "frozenset({3.14, 5, 'A', 'Python'})" 979 | ] 980 | }, 981 | "metadata": { 982 | "tags": [] 983 | }, 984 | "execution_count": 69 985 | } 986 | ] 987 | }, 988 | { 989 | "cell_type": "markdown", 990 | "metadata": { 991 | "id": "Z2odXhYHeW0g" 992 | }, 993 | "source": [ 994 | "KAYNAKÇA:\n", 995 | "\n", 996 | "1-https://www.mobilhanem.com/python-set-kume-ve-fronzsetkisitlanmis-kume/\n", 997 | "\n", 998 | "2-https://www.sadikturan.com/python-objeleri-ve-veri-yapilari/python-dictionary/1379\n", 999 | "\n" 1000 | ] 1001 | } 1002 | ] 1003 | } --------------------------------------------------------------------------------