├── README.md ├── deneme.db ├── kutuphane.py ├── sqliteGiris.py ├── ders1.ipynb ├── Ders6.ipynb ├── Ders5.ipynb ├── Lambda_Recursive.ipynb ├── Ders7.ipynb ├── Ders4.ipynb ├── Ders3.ipynb └── Ders2.ipynb /README.md: -------------------------------------------------------------------------------- 1 | 2020-2021 Python ders notları paylaşımı... 2 | -------------------------------------------------------------------------------- /deneme.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VolkanAltintas/Python-Dersleri/HEAD/deneme.db -------------------------------------------------------------------------------- /kutuphane.py: -------------------------------------------------------------------------------- 1 | def yazdir(imlec): 2 | komut ="Select * from veri" 3 | imlec.execute(komut) 4 | bilgiler=imlec.fetchall() 5 | print(bilgiler) 6 | 7 | def listele(): 8 | print('Listeleme işlemi yapıldı...') 9 | 10 | def topla(a,b): 11 | return a+b 12 | 13 | def komutCalistir(imlec,komut,db): 14 | imlec.execute(komut) 15 | db.commit() -------------------------------------------------------------------------------- /sqliteGiris.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | #import kutuphane 3 | from kutuphane import komutCalistir, listele, topla, yazdir 4 | 5 | db=sqlite3.connect('deneme.db') 6 | 7 | imlec=db.cursor() 8 | 9 | 10 | 11 | """ 12 | komut="CREATE TABLE IF NOT EXISTS veri(ad,soyad,yas)" 13 | imlec.execute(komut) 14 | 15 | komut="INSERT INTO veri VALUES('Ahmet','Avcu',18)" 16 | imlec.execute(komut) 17 | db.commit() 18 | 19 | komut="Select * from veri" 20 | imlec.execute(komut) 21 | """ 22 | """ 23 | bilgiler=imlec.fetchall() 24 | print(bilgiler) 25 | 26 | for bilgi in imlec: 27 | print(bilgi) 28 | 29 | komut="select * from veri where ad=?" 30 | imlec.execute(komut,('Erhan',)) 31 | bilgi=imlec.fetchone() 32 | 33 | print("İsim :"+str(bilgi[0])) 34 | print("Soyisim :"+str(bilgi[1])) 35 | print("Yaş :"+str(bilgi[2])) 36 | 37 | komut="select * from veri" 38 | imlec.execute(komut) 39 | bilgiler=imlec.fetchmany(3) 40 | print(bilgiler) 41 | 42 | 43 | komut="UPDATE veri SET yas=? where ad=?" 44 | imlec.execute(komut,(20,'Erhan')) 45 | db.commit() 46 | 47 | komut ="Select * from veri" 48 | imlec.execute(komut) 49 | bilgiler=imlec.fetchall() 50 | print(bilgiler) 51 | 52 | 53 | komut="Delete from veri where ad=?" 54 | imlec.execute(komut,('Volkan',)) 55 | db.commit() 56 | """ 57 | #komut="INSERT INTO veri VALUES('Ayça','Topçu',18)" 58 | komutCalistir(imlec,"INSERT INTO veri VALUES('Bahadır','Akkaşoğlu',22)",db) 59 | yazdir(imlec) 60 | -------------------------------------------------------------------------------- /ders1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "ders1.ipynb", 7 | "provenance": [] 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | } 13 | }, 14 | "cells": [ 15 | { 16 | "cell_type": "code", 17 | "metadata": { 18 | "id": "k8MOq1YJNcYL", 19 | "outputId": "920f042d-12c7-449a-989f-59af3da61cdd", 20 | "colab": { 21 | "base_uri": "https://localhost:8080/" 22 | } 23 | }, 24 | "source": [ 25 | "print(\"Merhaba Dünya\")" 26 | ], 27 | "execution_count": null, 28 | "outputs": [ 29 | { 30 | "output_type": "stream", 31 | "text": [ 32 | "Merhaba Dünya\n" 33 | ], 34 | "name": "stdout" 35 | } 36 | ] 37 | }, 38 | { 39 | "cell_type": "markdown", 40 | "metadata": { 41 | "id": "x8stKm13S3ZA" 42 | }, 43 | "source": [ 44 | "**Ekran çıktısı almak için kullanılır...**" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "metadata": { 50 | "id": "3tAeA6WmNpKr", 51 | "outputId": "e919f9f7-a2d1-4e57-83e8-99d1a4f02692", 52 | "colab": { 53 | "base_uri": "https://localhost:8080/" 54 | } 55 | }, 56 | "source": [ 57 | "ad = \"Volkan Altıntaş\"\n", 58 | "print(ad)\n", 59 | "sayi=35\n", 60 | "Sayi=45\n", 61 | "print(sayi)\n", 62 | "#int sayi=35; c#\n", 63 | "#string ad=\"Volkan Altıntaş\"; .py" 64 | ], 65 | "execution_count": null, 66 | "outputs": [ 67 | { 68 | "output_type": "stream", 69 | "text": [ 70 | "Volkan Altıntaş\n", 71 | "35\n" 72 | ], 73 | "name": "stdout" 74 | } 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "metadata": { 80 | "id": "yT0cMFwNN9vC", 81 | "outputId": "49097952-47ee-4cd5-ed67-051fd1798e67", 82 | "colab": { 83 | "base_uri": "https://localhost:8080/" 84 | } 85 | }, 86 | "source": [ 87 | "print(\"ad değişkenin türü:\",type(ad))\n", 88 | "print(\"sayi değişkenin türü:\",type(sayi))" 89 | ], 90 | "execution_count": null, 91 | "outputs": [ 92 | { 93 | "output_type": "stream", 94 | "text": [ 95 | "ad değişkenin türü: \n", 96 | "sayi değişkenin türü: \n" 97 | ], 98 | "name": "stdout" 99 | } 100 | ] 101 | }, 102 | { 103 | "cell_type": "code", 104 | "metadata": { 105 | "id": "JI5JTEorPfI6", 106 | "outputId": "e600f670-07bd-4203-84dc-8101eef4857e", 107 | "colab": { 108 | "base_uri": "https://localhost:8080/" 109 | } 110 | }, 111 | "source": [ 112 | "harfler=\"abcdef\" #string\n", 113 | "print(harfler.upper())\n", 114 | "print(\"abcdef\".upper())" 115 | ], 116 | "execution_count": null, 117 | "outputs": [ 118 | { 119 | "output_type": "stream", 120 | "text": [ 121 | "ABCDEF\n", 122 | "ABCDEF\n" 123 | ], 124 | "name": "stdout" 125 | } 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "metadata": { 131 | "id": "3SDPYeOmP1nK", 132 | "outputId": "b229b3f5-419f-4686-f9af-32beaa29d52c", 133 | "colab": { 134 | "base_uri": "https://localhost:8080/" 135 | } 136 | }, 137 | "source": [ 138 | "dir(harfler)" 139 | ], 140 | "execution_count": null, 141 | "outputs": [ 142 | { 143 | "output_type": "execute_result", 144 | "data": { 145 | "text/plain": [ 146 | "['__add__',\n", 147 | " '__class__',\n", 148 | " '__contains__',\n", 149 | " '__delattr__',\n", 150 | " '__dir__',\n", 151 | " '__doc__',\n", 152 | " '__eq__',\n", 153 | " '__format__',\n", 154 | " '__ge__',\n", 155 | " '__getattribute__',\n", 156 | " '__getitem__',\n", 157 | " '__getnewargs__',\n", 158 | " '__gt__',\n", 159 | " '__hash__',\n", 160 | " '__init__',\n", 161 | " '__init_subclass__',\n", 162 | " '__iter__',\n", 163 | " '__le__',\n", 164 | " '__len__',\n", 165 | " '__lt__',\n", 166 | " '__mod__',\n", 167 | " '__mul__',\n", 168 | " '__ne__',\n", 169 | " '__new__',\n", 170 | " '__reduce__',\n", 171 | " '__reduce_ex__',\n", 172 | " '__repr__',\n", 173 | " '__rmod__',\n", 174 | " '__rmul__',\n", 175 | " '__setattr__',\n", 176 | " '__sizeof__',\n", 177 | " '__str__',\n", 178 | " '__subclasshook__',\n", 179 | " 'capitalize',\n", 180 | " 'casefold',\n", 181 | " 'center',\n", 182 | " 'count',\n", 183 | " 'encode',\n", 184 | " 'endswith',\n", 185 | " 'expandtabs',\n", 186 | " 'find',\n", 187 | " 'format',\n", 188 | " 'format_map',\n", 189 | " 'index',\n", 190 | " 'isalnum',\n", 191 | " 'isalpha',\n", 192 | " 'isdecimal',\n", 193 | " 'isdigit',\n", 194 | " 'isidentifier',\n", 195 | " 'islower',\n", 196 | " 'isnumeric',\n", 197 | " 'isprintable',\n", 198 | " 'isspace',\n", 199 | " 'istitle',\n", 200 | " 'isupper',\n", 201 | " 'join',\n", 202 | " 'ljust',\n", 203 | " 'lower',\n", 204 | " 'lstrip',\n", 205 | " 'maketrans',\n", 206 | " 'partition',\n", 207 | " 'replace',\n", 208 | " 'rfind',\n", 209 | " 'rindex',\n", 210 | " 'rjust',\n", 211 | " 'rpartition',\n", 212 | " 'rsplit',\n", 213 | " 'rstrip',\n", 214 | " 'split',\n", 215 | " 'splitlines',\n", 216 | " 'startswith',\n", 217 | " 'strip',\n", 218 | " 'swapcase',\n", 219 | " 'title',\n", 220 | " 'translate',\n", 221 | " 'upper',\n", 222 | " 'zfill']" 223 | ] 224 | }, 225 | "metadata": { 226 | "tags": [] 227 | }, 228 | "execution_count": 18 229 | } 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "metadata": { 235 | "id": "yXKEkLtXQIEF", 236 | "outputId": "e4d8eb3d-a1ba-4a23-e43b-928320b26d35", 237 | "colab": { 238 | "base_uri": "https://localhost:8080/" 239 | } 240 | }, 241 | "source": [ 242 | "Ad=input(\"Lütfen Adınızı Giriniz:\")\n", 243 | "Soyad=input(\"Soyadınızı Giriniz:\")\n", 244 | "print(\"Merhaba\",Ad, Soyad)\n", 245 | "print(\"Merhaba {} {}\".format(Ad,Soyad))" 246 | ], 247 | "execution_count": null, 248 | "outputs": [ 249 | { 250 | "output_type": "stream", 251 | "text": [ 252 | "Lütfen Adınızı Giriniz:Volkan\n", 253 | "Soyadınızı Giriniz:Altıntaş\n", 254 | "Merhaba Volkan Altıntaş\n", 255 | "Merhaba Volkan Altıntaş\n" 256 | ], 257 | "name": "stdout" 258 | } 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "metadata": { 264 | "id": "FiHCHjb-Q3nP", 265 | "outputId": "8b03dba4-883e-4148-bb2e-3f97f735cdf8", 266 | "colab": { 267 | "base_uri": "https://localhost:8080/" 268 | } 269 | }, 270 | "source": [ 271 | "sayi1=int(input(\"Sayı giriniz:\"))#str 20\n", 272 | "sayi2=int(input(\"Sayı giriniz:\"))#str 10\n", 273 | "\n", 274 | "toplam=sayi1+sayi2\n", 275 | "print(toplam)" 276 | ], 277 | "execution_count": null, 278 | "outputs": [ 279 | { 280 | "output_type": "stream", 281 | "text": [ 282 | "Sayı giriniz:20\n", 283 | "Sayı giriniz:25\n", 284 | "45\n" 285 | ], 286 | "name": "stdout" 287 | } 288 | ] 289 | } 290 | ] 291 | } -------------------------------------------------------------------------------- /Ders6.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Ders6.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyMwgQ4bv6T8cB0+Yr3r2eeZ" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "code", 18 | "metadata": { 19 | "colab": { 20 | "base_uri": "https://localhost:8080/" 21 | }, 22 | "id": "IUo6reQnRlJO", 23 | "outputId": "c473785a-e576-4314-e616-6189b2b6ca1a" 24 | }, 25 | "source": [ 26 | "x = 0\n", 27 | "for i in range(5): #0-4 5adım\n", 28 | " for j in range(-1, -5, -1): #-1 - -4 4adım\n", 29 | " x += 1 #x=x+1\n", 30 | " print(x)" 31 | ], 32 | "execution_count": null, 33 | "outputs": [ 34 | { 35 | "output_type": "stream", 36 | "text": [ 37 | "1\n", 38 | "2\n", 39 | "3\n", 40 | "4\n", 41 | "5\n", 42 | "6\n", 43 | "7\n", 44 | "8\n", 45 | "9\n", 46 | "10\n", 47 | "11\n", 48 | "12\n", 49 | "13\n", 50 | "14\n", 51 | "15\n", 52 | "16\n", 53 | "17\n", 54 | "18\n", 55 | "19\n", 56 | "20\n" 57 | ], 58 | "name": "stdout" 59 | } 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "metadata": { 65 | "colab": { 66 | "base_uri": "https://localhost:8080/" 67 | }, 68 | "id": "9kX6XsPYSXOt", 69 | "outputId": "f13b2c9b-0af2-4d5a-c0d9-2d58489805e0" 70 | }, 71 | "source": [ 72 | "x = 0\n", 73 | "a = 0\n", 74 | "b = -5\n", 75 | "if a > 0: # 0 dan büyük değil\n", 76 | " if b < 0: \n", 77 | " x = x + 5 \n", 78 | " elif a > 5:\n", 79 | " x = x + 4\n", 80 | " else:\n", 81 | " x = x + 3\n", 82 | "else: \n", 83 | " x = x + 2\n", 84 | "print(x)" 85 | ], 86 | "execution_count": null, 87 | "outputs": [ 88 | { 89 | "output_type": "stream", 90 | "text": [ 91 | "2\n" 92 | ], 93 | "name": "stdout" 94 | } 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "metadata": { 100 | "colab": { 101 | "base_uri": "https://localhost:8080/" 102 | }, 103 | "id": "cyny5j6CScrh", 104 | "outputId": "e3d6c3b4-4258-482b-b1ba-18db3326e5a0" 105 | }, 106 | "source": [ 107 | "for num in range(-2,-5,-1): #-2 -3 -4\n", 108 | " print(num, end=\", \")" 109 | ], 110 | "execution_count": null, 111 | "outputs": [ 112 | { 113 | "output_type": "stream", 114 | "text": [ 115 | "-2, -3, -4, " 116 | ], 117 | "name": "stdout" 118 | } 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "metadata": { 124 | "colab": { 125 | "base_uri": "https://localhost:8080/" 126 | }, 127 | "id": "UACWmsKBSh1X", 128 | "outputId": "3cedb120-18c6-4830-cc0e-b78643f99a1e" 129 | }, 130 | "source": [ 131 | "for num in range(10, 14): #10 11 12 13\n", 132 | " for i in range(2, num):# 2-13\n", 133 | " if num%i == 1: #13 %2 ==1\n", 134 | " print(num)\n", 135 | " break" 136 | ], 137 | "execution_count": null, 138 | "outputs": [ 139 | { 140 | "output_type": "stream", 141 | "text": [ 142 | "10\n", 143 | "11\n", 144 | "12\n", 145 | "13\n" 146 | ], 147 | "name": "stdout" 148 | } 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "metadata": { 154 | "colab": { 155 | "base_uri": "https://localhost:8080/" 156 | }, 157 | "id": "oT-9NdKtSoOH", 158 | "outputId": "5bcd1517-05c6-4a01-fdf9-7cbcf3076dc6" 159 | }, 160 | "source": [ 161 | "for l in 'John': #J , o, h, n\n", 162 | " if l == 'o':\n", 163 | " continue\n", 164 | " print(l)\n", 165 | "\n", 166 | "liste=['Merhaba','Dünya','Hoşgeldiniz..']\n", 167 | "for x in liste:\n", 168 | " if x=='Merhaba':\n", 169 | " continue\n", 170 | " print(x)" 171 | ], 172 | "execution_count": null, 173 | "outputs": [ 174 | { 175 | "output_type": "stream", 176 | "text": [ 177 | "J\n", 178 | "h\n", 179 | "n\n", 180 | "Dünya\n", 181 | "Hoşgeldiniz..\n" 182 | ], 183 | "name": "stdout" 184 | } 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "metadata": { 190 | "colab": { 191 | "base_uri": "https://localhost:8080/" 192 | }, 193 | "id": "bVFPAUOGS2Oc", 194 | "outputId": "179fd62a-e184-4d69-905e-a1eb3e349909" 195 | }, 196 | "source": [ 197 | "var = 10\n", 198 | "for i in range(10): #0-9\n", 199 | " for j in range(2, 10, 1): #2-9\n", 200 | " if var % 2 == 0:\n", 201 | " continue\n", 202 | " var += 1\n", 203 | " var+=1\n", 204 | "else:\n", 205 | " var+=1\n", 206 | "print(var)" 207 | ], 208 | "execution_count": null, 209 | "outputs": [ 210 | { 211 | "output_type": "stream", 212 | "text": [ 213 | "21\n" 214 | ], 215 | "name": "stdout" 216 | } 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "metadata": { 222 | "colab": { 223 | "base_uri": "https://localhost:8080/" 224 | }, 225 | "id": "A-DYQEd8TI69", 226 | "outputId": "0f0068ac-f231-4180-bd46-dd5adb50841e" 227 | }, 228 | "source": [ 229 | "x = 0\n", 230 | "a = 5\n", 231 | "b = 5\n", 232 | "if a > 0:\n", 233 | " if b < 0: \n", 234 | " x = x + 5 \n", 235 | " elif a > 5:\n", 236 | " x = x + 4\n", 237 | " else:\n", 238 | " x = x + 3\n", 239 | "else:\n", 240 | " x = x + 2\n", 241 | "print(x)" 242 | ], 243 | "execution_count": null, 244 | "outputs": [ 245 | { 246 | "output_type": "stream", 247 | "text": [ 248 | "3\n" 249 | ], 250 | "name": "stdout" 251 | } 252 | ] 253 | }, 254 | { 255 | "cell_type": "code", 256 | "metadata": { 257 | "colab": { 258 | "base_uri": "https://localhost:8080/" 259 | }, 260 | "id": "XgkRP0DgTKoC", 261 | "outputId": "9d9136be-743c-4cdb-8753-72bb4af9a1dd" 262 | }, 263 | "source": [ 264 | "x = 0\n", 265 | "while (x < 100):\n", 266 | " x+=2\n", 267 | "print(x)" 268 | ], 269 | "execution_count": null, 270 | "outputs": [ 271 | { 272 | "output_type": "stream", 273 | "text": [ 274 | "100\n" 275 | ], 276 | "name": "stdout" 277 | } 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "metadata": { 283 | "colab": { 284 | "base_uri": "https://localhost:8080/" 285 | }, 286 | "id": "kmInitA9TVPn", 287 | "outputId": "eb5e86f8-fe35-4585-e61d-5620c46316ba" 288 | }, 289 | "source": [ 290 | "aList = [\"Deneme\", [4, 8, 12, 16, [5,6,7]],2]\n", 291 | "print(aList[0][1]) \n", 292 | "print(aList[1][3])\n", 293 | "print(aList[1][4][0])" 294 | ], 295 | "execution_count": null, 296 | "outputs": [ 297 | { 298 | "output_type": "stream", 299 | "text": [ 300 | "e\n", 301 | "16\n", 302 | "5\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": "ZG5Jy5pxTnyl", 315 | "outputId": "eb91295f-307f-446e-8d19-87944c088a36" 316 | }, 317 | "source": [ 318 | "aList = [1, 2, 3, 4, 5, 6, 7]\n", 319 | "pow2 = [2 * x for x in aList]\n", 320 | "print(pow2)" 321 | ], 322 | "execution_count": null, 323 | "outputs": [ 324 | { 325 | "output_type": "stream", 326 | "text": [ 327 | "[2, 4, 6, 8, 10, 12, 14]\n" 328 | ], 329 | "name": "stdout" 330 | } 331 | ] 332 | } 333 | ] 334 | } -------------------------------------------------------------------------------- /Ders5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Ders5.ipynb", 7 | "provenance": [], 8 | "collapsed_sections": [], 9 | "authorship_tag": "ABX9TyNocsTlaoJarsW5lVEQzxU/" 10 | }, 11 | "kernelspec": { 12 | "name": "python3", 13 | "display_name": "Python 3" 14 | } 15 | }, 16 | "cells": [ 17 | { 18 | "cell_type": "code", 19 | "metadata": { 20 | "id": "fhJvReeQwyAa" 21 | }, 22 | "source": [ 23 | "#def fonksiyon_ismi(varsa parametre)\n", 24 | "def fonk(): \n", 25 | " print('Merhaba')\n" 26 | ], 27 | "execution_count": null, 28 | "outputs": [] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "metadata": { 33 | "id": "Vtct5gY2Vaxb", 34 | "outputId": "f57dc47b-92dd-49fc-e9ec-cfe03157babc", 35 | "colab": { 36 | "base_uri": "https://localhost:8080/" 37 | } 38 | }, 39 | "source": [ 40 | "fonk()" 41 | ], 42 | "execution_count": null, 43 | "outputs": [ 44 | { 45 | "output_type": "stream", 46 | "text": [ 47 | "Merhaba\n" 48 | ], 49 | "name": "stdout" 50 | } 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "metadata": { 56 | "id": "LFZ_0W4sw547" 57 | }, 58 | "source": [ 59 | "def fonk2(): \n", 60 | " pass\n", 61 | "fonk2()" 62 | ], 63 | "execution_count": null, 64 | "outputs": [] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "metadata": { 69 | "id": "8OoHlEsjw9R-", 70 | "outputId": "94a994cb-c725-4f04-b459-11fec897575d", 71 | "colab": { 72 | "base_uri": "https://localhost:8080/" 73 | } 74 | }, 75 | "source": [ 76 | "x = 'Merhaba Dünya' #Global olarak tanımlanmış\n", 77 | "def yazdir():\n", 78 | " print(x)\n", 79 | "yazdir()" 80 | ], 81 | "execution_count": null, 82 | "outputs": [ 83 | { 84 | "output_type": "stream", 85 | "text": [ 86 | "Merhaba Dünya\n" 87 | ], 88 | "name": "stdout" 89 | } 90 | ] 91 | }, 92 | { 93 | "cell_type": "code", 94 | "metadata": { 95 | "id": "XTZhuVahxCB7", 96 | "outputId": "7ead2ef0-18ee-498a-acd2-478076657f5f", 97 | "colab": { 98 | "base_uri": "https://localhost:8080/", 99 | "height": 198 100 | } 101 | }, 102 | "source": [ 103 | "def yazdir(): \n", 104 | " y = 'Merhaba Dünya' #lokal olarak tanımlanmış\n", 105 | " \n", 106 | "yazdir()\n", 107 | "print(y)" 108 | ], 109 | "execution_count": null, 110 | "outputs": [ 111 | { 112 | "output_type": "error", 113 | "ename": "NameError", 114 | "evalue": "ignored", 115 | "traceback": [ 116 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 117 | "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", 118 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0myazdir\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[0;32m----> 5\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 119 | "\u001b[0;31mNameError\u001b[0m: name 'y' is not defined" 120 | ] 121 | } 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "metadata": { 127 | "id": "eClLuPhNWv9F", 128 | "outputId": "4f5782c5-f0d2-4119-9a70-c70780f92ad5", 129 | "colab": { 130 | "base_uri": "https://localhost:8080/" 131 | } 132 | }, 133 | "source": [ 134 | "def topla(a=1,b=1):\n", 135 | " sonuc = a+b\n", 136 | " return sonuc\n", 137 | "\n", 138 | "x=input('Bir sayı giriniz...')#3\n", 139 | "y=input('Bir Sayı giriniz....')#5\n", 140 | "print(topla(int(x),int(y)))" 141 | ], 142 | "execution_count": null, 143 | "outputs": [ 144 | { 145 | "output_type": "stream", 146 | "text": [ 147 | "Bir sayı giriniz...3\n", 148 | "Bir Sayı giriniz....5\n", 149 | "8\n" 150 | ], 151 | "name": "stdout" 152 | } 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "metadata": { 158 | "id": "VjZvP4YioREX", 159 | "outputId": "567fe937-2d7a-4206-80d6-c8d4be62dbba", 160 | "colab": { 161 | "base_uri": "https://localhost:8080/" 162 | } 163 | }, 164 | "source": [ 165 | "for i in range(1,21):\n", 166 | " if i%2==0:\n", 167 | " print(i)" 168 | ], 169 | "execution_count": null, 170 | "outputs": [ 171 | { 172 | "output_type": "stream", 173 | "text": [ 174 | "2\n", 175 | "4\n", 176 | "6\n", 177 | "8\n", 178 | "10\n", 179 | "12\n", 180 | "14\n", 181 | "16\n", 182 | "18\n", 183 | "20\n" 184 | ], 185 | "name": "stdout" 186 | } 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "metadata": { 192 | "id": "QPOWP7OyoV7V", 193 | "outputId": "1313f528-5714-4a57-b0b9-576dbdb078dd", 194 | "colab": { 195 | "base_uri": "https://localhost:8080/" 196 | } 197 | }, 198 | "source": [ 199 | "for i in range(1,21):\n", 200 | " if i%2!=0: #if(i%2==1)\n", 201 | " print(i)" 202 | ], 203 | "execution_count": null, 204 | "outputs": [ 205 | { 206 | "output_type": "stream", 207 | "text": [ 208 | "1\n", 209 | "3\n", 210 | "5\n", 211 | "7\n", 212 | "9\n", 213 | "11\n", 214 | "13\n", 215 | "15\n", 216 | "17\n", 217 | "19\n" 218 | ], 219 | "name": "stdout" 220 | } 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "metadata": { 226 | "id": "fK0lWAP-ocgP", 227 | "outputId": "82dbcdd2-ed4c-4f98-b6a0-7c130485c5a3", 228 | "colab": { 229 | "base_uri": "https://localhost:8080/" 230 | } 231 | }, 232 | "source": [ 233 | "for i in range(1,101):\n", 234 | " if i%3==0 and i%5==0:\n", 235 | " print(i)" 236 | ], 237 | "execution_count": null, 238 | "outputs": [ 239 | { 240 | "output_type": "stream", 241 | "text": [ 242 | "15\n", 243 | "30\n", 244 | "45\n", 245 | "60\n", 246 | "75\n", 247 | "90\n" 248 | ], 249 | "name": "stdout" 250 | } 251 | ] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "metadata": { 256 | "id": "2XPih8B6okTB", 257 | "outputId": "446c51a3-0ca1-4e98-b2b5-1a5df3641390", 258 | "colab": { 259 | "base_uri": "https://localhost:8080/" 260 | } 261 | }, 262 | "source": [ 263 | "sayi=input('Sayıyı Gir : ')\n", 264 | "for i in range(1,int(sayi)+1):#1,10+1\n", 265 | " print(i)" 266 | ], 267 | "execution_count": null, 268 | "outputs": [ 269 | { 270 | "output_type": "stream", 271 | "text": [ 272 | "Sayıyı Gir : 10\n", 273 | "1\n", 274 | "2\n", 275 | "3\n", 276 | "4\n", 277 | "5\n", 278 | "6\n", 279 | "7\n", 280 | "8\n", 281 | "9\n", 282 | "10\n" 283 | ], 284 | "name": "stdout" 285 | } 286 | ] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "metadata": { 291 | "id": "Zrk7fp5qorOZ", 292 | "outputId": "18c94daf-c95f-4015-9aca-aed018d11bcd", 293 | "colab": { 294 | "base_uri": "https://localhost:8080/" 295 | } 296 | }, 297 | "source": [ 298 | "def dikdortgenAlan(genislik, yukseklik):\n", 299 | " alan = float(genislik) * float(yukseklik)\n", 300 | " print (\"Alan :\",alan)\n", 301 | " return alan\n", 302 | " \n", 303 | "genislik = input(\"Genişlik :\")\n", 304 | "yukseklik = input(\"Yükseklik : \")\n", 305 | " \n", 306 | "dikdortgenAlan(genislik, yukseklik)" 307 | ], 308 | "execution_count": null, 309 | "outputs": [ 310 | { 311 | "output_type": "stream", 312 | "text": [ 313 | "Genişlik :3.2\n", 314 | "Yükseklik : 4\n", 315 | "Alan : 12.8\n" 316 | ], 317 | "name": "stdout" 318 | }, 319 | { 320 | "output_type": "execute_result", 321 | "data": { 322 | "text/plain": [ 323 | "12.8" 324 | ] 325 | }, 326 | "metadata": { 327 | "tags": [] 328 | }, 329 | "execution_count": 33 330 | } 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "metadata": { 336 | "id": "M3PZKmWSpCdm", 337 | "outputId": "1f82f976-f79c-4803-cd07-5774ac4e8d2c", 338 | "colab": { 339 | "base_uri": "https://localhost:8080/" 340 | } 341 | }, 342 | "source": [ 343 | "def ciftMi(x): \n", 344 | " return x % 2 == 0 #ikiye bölümden kalan 0'mı? Evetse True, Değilse False\n", 345 | " \n", 346 | "toplam=0\n", 347 | "sayac=0\n", 348 | "baslangic = input(\"Başlangıç Sayısı :\")\n", 349 | "bitis = input(\"Bitiş Sayısı :\")\n", 350 | "for sayi in range (int(baslangic), int(bitis)+1):\n", 351 | " if(ciftMi(int(sayi))): #if(sayi%2==0)\n", 352 | " toplam=toplam+sayi\n", 353 | " sayac=sayac+1\n", 354 | "print('Ortalama',(toplam/sayac))" 355 | ], 356 | "execution_count": null, 357 | "outputs": [ 358 | { 359 | "output_type": "stream", 360 | "text": [ 361 | "Başlangıç Sayısı :5\n", 362 | "Bitiş Sayısı :10\n", 363 | "Ortalama 8.0\n" 364 | ], 365 | "name": "stdout" 366 | } 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "metadata": { 372 | "id": "Qa0tvtyGpprZ", 373 | "outputId": "fe60e466-38de-4283-b992-473338de1d21", 374 | "colab": { 375 | "base_uri": "https://localhost:8080/" 376 | } 377 | }, 378 | "source": [ 379 | "from random import randint\n", 380 | " \n", 381 | "rand=randint(1, 100)#45\n", 382 | "sayac=0\n", 383 | " \n", 384 | "while True:\n", 385 | " sayac+=1\n", 386 | " sayi=int(input(\"1 ile 100 arasında değer girin (0 Çıkış):\"))#45\n", 387 | " if(sayi==0):\n", 388 | " print(\"Oyunu İptal Ettiniz\")\n", 389 | " break\n", 390 | " elif sayi < rand:\n", 391 | " print(\"Daha Yüksek Bir Sayı Girin.\")\n", 392 | " continue\n", 393 | " elif sayi > rand:\n", 394 | " print(\"Daha Düşük Bir Sayı Girin.\")\n", 395 | " continue\n", 396 | " else:\n", 397 | " print(\"Rastele seçilen sayı {0}!\".format(rand))\n", 398 | " print(\"Tahmin sayınız {0}\".format(sayac))" 399 | ], 400 | "execution_count": null, 401 | "outputs": [ 402 | { 403 | "output_type": "stream", 404 | "text": [ 405 | "1 ile 100 arasında değer girin (0 Çıkış):50\n", 406 | "Daha Yüksek Bir Sayı Girin.\n", 407 | "1 ile 100 arasında değer girin (0 Çıkış):75\n", 408 | "Daha Düşük Bir Sayı Girin.\n", 409 | "1 ile 100 arasında değer girin (0 Çıkış):63\n", 410 | "Daha Düşük Bir Sayı Girin.\n", 411 | "1 ile 100 arasında değer girin (0 Çıkış):56\n", 412 | "Daha Düşük Bir Sayı Girin.\n", 413 | "1 ile 100 arasında değer girin (0 Çıkış):53\n", 414 | "Daha Düşük Bir Sayı Girin.\n", 415 | "1 ile 100 arasında değer girin (0 Çıkış):52\n", 416 | "Rastele seçilen sayı 52!\n", 417 | "Tahmin sayınız 6\n", 418 | "1 ile 100 arasında değer girin (0 Çıkış):0\n", 419 | "Oyunu İptal Ettiniz\n" 420 | ], 421 | "name": "stdout" 422 | } 423 | ] 424 | } 425 | ] 426 | } -------------------------------------------------------------------------------- /Lambda_Recursive.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Lambda-Recursive.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyOW02AxYgPcSD1ShkhOzcgy" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "metadata": { 19 | "id": "iBTdIWKJ_ksP" 20 | }, 21 | "source": [ 22 | "Lambda Fonksiyonu :\n", 23 | " \n", 24 | "etiket = lambda parametre1,parametre2.... : İşlem" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "metadata": { 30 | "colab": { 31 | "base_uri": "https://localhost:8080/" 32 | }, 33 | "id": "-Q4Cw3nj_kO6", 34 | "outputId": "e725cc56-74c1-46b5-ac63-2f3feb2962f1" 35 | }, 36 | "source": [ 37 | "liste1 = [1,2,3,4,5] \n", 38 | "liste2 = list()\n", 39 | "for i in liste1: \n", 40 | " liste2.append(i*2)\n", 41 | "print(liste2)" 42 | ], 43 | "execution_count": 1, 44 | "outputs": [ 45 | { 46 | "output_type": "stream", 47 | "text": [ 48 | "[2, 4, 6, 8, 10]\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": "vjxpN-4U_5-O", 61 | "outputId": "58468ba5-ae5b-4585-be72-54e47b2151be" 62 | }, 63 | "source": [ 64 | "liste3 = [1,2,3,4,5]\n", 65 | "liste4 = [i * 2 for i in liste3] \n", 66 | "print(liste4)" 67 | ], 68 | "execution_count": 3, 69 | "outputs": [ 70 | { 71 | "output_type": "stream", 72 | "text": [ 73 | "[2, 4, 6, 8, 10]\n" 74 | ], 75 | "name": "stdout" 76 | } 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "metadata": { 82 | "colab": { 83 | "base_uri": "https://localhost:8080/" 84 | }, 85 | "id": "sgYvn1G4__D4", 86 | "outputId": "5533109c-ef99-4178-bbc3-e14f5d5016a4" 87 | }, 88 | "source": [ 89 | "def ikiyleçarp(x): # Klasik fonksiyon tanımlama\n", 90 | " return x * 2\n", 91 | "print(ikiyleçarp(2))" 92 | ], 93 | "execution_count": 2, 94 | "outputs": [ 95 | { 96 | "output_type": "stream", 97 | "text": [ 98 | "4\n" 99 | ], 100 | "name": "stdout" 101 | } 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "metadata": { 107 | "colab": { 108 | "base_uri": "https://localhost:8080/" 109 | }, 110 | "id": "tAwlBuNaAEK9", 111 | "outputId": "5a13700e-0079-4106-b9dd-b5ace6bd2c45" 112 | }, 113 | "source": [ 114 | "ikiyleçarp = lambda x : x * 2 \n", 115 | " \n", 116 | "ikiyleçarp(5)" 117 | ], 118 | "execution_count": 5, 119 | "outputs": [ 120 | { 121 | "output_type": "execute_result", 122 | "data": { 123 | "text/plain": [ 124 | "10" 125 | ] 126 | }, 127 | "metadata": { 128 | "tags": [] 129 | }, 130 | "execution_count": 5 131 | } 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "metadata": { 137 | "colab": { 138 | "base_uri": "https://localhost:8080/" 139 | }, 140 | "id": "Wb0rytT1ALzt", 141 | "outputId": "41f48da7-c7f9-42f9-abd0-36d7d3add433" 142 | }, 143 | "source": [ 144 | "def toplama(a,b,c):\n", 145 | " return a + b + c\n", 146 | " \n", 147 | "print(toplama(3,4,5))" 148 | ], 149 | "execution_count": 6, 150 | "outputs": [ 151 | { 152 | "output_type": "stream", 153 | "text": [ 154 | "12\n" 155 | ], 156 | "name": "stdout" 157 | } 158 | ] 159 | }, 160 | { 161 | "cell_type": "code", 162 | "metadata": { 163 | "colab": { 164 | "base_uri": "https://localhost:8080/" 165 | }, 166 | "id": "KuehWc6pAPqw", 167 | "outputId": "ddf11319-e1b9-48a4-add9-08c5b36aba88" 168 | }, 169 | "source": [ 170 | "topla = lambda x,y,z : x + y + z\n", 171 | " \n", 172 | "print(topla(3,4,5))" 173 | ], 174 | "execution_count": 7, 175 | "outputs": [ 176 | { 177 | "output_type": "stream", 178 | "text": [ 179 | "12\n" 180 | ], 181 | "name": "stdout" 182 | } 183 | ] 184 | }, 185 | { 186 | "cell_type": "code", 187 | "metadata": { 188 | "colab": { 189 | "base_uri": "https://localhost:8080/" 190 | }, 191 | "id": "QJkE1LGSASlh", 192 | "outputId": "3a47e86b-5df4-4038-93e7-c875342daefd" 193 | }, 194 | "source": [ 195 | "def terscevir(s):\n", 196 | " return s[::-1]\n", 197 | "\n", 198 | "metin=input()\n", 199 | "print(terscevir(metin))" 200 | ], 201 | "execution_count": 13, 202 | "outputs": [ 203 | { 204 | "output_type": "stream", 205 | "text": [ 206 | "Bilgisayar\n", 207 | "rayasigliB\n" 208 | ], 209 | "name": "stdout" 210 | } 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "metadata": { 216 | "colab": { 217 | "base_uri": "https://localhost:8080/" 218 | }, 219 | "id": "eW6re4OCAZs-", 220 | "outputId": "5c9aec1e-60f7-4e39-cdab-2afb5ae0ea18" 221 | }, 222 | "source": [ 223 | "ters = lambda s : s[::-1]\n", 224 | "\n", 225 | "metin=input()\n", 226 | "print(ters(metin))" 227 | ], 228 | "execution_count": 15, 229 | "outputs": [ 230 | { 231 | "output_type": "stream", 232 | "text": [ 233 | "Bilgisayar\n", 234 | "rayasigliB\n" 235 | ], 236 | "name": "stdout" 237 | } 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "metadata": { 243 | "colab": { 244 | "base_uri": "https://localhost:8080/" 245 | }, 246 | "id": "lv8zB6ulAe4Y", 247 | "outputId": "40564925-da53-4d4e-ceee-451f857dd053" 248 | }, 249 | "source": [ 250 | "çifttek = lambda sayı : sayı % 2 == 0 \n", 251 | " \n", 252 | "#çifttek(34)\n", 253 | " \n", 254 | "çifttek(13)\n", 255 | "\n" 256 | ], 257 | "execution_count": 17, 258 | "outputs": [ 259 | { 260 | "output_type": "execute_result", 261 | "data": { 262 | "text/plain": [ 263 | "False" 264 | ] 265 | }, 266 | "metadata": { 267 | "tags": [] 268 | }, 269 | "execution_count": 17 270 | } 271 | ] 272 | }, 273 | { 274 | "cell_type": "code", 275 | "metadata": { 276 | "colab": { 277 | "base_uri": "https://localhost:8080/" 278 | }, 279 | "id": "YdQplHGDAmix", 280 | "outputId": "69e6e68b-72bc-4eff-b433-9422cc859399" 281 | }, 282 | "source": [ 283 | "x = lambda a : a + 10\n", 284 | "print(x(5))" 285 | ], 286 | "execution_count": 18, 287 | "outputs": [ 288 | { 289 | "output_type": "stream", 290 | "text": [ 291 | "15\n" 292 | ], 293 | "name": "stdout" 294 | } 295 | ] 296 | }, 297 | { 298 | "cell_type": "code", 299 | "metadata": { 300 | "colab": { 301 | "base_uri": "https://localhost:8080/" 302 | }, 303 | "id": "UuwRia-mAn61", 304 | "outputId": "b0b6bc7c-fc9a-48a7-bca3-b46b8474c29a" 305 | }, 306 | "source": [ 307 | "x = lambda a, b : a * b\n", 308 | "print(x(5, 6))" 309 | ], 310 | "execution_count": 19, 311 | "outputs": [ 312 | { 313 | "output_type": "stream", 314 | "text": [ 315 | "30\n" 316 | ], 317 | "name": "stdout" 318 | } 319 | ] 320 | }, 321 | { 322 | "cell_type": "code", 323 | "metadata": { 324 | "colab": { 325 | "base_uri": "https://localhost:8080/" 326 | }, 327 | "id": "ZupHe7FWAqy4", 328 | "outputId": "1f5948be-45ea-40c4-a609-8114486f3bad" 329 | }, 330 | "source": [ 331 | "x = lambda a, b, c : a + b + c\n", 332 | "print(x(5, 6, 2))" 333 | ], 334 | "execution_count": 12, 335 | "outputs": [ 336 | { 337 | "output_type": "stream", 338 | "text": [ 339 | "13\n" 340 | ], 341 | "name": "stdout" 342 | } 343 | ] 344 | }, 345 | { 346 | "cell_type": "code", 347 | "metadata": { 348 | "colab": { 349 | "base_uri": "https://localhost:8080/" 350 | }, 351 | "id": "v6Y4F9QyAvwv", 352 | "outputId": "c6a02e80-f0f0-413d-e31a-8beda2972348" 353 | }, 354 | "source": [ 355 | "def myfunc(n):\n", 356 | " return lambda a : a * n\n", 357 | "#lambda a :a*2\n", 358 | "mydoubler = myfunc(2)\n", 359 | "#mydoubler=lambda a :a*2\n", 360 | "print(mydoubler(15))" 361 | ], 362 | "execution_count": 24, 363 | "outputs": [ 364 | { 365 | "output_type": "stream", 366 | "text": [ 367 | "30\n" 368 | ], 369 | "name": "stdout" 370 | } 371 | ] 372 | }, 373 | { 374 | "cell_type": "code", 375 | "metadata": { 376 | "colab": { 377 | "base_uri": "https://localhost:8080/" 378 | }, 379 | "id": "JiNHtExnAz0t", 380 | "outputId": "713c6305-027e-48ae-88f9-ba92756610b2" 381 | }, 382 | "source": [ 383 | "def myfunc(n):\n", 384 | " return lambda a : a * n\n", 385 | "#lambda a:a*3\n", 386 | "mytripler = myfunc(3)\n", 387 | "#mytripler=lambda a:a*3\n", 388 | "print(mytripler(11))" 389 | ], 390 | "execution_count": 25, 391 | "outputs": [ 392 | { 393 | "output_type": "stream", 394 | "text": [ 395 | "33\n" 396 | ], 397 | "name": "stdout" 398 | } 399 | ] 400 | }, 401 | { 402 | "cell_type": "code", 403 | "metadata": { 404 | "colab": { 405 | "base_uri": "https://localhost:8080/" 406 | }, 407 | "id": "Iktyef1aBMi0", 408 | "outputId": "9f4578f5-1eb1-499b-e02b-f22f17a17c33" 409 | }, 410 | "source": [ 411 | "def myfunc(n):\n", 412 | " return lambda a : a * n\n", 413 | "\n", 414 | "mydoubler = myfunc(2)\n", 415 | "#mydoubler=lambda a:a*2\n", 416 | "mytripler = myfunc(3)\n", 417 | "#mytripler=lambda a:a*3\n", 418 | "print(mydoubler(10))\n", 419 | "print(mytripler(15))" 420 | ], 421 | "execution_count": 27, 422 | "outputs": [ 423 | { 424 | "output_type": "stream", 425 | "text": [ 426 | "20\n", 427 | "45\n" 428 | ], 429 | "name": "stdout" 430 | } 431 | ] 432 | }, 433 | { 434 | "cell_type": "markdown", 435 | "metadata": { 436 | "id": "5Bmf39QEBd_O" 437 | }, 438 | "source": [ 439 | "Recursive Fonksiyonlar(Öz Yinelemeli Fonksiyonlar)\n", 440 | "\n", 441 | "Kendi kendini çağıran fonksiyonlar..." 442 | ] 443 | }, 444 | { 445 | "cell_type": "code", 446 | "metadata": { 447 | "colab": { 448 | "base_uri": "https://localhost:8080/" 449 | }, 450 | "id": "8sIeWKNPBOy7", 451 | "outputId": "7dcef660-36ca-4048-f9ed-3bfd49bf15a8" 452 | }, 453 | "source": [ 454 | "def azalt(s):\n", 455 | " if len(s) < 1:\n", 456 | " return s\n", 457 | " else:\n", 458 | " print(s)\n", 459 | " return azalt(s[1:])\n", 460 | "#print(len('Bilgisayar'))\n", 461 | "print(azalt('Bilgisayar'))\n", 462 | "#s=Bilgisayar\n", 463 | "#azalt(ilgisayar)\n", 464 | "#azalt(lgisayar)\n", 465 | "#azalt(gisayar)\n", 466 | "#...... azalt(r) azalt('')\n" 467 | ], 468 | "execution_count": 35, 469 | "outputs": [ 470 | { 471 | "output_type": "stream", 472 | "text": [ 473 | "Bilgisayar\n", 474 | "ilgisayar\n", 475 | "lgisayar\n", 476 | "gisayar\n", 477 | "isayar\n", 478 | "sayar\n", 479 | "ayar\n", 480 | "yar\n", 481 | "ar\n", 482 | "r\n", 483 | "\n" 484 | ], 485 | "name": "stdout" 486 | } 487 | ] 488 | }, 489 | { 490 | "cell_type": "code", 491 | "metadata": { 492 | "colab": { 493 | "base_uri": "https://localhost:8080/" 494 | }, 495 | "id": "Xp3nmEj-CGCx", 496 | "outputId": "50496588-581e-4c8e-fc27-c0efe258c9bf" 497 | }, 498 | "source": [ 499 | "def Usal(sayi,us):#sayı=4 us=1\n", 500 | " if us==1:\n", 501 | " return sayi\n", 502 | " elif us==0:\n", 503 | " return 1\n", 504 | " else:\n", 505 | " return sayi*Usal(sayi,us-1)\n", 506 | "print(Usal(4,3))\n", 507 | "#4*usal(4,2)=4*16=64\n", 508 | " #4*usal(4,1)=4*4=16\n", 509 | " #usal(4,1)=4" 510 | ], 511 | "execution_count": 39, 512 | "outputs": [ 513 | { 514 | "output_type": "stream", 515 | "text": [ 516 | "64\n" 517 | ], 518 | "name": "stdout" 519 | } 520 | ] 521 | }, 522 | { 523 | "cell_type": "code", 524 | "metadata": { 525 | "colab": { 526 | "base_uri": "https://localhost:8080/" 527 | }, 528 | "id": "WRV2hrJbCTAZ", 529 | "outputId": "36459609-74f3-47ab-b925-68188bc98418" 530 | }, 531 | "source": [ 532 | "def Faktoriyel(sayi): #sayı=1\n", 533 | " if sayi==1:\n", 534 | " return 1\n", 535 | " else:\n", 536 | " return sayi*Faktoriyel(sayi-1)\n", 537 | "print(Faktoriyel(5))\n", 538 | "#5*faktoriyel(4) =5*24=120\n", 539 | " #4*faktoriyel(3)=4*6=24 \n", 540 | " #3*faktoriyel(2)=3*2=6\n", 541 | " #2*faktoriyel(1)=2*1" 542 | ], 543 | "execution_count": 40, 544 | "outputs": [ 545 | { 546 | "output_type": "stream", 547 | "text": [ 548 | "120\n" 549 | ], 550 | "name": "stdout" 551 | } 552 | ] 553 | }, 554 | { 555 | "cell_type": "markdown", 556 | "metadata": { 557 | "id": "c9A5PP1wA_3b" 558 | }, 559 | "source": [ 560 | "Kaynakça:\n", 561 | "\n", 562 | "https://www.yazilimbilimi.org/python-lambda-function-lambda-fonksiyonlar/ \n", 563 | "\n", 564 | "https://www.w3schools.com/python/python_lambda.asp\n", 565 | "\n", 566 | "https://python-istihza.yazbel.com/ileri_fonksiyonlar.html\n", 567 | "\n", 568 | "https://yazilimhanem.com/python-recursive/" 569 | ] 570 | } 571 | ] 572 | } -------------------------------------------------------------------------------- /Ders7.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Ders7.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyNRx9p05e1Ai2SIrplN6Prc" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "code", 18 | "metadata": { 19 | "colab": { 20 | "base_uri": "https://localhost:8080/" 21 | }, 22 | "id": "yWsiRTn2DA_W", 23 | "outputId": "36c864d8-9f94-49ec-9375-d32777b27068" 24 | }, 25 | "source": [ 26 | "lst = ['a', 'b', 'c', 'd', 'e'] \n", 27 | "#lst[2:4]\n", 28 | "# Output: ['c', 'd']\n", 29 | "#lst[2:]\n", 30 | "# Output: ['c', 'd', 'e']\n", 31 | "lst[:4]\n", 32 | "# Output: ['a', 'b', 'c', 'd']" 33 | ], 34 | "execution_count": null, 35 | "outputs": [ 36 | { 37 | "output_type": "execute_result", 38 | "data": { 39 | "text/plain": [ 40 | "['a', 'b', 'c', 'd']" 41 | ] 42 | }, 43 | "metadata": { 44 | "tags": [] 45 | }, 46 | "execution_count": 10 47 | } 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "metadata": { 53 | "colab": { 54 | "base_uri": "https://localhost:8080/" 55 | }, 56 | "id": "yzzo3mm8CJky", 57 | "outputId": "fad39acb-8ebf-40ce-fdea-1baf54b46b29" 58 | }, 59 | "source": [ 60 | "lst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] \n", 61 | "lst[1::2]\n", 62 | "#lst[::3]" 63 | ], 64 | "execution_count": null, 65 | "outputs": [ 66 | { 67 | "output_type": "execute_result", 68 | "data": { 69 | "text/plain": [ 70 | "['b', 'd', 'f', 'h']" 71 | ] 72 | }, 73 | "metadata": { 74 | "tags": [] 75 | }, 76 | "execution_count": 15 77 | } 78 | ] 79 | }, 80 | { 81 | "cell_type": "code", 82 | "metadata": { 83 | "colab": { 84 | "base_uri": "https://localhost:8080/" 85 | }, 86 | "id": "xgV2m_GK-LmT", 87 | "outputId": "70e4b9ce-a10a-404c-abb4-729a7df02878" 88 | }, 89 | "source": [ 90 | "aList = [4, 8, 12, 16] # 4=0.indis, 8=1.indis, 12=2, 16=3\n", 91 | "aList[1:4] = [20, 24, 28]# 1=20, 2=24,3=28\n", 92 | "print(aList)" 93 | ], 94 | "execution_count": null, 95 | "outputs": [ 96 | { 97 | "output_type": "stream", 98 | "text": [ 99 | "[4, 20, 24, 28]\n" 100 | ], 101 | "name": "stdout" 102 | } 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "metadata": { 108 | "colab": { 109 | "base_uri": "https://localhost:8080/" 110 | }, 111 | "id": "4fWgYC5Z-Sum", 112 | "outputId": "2dadd3a5-d5ad-4510-b2d5-285922305684" 113 | }, 114 | "source": [ 115 | "aList = [10, 20, 30, 40, 50, 60, 70, 80]\n", 116 | "print(aList[2:5])\n", 117 | "print(aList[:4])\n", 118 | "print(aList[3:])" 119 | ], 120 | "execution_count": null, 121 | "outputs": [ 122 | { 123 | "output_type": "stream", 124 | "text": [ 125 | "[30, 40, 50]\n", 126 | "[10, 20, 30, 40]\n", 127 | "[40, 50, 60, 70, 80]\n" 128 | ], 129 | "name": "stdout" 130 | } 131 | ] 132 | }, 133 | { 134 | "cell_type": "code", 135 | "metadata": { 136 | "colab": { 137 | "base_uri": "https://localhost:8080/" 138 | }, 139 | "id": "58wnSAPg-UoI", 140 | "outputId": "0765309c-6207-4138-8864-4ea2ec6b4f92" 141 | }, 142 | "source": [ 143 | "str1 = \"Merhaba\"# M=0.indis , a=-1.indis oluyor..\n", 144 | "print(str1[1:4], str1[:5], str1[4:], str1[0:-2], str1[:-1])" 145 | ], 146 | "execution_count": null, 147 | "outputs": [ 148 | { 149 | "output_type": "stream", 150 | "text": [ 151 | "erh Merha aba Merha Merhab Merhaba\n" 152 | ], 153 | "name": "stdout" 154 | } 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "metadata": { 160 | "colab": { 161 | "base_uri": "https://localhost:8080/" 162 | }, 163 | "id": "K6hR6SCXKYCk", 164 | "outputId": "6a05e974-0d24-4b39-e023-21f3ee70f00a" 165 | }, 166 | "source": [ 167 | "hafta_ici=[\"pazartesi\",\"salı\",\"çarşamba\",\"perşembe\",\"cuma\"]\n", 168 | "\n", 169 | "print(\"cuma\" in hafta_ici)\n", 170 | "print(\"cumartesi\" in hafta_ici)" 171 | ], 172 | "execution_count": null, 173 | "outputs": [ 174 | { 175 | "output_type": "stream", 176 | "text": [ 177 | "True\n", 178 | "False\n" 179 | ], 180 | "name": "stdout" 181 | } 182 | ] 183 | }, 184 | { 185 | "cell_type": "code", 186 | "metadata": { 187 | "colab": { 188 | "base_uri": "https://localhost:8080/" 189 | }, 190 | "id": "cWnwpC35VS0h", 191 | "outputId": "6945bc15-c58f-4230-e0e6-bffdb3778e59" 192 | }, 193 | "source": [ 194 | "hafta_ici=[\"pazartesi\",\"salı\",\"çarşamba\",\"perşembe\",\"cuma\"]\n", 195 | "if \"cumartesi\" in hafta_ici:\n", 196 | " print('Listede var...')\n", 197 | "else:\n", 198 | " print('Listede yok..')\n", 199 | "\n", 200 | "kontrol=0\n", 201 | "for gun in hafta_ici:\n", 202 | " if gun==\"cumartesi\":\n", 203 | " kontrol=1\n", 204 | "if kontrol==1:\n", 205 | " print('Aranan gün var..')\n", 206 | "else:\n", 207 | " print('Aranan gün yok..')" 208 | ], 209 | "execution_count": null, 210 | "outputs": [ 211 | { 212 | "output_type": "stream", 213 | "text": [ 214 | "Listede yok..\n", 215 | "Aranan gün yok..\n" 216 | ], 217 | "name": "stdout" 218 | } 219 | ] 220 | }, 221 | { 222 | "cell_type": "code", 223 | "metadata": { 224 | "colab": { 225 | "base_uri": "https://localhost:8080/" 226 | }, 227 | "id": "DgwAReTn-YUz", 228 | "outputId": "cbe423b1-ed0b-499a-e724-3a987aa256e7" 229 | }, 230 | "source": [ 231 | "sampleList = [10, 20, 30, 40, 50]\n", 232 | "sampleList.append(60)\n", 233 | "print(sampleList)\n", 234 | "\n", 235 | "sampleList.append(60)\n", 236 | "print(sampleList)" 237 | ], 238 | "execution_count": null, 239 | "outputs": [ 240 | { 241 | "output_type": "stream", 242 | "text": [ 243 | "[10, 20, 30, 40, 50, 60]\n", 244 | "[10, 20, 30, 40, 50, 60, 60]\n" 245 | ], 246 | "name": "stdout" 247 | } 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "metadata": { 253 | "colab": { 254 | "base_uri": "https://localhost:8080/" 255 | }, 256 | "id": "tr90qUQC_HMt", 257 | "outputId": "392810cf-cdfc-4617-e53c-159f635cc0ce" 258 | }, 259 | "source": [ 260 | "for index, item in enumerate(['one', 'two', 'three', 'four']):\n", 261 | " print(index, '::', item)" 262 | ], 263 | "execution_count": null, 264 | "outputs": [ 265 | { 266 | "output_type": "stream", 267 | "text": [ 268 | "0 :: one\n", 269 | "1 :: two\n", 270 | "2 :: three\n", 271 | "3 :: four\n" 272 | ], 273 | "name": "stdout" 274 | } 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "metadata": { 280 | "colab": { 281 | "base_uri": "https://localhost:8080/" 282 | }, 283 | "id": "_VLGkMjfALL9", 284 | "outputId": "e117f9c4-43d9-4462-d84e-3676f1271128" 285 | }, 286 | "source": [ 287 | "[s.upper() for s in \"Hello World\"]\n" 288 | ], 289 | "execution_count": null, 290 | "outputs": [ 291 | { 292 | "output_type": "execute_result", 293 | "data": { 294 | "text/plain": [ 295 | "['H', 'E', 'L', 'L', 'O', ' ', 'W', 'O', 'R', 'L', 'D']" 296 | ] 297 | }, 298 | "metadata": { 299 | "tags": [] 300 | }, 301 | "execution_count": 10 302 | } 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "metadata": { 308 | "colab": { 309 | "base_uri": "https://localhost:8080/" 310 | }, 311 | "id": "0wWm7sZnBu6I", 312 | "outputId": "62a37f17-a4ad-4d68-ffe2-9f9ff9eb8897" 313 | }, 314 | "source": [ 315 | " [x for x in range(10) if x % 2 == 1]" 316 | ], 317 | "execution_count": null, 318 | "outputs": [ 319 | { 320 | "output_type": "execute_result", 321 | "data": { 322 | "text/plain": [ 323 | "[1, 3, 5, 7, 9]" 324 | ] 325 | }, 326 | "metadata": { 327 | "tags": [] 328 | }, 329 | "execution_count": 40 330 | } 331 | ] 332 | }, 333 | { 334 | "cell_type": "code", 335 | "metadata": { 336 | "colab": { 337 | "base_uri": "https://localhost:8080/" 338 | }, 339 | "id": "p6LslC7WBx7A", 340 | "outputId": "b5426eb6-50d8-42cb-8624-fa4c72143aac" 341 | }, 342 | "source": [ 343 | "even_numbers = []\n", 344 | "for x in range(10): \n", 345 | " if x % 2 == 0:\n", 346 | " even_numbers.append(x)\n", 347 | "print(even_numbers)" 348 | ], 349 | "execution_count": null, 350 | "outputs": [ 351 | { 352 | "output_type": "stream", 353 | "text": [ 354 | "[0, 2, 4, 6, 8]\n" 355 | ], 356 | "name": "stdout" 357 | } 358 | ] 359 | }, 360 | { 361 | "cell_type": "code", 362 | "metadata": { 363 | "colab": { 364 | "base_uri": "https://localhost:8080/" 365 | }, 366 | "id": "7oZBfRrpXzes", 367 | "outputId": "26ae87f7-e171-4781-d203-8e4ff2d7e401" 368 | }, 369 | "source": [ 370 | "even_numbers = []\n", 371 | "[even_numbers.append(x) for x in range(10) if x % 2 == 0]\n", 372 | "print(even_numbers)" 373 | ], 374 | "execution_count": null, 375 | "outputs": [ 376 | { 377 | "output_type": "stream", 378 | "text": [ 379 | "[0, 2, 4, 6, 8]\n" 380 | ], 381 | "name": "stdout" 382 | } 383 | ] 384 | }, 385 | { 386 | "cell_type": "code", 387 | "metadata": { 388 | "colab": { 389 | "base_uri": "https://localhost:8080/" 390 | }, 391 | "id": "oP0zLynsB-ON", 392 | "outputId": "285dcf85-1a35-40cc-9c90-e7cecb796e89" 393 | }, 394 | "source": [ 395 | " [x if x % 2 == 0 else None for x in range(10)]" 396 | ], 397 | "execution_count": null, 398 | "outputs": [ 399 | { 400 | "output_type": "execute_result", 401 | "data": { 402 | "text/plain": [ 403 | "[0, None, 2, None, 4, None, 6, None, 8, None]" 404 | ] 405 | }, 406 | "metadata": { 407 | "tags": [] 408 | }, 409 | "execution_count": 47 410 | } 411 | ] 412 | }, 413 | { 414 | "cell_type": "code", 415 | "metadata": { 416 | "colab": { 417 | "base_uri": "https://localhost:8080/" 418 | }, 419 | "id": "A28xdTNxDPuI", 420 | "outputId": "cf17f23a-cf04-4ed6-ac42-814e5248ca4a" 421 | }, 422 | "source": [ 423 | "names = ['Fred', 'Wilma', 'Barney','Moloztaş','Çakmaktaş']\n", 424 | "def long_name(name): \n", 425 | " return len(name) > 5\n", 426 | "list(filter(long_name, names))" 427 | ], 428 | "execution_count": null, 429 | "outputs": [ 430 | { 431 | "output_type": "execute_result", 432 | "data": { 433 | "text/plain": [ 434 | "['Barney', 'Moloztaş', 'Çakmaktaş']" 435 | ] 436 | }, 437 | "metadata": { 438 | "tags": [] 439 | }, 440 | "execution_count": 52 441 | } 442 | ] 443 | }, 444 | { 445 | "cell_type": "code", 446 | "metadata": { 447 | "colab": { 448 | "base_uri": "https://localhost:8080/" 449 | }, 450 | "id": "Wxo29DSWJsv5", 451 | "outputId": "f5b8f115-3c44-4c0f-e0b6-839f7f4b9a65" 452 | }, 453 | "source": [ 454 | "sayilar = [18,22,15,85,65,30,10,20,32,34,28,101,5,4,32]\n", 455 | "sayac=0 \n", 456 | "for sayi in sayilar:\n", 457 | " if sayi%5 == 0:\n", 458 | " print (str(sayi)+ (\" : 5'in katıdır.\"))\n", 459 | " sayac=sayac+1 \n", 460 | "else:\n", 461 | " print ('Döngü Bitti')\n", 462 | "print(\"5'in katı olan sayı adeti : \"+str(sayac))\n", 463 | "\"\"\"\n", 464 | "1-bolum fonk. 5'e bölünüp bölünmediğini inceleyecek.\n", 465 | "2-filter kullanılarak 5'e bölünenlerin listesini verecek..." 466 | ], 467 | "execution_count": null, 468 | "outputs": [ 469 | { 470 | "output_type": "stream", 471 | "text": [ 472 | "15 : 5'in katıdır.\n", 473 | "85 : 5'in katıdır.\n", 474 | "65 : 5'in katıdır.\n", 475 | "30 : 5'in katıdır.\n", 476 | "10 : 5'in katıdır.\n", 477 | "20 : 5'in katıdır.\n", 478 | "5 : 5'in katıdır.\n", 479 | "Döngü Bitti\n", 480 | "5'in katı olan sayı adeti : 7\n" 481 | ], 482 | "name": "stdout" 483 | } 484 | ] 485 | }, 486 | { 487 | "cell_type": "code", 488 | "metadata": { 489 | "colab": { 490 | "base_uri": "https://localhost:8080/" 491 | }, 492 | "id": "ceTPXdCOJ18a", 493 | "outputId": "c373ab4a-de1f-41e1-b9d2-8f5720934bf0" 494 | }, 495 | "source": [ 496 | "def kontrol(str,karakter):\n", 497 | " #sayac = 0\n", 498 | " for ch in str:\n", 499 | " if ch == karakter:\n", 500 | " #sayac = sayac + 1\n", 501 | " return True\n", 502 | " break\n", 503 | " \n", 504 | " \n", 505 | "metin=input('Metin : ')\n", 506 | "krktr=input('Aranacak Karakteri : ')\n", 507 | "if(kontrol(metin,krktr)==True):\n", 508 | " print('Aranan karakter metin içinde var')\n", 509 | "else:\n", 510 | " print('Aranan karakter metin içinde yok')" 511 | ], 512 | "execution_count": null, 513 | "outputs": [ 514 | { 515 | "output_type": "stream", 516 | "text": [ 517 | "Metin : Bilgisayar\n", 518 | "Aranacak Karakteri : a\n", 519 | "Aranan karakter metin içinde var\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": "OE5G3hVuKI3q", 532 | "outputId": "22f8bb01-1ce8-482b-c0bc-2dc4fe80840f" 533 | }, 534 | "source": [ 535 | "tekAdet=0\n", 536 | "ciftAdet=0\n", 537 | "tekToplam=0\n", 538 | "ciftToplam=0\n", 539 | " \n", 540 | "n=int(input(\"Kaç Adet Sayı Girilecek : \"))\n", 541 | "for i in range(n):\n", 542 | " sayi=int(input(\"Sayı : \"))\n", 543 | " if(sayi%2==1):\n", 544 | " tekAdet+=1\n", 545 | " tekToplam+=sayi\n", 546 | " else:\n", 547 | " ciftAdet+=1\n", 548 | " ciftToplam+=sayi\n", 549 | "if(tekAdet!=0):#Eğer hiç tek sayı girilmemişse 0'a bölme hatası verecektir.\n", 550 | " print(\"Tek Sayıların Ortalaması : \",tekToplam/tekAdet)\n", 551 | "if(ciftAdet!=0):#Eğer hiç çift sayı girilmemişse 0'a bölme hatası verecektir.\n", 552 | " print(\"Çift Sayıların Ortalaması : \",ciftToplam/ciftAdet)" 553 | ], 554 | "execution_count": null, 555 | "outputs": [ 556 | { 557 | "output_type": "stream", 558 | "text": [ 559 | "Kaç Adet Sayı Girilecek : 3\n", 560 | "Sayı : 10\n", 561 | "Sayı : 15\n", 562 | "Sayı : 25\n", 563 | "Tek Sayıların Ortalaması : 20.0\n", 564 | "Çift Sayıların Ortalaması : 10.0\n" 565 | ], 566 | "name": "stdout" 567 | } 568 | ] 569 | } 570 | ] 571 | } -------------------------------------------------------------------------------- /Ders4.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Ders4.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyP1k69VDp1VzWxqJuQg1qGF" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "code", 18 | "metadata": { 19 | "id": "dvDwpBwZCcU_", 20 | "outputId": "ac4d501d-cdb8-4ad8-cc67-d5f9c8b20ed0", 21 | "colab": { 22 | "base_uri": "https://localhost:8080/", 23 | "height": 68 24 | } 25 | }, 26 | "source": [ 27 | "a=input('İlk değeri giriniz...')#5\n", 28 | "b=input('İkinci değeri giriniz...')#3\n", 29 | "print(a+b) " 30 | ], 31 | "execution_count": null, 32 | "outputs": [ 33 | { 34 | "output_type": "stream", 35 | "text": [ 36 | "İlk değeri giriniz...5\n", 37 | "İkinci değeri giriniz...3\n", 38 | "53\n" 39 | ], 40 | "name": "stdout" 41 | } 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "metadata": { 47 | "id": "7rQedKnxDrZ7", 48 | "outputId": "b054db1f-423f-462a-a919-f52b390d4d26", 49 | "colab": { 50 | "base_uri": "https://localhost:8080/", 51 | "height": 34 52 | } 53 | }, 54 | "source": [ 55 | "liste=['p','y','t','h','o','n']\n", 56 | "print(liste[1]) #a)p b)y c)Y" 57 | ], 58 | "execution_count": null, 59 | "outputs": [ 60 | { 61 | "output_type": "stream", 62 | "text": [ 63 | "y\n" 64 | ], 65 | "name": "stdout" 66 | } 67 | ] 68 | }, 69 | { 70 | "cell_type": "markdown", 71 | "metadata": { 72 | "id": "7xPbx9YcEa5S" 73 | }, 74 | "source": [ 75 | "Döngüler bir bloğun istenilen sayıda çalışmasını sağlar." 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "metadata": { 81 | "id": "hXiBLqHQXCaH", 82 | "outputId": "f1e0027e-362b-4bdd-cc06-d7ebd8e12d07", 83 | "colab": { 84 | "base_uri": "https://localhost:8080/", 85 | "height": 102 86 | } 87 | }, 88 | "source": [ 89 | "i = 1\n", 90 | "while i < 6:\n", 91 | " print(i)\n", 92 | " i += 1 #i=i+1" 93 | ], 94 | "execution_count": null, 95 | "outputs": [ 96 | { 97 | "output_type": "stream", 98 | "text": [ 99 | "1\n", 100 | "2\n", 101 | "3\n", 102 | "4\n", 103 | "5\n" 104 | ], 105 | "name": "stdout" 106 | } 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "metadata": { 112 | "id": "YS4KPwxwXHwb", 113 | "outputId": "e315a6bf-25ee-4e16-832e-a5b4b878b93f", 114 | "colab": { 115 | "base_uri": "https://localhost:8080/", 116 | "height": 68 117 | } 118 | }, 119 | "source": [ 120 | "i = 1\n", 121 | "while i < 6:\n", 122 | " print(i)\n", 123 | " if i == 3:\n", 124 | " break #Döngüyü sonlandır....\n", 125 | " i += 1" 126 | ], 127 | "execution_count": null, 128 | "outputs": [ 129 | { 130 | "output_type": "stream", 131 | "text": [ 132 | "1\n", 133 | "2\n", 134 | "3\n" 135 | ], 136 | "name": "stdout" 137 | } 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "metadata": { 143 | "id": "zYWMvNNpXOON", 144 | "outputId": "6d21c96e-55bb-4266-9b6b-38e8f8ad7650", 145 | "colab": { 146 | "base_uri": "https://localhost:8080/", 147 | "height": 102 148 | } 149 | }, 150 | "source": [ 151 | "i = 0\n", 152 | "while i < 6:\n", 153 | " i += 1 #i=i+1 \n", 154 | " if i == 3:\n", 155 | " continue #Döngü bir sonraki adıma geçer...\n", 156 | " print(i)" 157 | ], 158 | "execution_count": null, 159 | "outputs": [ 160 | { 161 | "output_type": "stream", 162 | "text": [ 163 | "1\n", 164 | "2\n", 165 | "4\n", 166 | "5\n", 167 | "6\n" 168 | ], 169 | "name": "stdout" 170 | } 171 | ] 172 | }, 173 | { 174 | "cell_type": "code", 175 | "metadata": { 176 | "id": "qSaNzdqiXTQO", 177 | "outputId": "09780748-2990-42b4-e8ff-e21e88b29500", 178 | "colab": { 179 | "base_uri": "https://localhost:8080/", 180 | "height": 119 181 | } 182 | }, 183 | "source": [ 184 | "i = 1\n", 185 | "while i < 6:\n", 186 | " print(i) #5\n", 187 | " i += 1\n", 188 | "else:\n", 189 | " print(\"i, 6'dan küçük değil...\")" 190 | ], 191 | "execution_count": null, 192 | "outputs": [ 193 | { 194 | "output_type": "stream", 195 | "text": [ 196 | "1\n", 197 | "2\n", 198 | "3\n", 199 | "4\n", 200 | "5\n", 201 | "i, 6'dan küçük değil...\n" 202 | ], 203 | "name": "stdout" 204 | } 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "metadata": { 210 | "id": "d1pPSZU6XX0z", 211 | "outputId": "f9251a22-4a3a-4540-d3b2-13bfe2287ded", 212 | "colab": { 213 | "base_uri": "https://localhost:8080/", 214 | "height": 119 215 | } 216 | }, 217 | "source": [ 218 | "meyve = [\"elma\", \"muz\", \"çilek\"]\n", 219 | "i=0\n", 220 | "while i<3:\n", 221 | " print(meyve[i])\n", 222 | " i=i+1\n", 223 | "for x in meyve: # x döngü elemanı\n", 224 | " print(x)" 225 | ], 226 | "execution_count": null, 227 | "outputs": [ 228 | { 229 | "output_type": "stream", 230 | "text": [ 231 | "elma\n", 232 | "muz\n", 233 | "çilek\n", 234 | "elma\n", 235 | "muz\n", 236 | "çilek\n" 237 | ], 238 | "name": "stdout" 239 | } 240 | ] 241 | }, 242 | { 243 | "cell_type": "code", 244 | "metadata": { 245 | "id": "TpOAe_52KQ2b", 246 | "outputId": "2235d540-99cb-4886-d05d-64bb68151fec", 247 | "colab": { 248 | "base_uri": "https://localhost:8080/", 249 | "height": 68 250 | } 251 | }, 252 | "source": [ 253 | "meyve = [\"elma\", \"muz\", \"çilek\"]\n", 254 | "for x in meyve: # x döngü elemanı \n", 255 | " print(x[0])" 256 | ], 257 | "execution_count": null, 258 | "outputs": [ 259 | { 260 | "output_type": "stream", 261 | "text": [ 262 | "e\n", 263 | "m\n", 264 | "ç\n" 265 | ], 266 | "name": "stdout" 267 | } 268 | ] 269 | }, 270 | { 271 | "cell_type": "code", 272 | "metadata": { 273 | "id": "sNUXWXDfLNVx", 274 | "outputId": "b86a4864-18a6-424a-e263-6517b5ef1439", 275 | "colab": { 276 | "base_uri": "https://localhost:8080/", 277 | "height": 221 278 | } 279 | }, 280 | "source": [ 281 | "meyve = [\"elma\", \"muz\", \"çilek\"]\n", 282 | "for x in meyve: \n", 283 | " for a in x: \n", 284 | " print(a)" 285 | ], 286 | "execution_count": null, 287 | "outputs": [ 288 | { 289 | "output_type": "stream", 290 | "text": [ 291 | "e\n", 292 | "l\n", 293 | "m\n", 294 | "a\n", 295 | "m\n", 296 | "u\n", 297 | "z\n", 298 | "ç\n", 299 | "i\n", 300 | "l\n", 301 | "e\n", 302 | "k\n" 303 | ], 304 | "name": "stdout" 305 | } 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "metadata": { 311 | "id": "M0scOF0KXbeX", 312 | "outputId": "437cdb2b-3ad5-445b-bd9e-4faf45ae7c27", 313 | "colab": { 314 | "base_uri": "https://localhost:8080/", 315 | "height": 85 316 | } 317 | }, 318 | "source": [ 319 | "kelime=\"elma\"\n", 320 | "for x in kelime:\n", 321 | " print(x)" 322 | ], 323 | "execution_count": null, 324 | "outputs": [ 325 | { 326 | "output_type": "stream", 327 | "text": [ 328 | "e\n", 329 | "l\n", 330 | "m\n", 331 | "a\n" 332 | ], 333 | "name": "stdout" 334 | } 335 | ] 336 | }, 337 | { 338 | "cell_type": "code", 339 | "metadata": { 340 | "id": "VRH6jy0EXgy5", 341 | "outputId": "8d368546-9e3f-41df-d5a0-27e82e7fda05", 342 | "colab": { 343 | "base_uri": "https://localhost:8080/", 344 | "height": 51 345 | } 346 | }, 347 | "source": [ 348 | "for x in meyve: #meyve = [\"elma\", \"muz\", \"çilek\"]\n", 349 | " print(x)\n", 350 | " if x == \"muz\":\n", 351 | " break #döngüyü sonladırır...." 352 | ], 353 | "execution_count": null, 354 | "outputs": [ 355 | { 356 | "output_type": "stream", 357 | "text": [ 358 | "elma\n", 359 | "muz\n" 360 | ], 361 | "name": "stdout" 362 | } 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "metadata": { 368 | "id": "5pQehKH_XjFZ", 369 | "outputId": "0c14dce1-8f04-4f4c-819f-d71df97928b3", 370 | "colab": { 371 | "base_uri": "https://localhost:8080/", 372 | "height": 51 373 | } 374 | }, 375 | "source": [ 376 | "for x in meyve: \n", 377 | " if x == \"muz\":\n", 378 | " continue #Bir sonraki adıma geçer...\n", 379 | " print(x)" 380 | ], 381 | "execution_count": null, 382 | "outputs": [ 383 | { 384 | "output_type": "stream", 385 | "text": [ 386 | "elma\n", 387 | "çilek\n" 388 | ], 389 | "name": "stdout" 390 | } 391 | ] 392 | }, 393 | { 394 | "cell_type": "code", 395 | "metadata": { 396 | "id": "pcoYflGGXmNu", 397 | "outputId": "f06314c0-4e7a-48eb-ee7b-820d789dc0b0", 398 | "colab": { 399 | "base_uri": "https://localhost:8080/", 400 | "height": 102 401 | } 402 | }, 403 | "source": [ 404 | "for x in range(5):\n", 405 | " print(x)" 406 | ], 407 | "execution_count": null, 408 | "outputs": [ 409 | { 410 | "output_type": "stream", 411 | "text": [ 412 | "0\n", 413 | "1\n", 414 | "2\n", 415 | "3\n", 416 | "4\n" 417 | ], 418 | "name": "stdout" 419 | } 420 | ] 421 | }, 422 | { 423 | "cell_type": "code", 424 | "metadata": { 425 | "id": "S9w2GFemXqKK", 426 | "outputId": "83f98548-e50d-41e0-f5f8-353442e5ea40", 427 | "colab": { 428 | "base_uri": "https://localhost:8080/", 429 | "height": 68 430 | } 431 | }, 432 | "source": [ 433 | "for x in range(2, 5):#x=2,3,4\n", 434 | " print(x)" 435 | ], 436 | "execution_count": null, 437 | "outputs": [ 438 | { 439 | "output_type": "stream", 440 | "text": [ 441 | "2\n", 442 | "3\n", 443 | "4\n" 444 | ], 445 | "name": "stdout" 446 | } 447 | ] 448 | }, 449 | { 450 | "cell_type": "code", 451 | "metadata": { 452 | "id": "D0AV6eYlXu9_", 453 | "outputId": "b5fd2dd0-d765-4a31-da11-aff4f5a0a159", 454 | "colab": { 455 | "base_uri": "https://localhost:8080/", 456 | "height": 85 457 | } 458 | }, 459 | "source": [ 460 | "for x in range(2, 10, 2):#ilk parametre başlangıç değeri, ikinci parametre bitiş değeri, üçüncü parametre artış\n", 461 | " print(x)" 462 | ], 463 | "execution_count": null, 464 | "outputs": [ 465 | { 466 | "output_type": "stream", 467 | "text": [ 468 | "2\n", 469 | "4\n", 470 | "6\n", 471 | "8\n" 472 | ], 473 | "name": "stdout" 474 | } 475 | ] 476 | }, 477 | { 478 | "cell_type": "code", 479 | "metadata": { 480 | "id": "xBPq2NXyXwkj", 481 | "outputId": "3c2ae0f3-d8d5-4fa3-ba4e-b4c4f0b6192a", 482 | "colab": { 483 | "base_uri": "https://localhost:8080/", 484 | "height": 170 485 | } 486 | }, 487 | "source": [ 488 | "ozellik = [\"kırmızı\", \"sarı\", \"lezzetli\"]\n", 489 | "meyve = [\"elma\", \"muz\", \"çilek\"]\n", 490 | "\n", 491 | "for x in ozellik: \n", 492 | " for y in meyve:\n", 493 | " print(x, y)" 494 | ], 495 | "execution_count": null, 496 | "outputs": [ 497 | { 498 | "output_type": "stream", 499 | "text": [ 500 | "kırmızı elma\n", 501 | "kırmızı muz\n", 502 | "kırmızı çilek\n", 503 | "sarı elma\n", 504 | "sarı muz\n", 505 | "sarı çilek\n", 506 | "lezzetli elma\n", 507 | "lezzetli muz\n", 508 | "lezzetli çilek\n" 509 | ], 510 | "name": "stdout" 511 | } 512 | ] 513 | }, 514 | { 515 | "cell_type": "code", 516 | "metadata": { 517 | "id": "8OXfZKXtX3CO", 518 | "outputId": "d7db8def-38de-4cb1-d803-8f7c1869e7bb", 519 | "colab": { 520 | "base_uri": "https://localhost:8080/", 521 | "height": 68 522 | } 523 | }, 524 | "source": [ 525 | "sozluk = {'kitap':'book', 'bilgisayar':'computer', 'dil':'language' }\n", 526 | "for i in sozluk: #key value\n", 527 | " print(i)" 528 | ], 529 | "execution_count": null, 530 | "outputs": [ 531 | { 532 | "output_type": "stream", 533 | "text": [ 534 | "kitap\n", 535 | "bilgisayar\n", 536 | "dil\n" 537 | ], 538 | "name": "stdout" 539 | } 540 | ] 541 | }, 542 | { 543 | "cell_type": "code", 544 | "metadata": { 545 | "id": "u8RW4mI3X4WA", 546 | "outputId": "a1813cdd-a271-4062-d531-4476c558f0fe", 547 | "colab": { 548 | "base_uri": "https://localhost:8080/", 549 | "height": 68 550 | } 551 | }, 552 | "source": [ 553 | "sozluk = {'kitap':'book', 'bilgisayar':'computer', 'dil':'language' }\n", 554 | "for i in sozluk.values():\n", 555 | " print(i)" 556 | ], 557 | "execution_count": null, 558 | "outputs": [ 559 | { 560 | "output_type": "stream", 561 | "text": [ 562 | "book\n", 563 | "computer\n", 564 | "language\n" 565 | ], 566 | "name": "stdout" 567 | } 568 | ] 569 | }, 570 | { 571 | "cell_type": "code", 572 | "metadata": { 573 | "id": "FtsaLWpaX9bo", 574 | "outputId": "f15aab06-0f83-4ae1-b50b-162aa4e07282", 575 | "colab": { 576 | "base_uri": "https://localhost:8080/", 577 | "height": 68 578 | } 579 | }, 580 | "source": [ 581 | "sozluk = {'kitap':'book', 'bilgisayar':'computer', 'dil':'language' }\n", 582 | "for i in sozluk: #i=dil sozluk[dil]\n", 583 | " print(i, '->', sozluk[i])" 584 | ], 585 | "execution_count": null, 586 | "outputs": [ 587 | { 588 | "output_type": "stream", 589 | "text": [ 590 | "kitap -> book\n", 591 | "bilgisayar -> computer\n", 592 | "dil -> language\n" 593 | ], 594 | "name": "stdout" 595 | } 596 | ] 597 | }, 598 | { 599 | "cell_type": "code", 600 | "metadata": { 601 | "id": "pXsG79zQYAqU", 602 | "outputId": "a28cabdc-2fc3-473a-ca0e-859980080201", 603 | "colab": { 604 | "base_uri": "https://localhost:8080/", 605 | "height": 51 606 | } 607 | }, 608 | "source": [ 609 | "harfler = 'abcdefgh' \n", 610 | "liste=['Bilgisayar','Kitap','Kalem']\n", 611 | "print(*liste, sep='-')\n", 612 | "print(*harfler,sep='+')" 613 | ], 614 | "execution_count": null, 615 | "outputs": [ 616 | { 617 | "output_type": "stream", 618 | "text": [ 619 | "Bilgisayar-Kitap-Kalem\n", 620 | "a+b+c+d+e+f+g+h\n" 621 | ], 622 | "name": "stdout" 623 | } 624 | ] 625 | }, 626 | { 627 | "cell_type": "code", 628 | "metadata": { 629 | "id": "Nsmp1kBGYFZ3", 630 | "outputId": "b1939bac-943a-4056-826d-c4b87067c050", 631 | "colab": { 632 | "base_uri": "https://localhost:8080/", 633 | "height": 85 634 | } 635 | }, 636 | "source": [ 637 | "while True: #sonsuz döngü\n", 638 | " try:\n", 639 | " notu = int(input('Lütfen 0-100 aralığında bir not girin')) \n", 640 | " if notu>100 or notu<0:\n", 641 | " print('Girdiğiniz not değeri 0-100 arasında olmalıdır') \n", 642 | " else:\n", 643 | " if notu>84:\n", 644 | " print('Öğrenci notu: 5')\n", 645 | " elif notu<85 and notu>69: \n", 646 | " print('Öğrenci notu: 4')\n", 647 | " elif notu<70 and notu>54: \n", 648 | " print('Öğrenci notu: 3')\n", 649 | " elif notu<55 and notu>44: \n", 650 | " print('Öğrenci notu: 2')\n", 651 | " else:\n", 652 | " print('Öğrenci notu: 1')\n", 653 | " break # döngüyü sonlandırma \n", 654 | " except:\n", 655 | " print('Lütfen sayı değeri girin')" 656 | ], 657 | "execution_count": null, 658 | "outputs": [ 659 | { 660 | "output_type": "stream", 661 | "text": [ 662 | "Lütfen 0-100 aralığında bir not girinqwqwwq\n", 663 | "Lütfen sayı değeri girin\n", 664 | "Lütfen 0-100 aralığında bir not girin90\n", 665 | "Öğrenci notu: 5\n" 666 | ], 667 | "name": "stdout" 668 | } 669 | ] 670 | } 671 | ] 672 | } -------------------------------------------------------------------------------- /Ders3.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Ders3.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyNgX+pOMS6alF/fNvM2+zmd" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "metadata": { 19 | "id": "TwRnt3d20kut" 20 | }, 21 | "source": [ 22 | "Dictionary (Sözlük) key-value(anahtar ve değer) çiftinden oluşur. Küme parantezi içerisine yazılır ve iki nokta ile birbirinden ayrılır." 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "metadata": { 28 | "id": "SiaZXFqe0X1X" 29 | }, 30 | "source": [ 31 | "bolge_il = {\n", 32 | "'Ege': 'Manisa', \n", 33 | "'Marmara': 'İstanbul', \n", 34 | "'icAnadolu': 'Ankara', \n", 35 | "'Akdeniz': 'Antalya'\n", 36 | "}" 37 | ], 38 | "execution_count": 1, 39 | "outputs": [] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "metadata": { 44 | "id": "eutvM9Mn1Ef_", 45 | "outputId": "184cf65a-20be-4712-e584-3974c1e3509b", 46 | "colab": { 47 | "base_uri": "https://localhost:8080/", 48 | "height": 34 49 | } 50 | }, 51 | "source": [ 52 | "ege_il = bolge_il['Akdeniz']\n", 53 | "print(ege_il)" 54 | ], 55 | "execution_count": 4, 56 | "outputs": [ 57 | { 58 | "output_type": "stream", 59 | "text": [ 60 | "Antalya\n" 61 | ], 62 | "name": "stdout" 63 | } 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "metadata": { 69 | "id": "Xg1PRc1O2FQj", 70 | "outputId": "56810355-1bd1-4e8f-a682-3589dba5359d", 71 | "colab": { 72 | "base_uri": "https://localhost:8080/", 73 | "height": 85 74 | } 75 | }, 76 | "source": [ 77 | "#key-value\n", 78 | "#for (i=0;i<10;i++) C# for döngüsü \n", 79 | "for k in bolge_il.keys():\n", 80 | " print('{} ilinin bölgesi: {}'.format(bolge_il[k], k))#bolge_il[k] k='Marmara'" 81 | ], 82 | "execution_count": 6, 83 | "outputs": [ 84 | { 85 | "output_type": "stream", 86 | "text": [ 87 | "Manisa ilinin bölgesi: Ege\n", 88 | "İstanbul ilinin bölgesi: Marmara\n", 89 | "Ankara ilinin bölgesi: icAnadolu\n", 90 | "Antalya ilinin bölgesi: Akdeniz\n" 91 | ], 92 | "name": "stdout" 93 | } 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": { 99 | "id": "39mBrAnX3Jbm" 100 | }, 101 | "source": [ 102 | "**SET**\n", 103 | "\n", 104 | "Pythonda set listeleri, list' e benzer ancak fark olarak set içindeki elemanlar sıralanamaz (sort) ve indekslenemez yani set elemanlarına 0,1 şeklinde indeks numaraları ile ulaşamayız. " 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "metadata": { 110 | "id": "gpZGzmr32fDw", 111 | "outputId": "9d078ff7-f54e-42c8-a46b-c4b3076404c2", 112 | "colab": { 113 | "base_uri": "https://localhost:8080/", 114 | "height": 34 115 | } 116 | }, 117 | "source": [ 118 | "fruits = {\"banana\", \"grape\", \"cherry\"}\n", 119 | "print(fruits)" 120 | ], 121 | "execution_count": 7, 122 | "outputs": [ 123 | { 124 | "output_type": "stream", 125 | "text": [ 126 | "{'cherry', 'banana', 'grape'}\n" 127 | ], 128 | "name": "stdout" 129 | } 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "metadata": { 135 | "id": "RfLlUzq-3fUm", 136 | "outputId": "046b5aa2-1b97-4a78-a60a-99854225d889", 137 | "colab": { 138 | "base_uri": "https://localhost:8080/", 139 | "height": 85 140 | } 141 | }, 142 | "source": [ 143 | "fruits = {\"banana\", \"grape\", \"cherry\"}#set küme parantezi ile tanımlanmış...\n", 144 | "for fruit in fruits:\n", 145 | " print(fruit)\n", 146 | "print(type(fruits))" 147 | ], 148 | "execution_count": 9, 149 | "outputs": [ 150 | { 151 | "output_type": "stream", 152 | "text": [ 153 | "cherry\n", 154 | "banana\n", 155 | "grape\n", 156 | "\n" 157 | ], 158 | "name": "stdout" 159 | } 160 | ] 161 | }, 162 | { 163 | "cell_type": "code", 164 | "metadata": { 165 | "id": "o-GTRYUr6fXf", 166 | "outputId": "5098ab56-d2dd-4187-a498-153f6b8a60ab", 167 | "colab": { 168 | "base_uri": "https://localhost:8080/", 169 | "height": 51 170 | } 171 | }, 172 | "source": [ 173 | " my_list = [1,2,3]#list köşeli parantezle tanımlanmış... \n", 174 | " print(my_list)\n", 175 | " my_set = set(my_list)\n", 176 | " print(my_set)" 177 | ], 178 | "execution_count": 11, 179 | "outputs": [ 180 | { 181 | "output_type": "stream", 182 | "text": [ 183 | "[1, 2, 3]\n", 184 | "{1, 2, 3}\n" 185 | ], 186 | "name": "stdout" 187 | } 188 | ] 189 | }, 190 | { 191 | "cell_type": "code", 192 | "metadata": { 193 | "id": "TVdxnL9l7k9S", 194 | "outputId": "2c9909aa-b22d-40af-b629-e4d2bbf68dee", 195 | "colab": { 196 | "base_uri": "https://localhost:8080/", 197 | "height": 34 198 | } 199 | }, 200 | "source": [ 201 | "import math\n", 202 | "math.sqrt(16)" 203 | ], 204 | "execution_count": 12, 205 | "outputs": [ 206 | { 207 | "output_type": "execute_result", 208 | "data": { 209 | "text/plain": [ 210 | "4.0" 211 | ] 212 | }, 213 | "metadata": { 214 | "tags": [] 215 | }, 216 | "execution_count": 12 217 | } 218 | ] 219 | }, 220 | { 221 | "cell_type": "code", 222 | "metadata": { 223 | "id": "kUSWpOWADcaz", 224 | "outputId": "744aa79e-47d0-4071-e4f3-11ed10c158ad", 225 | "colab": { 226 | "base_uri": "https://localhost:8080/", 227 | "height": 935 228 | } 229 | }, 230 | "source": [ 231 | "dir(math)" 232 | ], 233 | "execution_count": 13, 234 | "outputs": [ 235 | { 236 | "output_type": "execute_result", 237 | "data": { 238 | "text/plain": [ 239 | "['__doc__',\n", 240 | " '__loader__',\n", 241 | " '__name__',\n", 242 | " '__package__',\n", 243 | " '__spec__',\n", 244 | " 'acos',\n", 245 | " 'acosh',\n", 246 | " 'asin',\n", 247 | " 'asinh',\n", 248 | " 'atan',\n", 249 | " 'atan2',\n", 250 | " 'atanh',\n", 251 | " 'ceil',\n", 252 | " 'copysign',\n", 253 | " 'cos',\n", 254 | " 'cosh',\n", 255 | " 'degrees',\n", 256 | " 'e',\n", 257 | " 'erf',\n", 258 | " 'erfc',\n", 259 | " 'exp',\n", 260 | " 'expm1',\n", 261 | " 'fabs',\n", 262 | " 'factorial',\n", 263 | " 'floor',\n", 264 | " 'fmod',\n", 265 | " 'frexp',\n", 266 | " 'fsum',\n", 267 | " 'gamma',\n", 268 | " 'gcd',\n", 269 | " 'hypot',\n", 270 | " 'inf',\n", 271 | " 'isclose',\n", 272 | " 'isfinite',\n", 273 | " 'isinf',\n", 274 | " 'isnan',\n", 275 | " 'ldexp',\n", 276 | " 'lgamma',\n", 277 | " 'log',\n", 278 | " 'log10',\n", 279 | " 'log1p',\n", 280 | " 'log2',\n", 281 | " 'modf',\n", 282 | " 'nan',\n", 283 | " 'pi',\n", 284 | " 'pow',\n", 285 | " 'radians',\n", 286 | " 'sin',\n", 287 | " 'sinh',\n", 288 | " 'sqrt',\n", 289 | " 'tan',\n", 290 | " 'tanh',\n", 291 | " 'tau',\n", 292 | " 'trunc']" 293 | ] 294 | }, 295 | "metadata": { 296 | "tags": [] 297 | }, 298 | "execution_count": 13 299 | } 300 | ] 301 | }, 302 | { 303 | "cell_type": "code", 304 | "metadata": { 305 | "id": "WTLR7OZr8n-B", 306 | "outputId": "124919bf-d149-40a1-f222-c12a3a8f09ba", 307 | "colab": { 308 | "base_uri": "https://localhost:8080/", 309 | "height": 35 310 | } 311 | }, 312 | "source": [ 313 | "math.__doc__" 314 | ], 315 | "execution_count": 15, 316 | "outputs": [ 317 | { 318 | "output_type": "execute_result", 319 | "data": { 320 | "application/vnd.google.colaboratory.intrinsic+json": { 321 | "type": "string" 322 | }, 323 | "text/plain": [ 324 | "'This module is always available. It provides access to the\\nmathematical functions defined by the C standard.'" 325 | ] 326 | }, 327 | "metadata": { 328 | "tags": [] 329 | }, 330 | "execution_count": 15 331 | } 332 | ] 333 | }, 334 | { 335 | "cell_type": "code", 336 | "metadata": { 337 | "id": "4_LkEaBW8zhT", 338 | "outputId": "979614de-e763-4ae6-ba91-1627789f874a", 339 | "colab": { 340 | "base_uri": "https://localhost:8080/", 341 | "height": 35 342 | } 343 | }, 344 | "source": [ 345 | "def Merhaba():\n", 346 | " \"\"\"Bu metot ile ilgili doc burada olabilir.\n", 347 | " Burada Merhaba Dünya mesajı verilecek....\n", 348 | " \"\"\" \n", 349 | " return 'Hello World'\n", 350 | "Merhaba.__doc__" 351 | ], 352 | "execution_count": 16, 353 | "outputs": [ 354 | { 355 | "output_type": "execute_result", 356 | "data": { 357 | "application/vnd.google.colaboratory.intrinsic+json": { 358 | "type": "string" 359 | }, 360 | "text/plain": [ 361 | "'Bu metot ile ilgili doc burada olabilir.\\n Burada Merhaba Dünya mesajı verilecek....\\n '" 362 | ] 363 | }, 364 | "metadata": { 365 | "tags": [] 366 | }, 367 | "execution_count": 16 368 | } 369 | ] 370 | }, 371 | { 372 | "cell_type": "code", 373 | "metadata": { 374 | "id": "Vm5tUmck_Uv_", 375 | "outputId": "fc4fab54-5003-465d-ec11-eb05c241f664", 376 | "colab": { 377 | "base_uri": "https://localhost:8080/", 378 | "height": 119 379 | } 380 | }, 381 | "source": [ 382 | "help(Merhaba)" 383 | ], 384 | "execution_count": 17, 385 | "outputs": [ 386 | { 387 | "output_type": "stream", 388 | "text": [ 389 | "Help on function Merhaba in module __main__:\n", 390 | "\n", 391 | "Merhaba()\n", 392 | " Bu metot ile ilgili doc burada olabilir.\n", 393 | " Burada Merhaba Dünya mesajı verilecek....\n", 394 | "\n" 395 | ], 396 | "name": "stdout" 397 | } 398 | ] 399 | }, 400 | { 401 | "cell_type": "code", 402 | "metadata": { 403 | "id": "6QjaAWAiBS5n" 404 | }, 405 | "source": [ 406 | "# if şart_ifadesi:\n", 407 | "# şart doğru ise yapılacaklar\n", 408 | "\"\"\"\n", 409 | "Eşitlik: a == b\n", 410 | "Eşit Değil: a != b\n", 411 | "Küçük: a < b\n", 412 | "Küçük Eşit: a <= b\n", 413 | "Büyük: a > b\n", 414 | "Büyük Eşit: a >= b\n", 415 | "\"\"\"" 416 | ], 417 | "execution_count": null, 418 | "outputs": [] 419 | }, 420 | { 421 | "cell_type": "code", 422 | "metadata": { 423 | "id": "jucHNaZNAFqR", 424 | "outputId": "8e1d5e88-239f-4243-bc9a-6cfc54006d83", 425 | "colab": { 426 | "base_uri": "https://localhost:8080/", 427 | "height": 34 428 | } 429 | }, 430 | "source": [ 431 | "a=10 \n", 432 | "if a>5:\n", 433 | " print('a değeri 5ten büyüktür')" 434 | ], 435 | "execution_count": 18, 436 | "outputs": [ 437 | { 438 | "output_type": "stream", 439 | "text": [ 440 | "a değeri 5ten büyüktür\n" 441 | ], 442 | "name": "stdout" 443 | } 444 | ] 445 | }, 446 | { 447 | "cell_type": "code", 448 | "metadata": { 449 | "id": "8BoMxa22BcEy", 450 | "outputId": "99e5b3e8-3336-48a8-96f2-be481cc7c1f2", 451 | "colab": { 452 | "base_uri": "https://localhost:8080/", 453 | "height": 34 454 | } 455 | }, 456 | "source": [ 457 | "a = 33\n", 458 | "b = 200\n", 459 | "if b > a:\n", 460 | " print(\"b, a'dan daha büyük...\")" 461 | ], 462 | "execution_count": 21, 463 | "outputs": [ 464 | { 465 | "output_type": "stream", 466 | "text": [ 467 | "b, a'dan daha büyük...\n" 468 | ], 469 | "name": "stdout" 470 | } 471 | ] 472 | }, 473 | { 474 | "cell_type": "code", 475 | "metadata": { 476 | "id": "b0SnXRl0ANo5", 477 | "outputId": "badf9026-1930-477b-8042-c6a98019b763", 478 | "colab": { 479 | "base_uri": "https://localhost:8080/", 480 | "height": 34 481 | } 482 | }, 483 | "source": [ 484 | "a=5\n", 485 | "if a>5:\n", 486 | " print('a değeri 5ten büyüktür') \n", 487 | "else:\n", 488 | " print('a değeri 5 ten büyük değil..')" 489 | ], 490 | "execution_count": 29, 491 | "outputs": [ 492 | { 493 | "output_type": "stream", 494 | "text": [ 495 | "a değeri 5 ten büyük değil..\n" 496 | ], 497 | "name": "stdout" 498 | } 499 | ] 500 | }, 501 | { 502 | "cell_type": "code", 503 | "metadata": { 504 | "id": "NqgvHsuXBigD", 505 | "outputId": "985fd21b-0b76-4344-e607-f18fdd921053", 506 | "colab": { 507 | "base_uri": "https://localhost:8080/", 508 | "height": 34 509 | } 510 | }, 511 | "source": [ 512 | "a = 200\n", 513 | "b = 33\n", 514 | "c = 500\n", 515 | "if a > b and c > a:\n", 516 | " print(\"Her iki durumda doğru\")" 517 | ], 518 | "execution_count": 35, 519 | "outputs": [ 520 | { 521 | "output_type": "stream", 522 | "text": [ 523 | "Her iki durumda doğru\n" 524 | ], 525 | "name": "stdout" 526 | } 527 | ] 528 | }, 529 | { 530 | "cell_type": "code", 531 | "metadata": { 532 | "id": "7Nddf9pmBuxk", 533 | "outputId": "24891c7d-9061-4c11-903d-9023b311acf6", 534 | "colab": { 535 | "base_uri": "https://localhost:8080/", 536 | "height": 51 537 | } 538 | }, 539 | "source": [ 540 | "x = 8\n", 541 | "\n", 542 | "if x > 10:\n", 543 | " print(\"10 dan büyük,\")\n", 544 | " if x > 20:\n", 545 | " print(\"ve 20 den büyük!\")\n", 546 | " else:\n", 547 | " print(\"ama 20 den küçük..\")\n", 548 | "else:\n", 549 | " print('10 dan büyük değil')\n", 550 | "print('İşlem bitti..')" 551 | ], 552 | "execution_count": 40, 553 | "outputs": [ 554 | { 555 | "output_type": "stream", 556 | "text": [ 557 | "10 dan büyük değil\n", 558 | "İşlem bitti..\n" 559 | ], 560 | "name": "stdout" 561 | } 562 | ] 563 | }, 564 | { 565 | "cell_type": "code", 566 | "metadata": { 567 | "id": "nPBfnZrECP3u", 568 | "outputId": "f21dcf17-c234-4619-ff2b-8d46d1b8bfe6", 569 | "colab": { 570 | "base_uri": "https://localhost:8080/", 571 | "height": 51 572 | } 573 | }, 574 | "source": [ 575 | "\"\"\"\n", 576 | "if şart1:\n", 577 | " doğruysa\n", 578 | "elif şart2:\n", 579 | " doğruysa\n", 580 | "elif şart3:\n", 581 | " doğruysa\n", 582 | "else :\n", 583 | " hiçbiri olmadıysa\n", 584 | "\"\"\"\n", 585 | "notu = int(input('Notunuzu girin:')) #input ile girilen değerler str türündedir. int(değişken) notu=35\n", 586 | "if notu>=85:\n", 587 | " print('Öğrenci notu: 5') \n", 588 | "elif notu<85 and notu>69: # else if=elif\n", 589 | " print('Öğrenci notu: 4') \n", 590 | "elif notu<70 and notu>54:\n", 591 | " print('Öğrenci notu: 3') \n", 592 | "elif notu<55 and notu>44:\n", 593 | " print('Öğrenci notu: 2') \n", 594 | "else:\n", 595 | " print('Öğrenci notu: 1')" 596 | ], 597 | "execution_count": 42, 598 | "outputs": [ 599 | { 600 | "output_type": "stream", 601 | "text": [ 602 | "Notunuzu girin:55\n", 603 | "Öğrenci notu: 3\n" 604 | ], 605 | "name": "stdout" 606 | } 607 | ] 608 | }, 609 | { 610 | "cell_type": "code", 611 | "metadata": { 612 | "id": "2YBOQwU2CjYk", 613 | "outputId": "bc1929fb-0dd9-4600-a149-9369c8a48cd3", 614 | "colab": { 615 | "base_uri": "https://localhost:8080/", 616 | "height": 85 617 | } 618 | }, 619 | "source": [ 620 | "yas = int(input('Lütfen yaşınızı yazın\\n')) \n", 621 | "if yas>17:\n", 622 | " cinsiyet = (input('Lütfen cinsiyetinizi girin E/K')).upper()\n", 623 | " if cinsiyet=='E':\n", 624 | " print('Askerlik durumunuz bulunmaktadır')\n", 625 | " else:\n", 626 | " print('Askerlik durumunuz bulunmamaktadır') \n", 627 | "else: \n", 628 | " print('Askerlik durumunuz bulunmamaktadır')" 629 | ], 630 | "execution_count": 45, 631 | "outputs": [ 632 | { 633 | "output_type": "stream", 634 | "text": [ 635 | "Lütfen yaşınızı yazın\n", 636 | "20\n", 637 | "Lütfen cinsiyetinizi girin E/Ke\n", 638 | "Askerlik durumunuz bulunmaktadır\n" 639 | ], 640 | "name": "stdout" 641 | } 642 | ] 643 | } 644 | ] 645 | } -------------------------------------------------------------------------------- /Ders2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Ders2.ipynb", 7 | "provenance": [], 8 | "authorship_tag": "ABX9TyMsUnDRKR8DXZdWemDq0Dwy" 9 | }, 10 | "kernelspec": { 11 | "name": "python3", 12 | "display_name": "Python 3" 13 | } 14 | }, 15 | "cells": [ 16 | { 17 | "cell_type": "markdown", 18 | "metadata": { 19 | "id": "vhI08hPqActn" 20 | }, 21 | "source": [ 22 | "DEĞİŞKEN TANIMLAMADA DİKKAT EDİLMESİ GEREKEN KURALLAR\n", 23 | "\n", 24 | "\n", 25 | "1. Değişken isimleri harfle veya alt çizgi ile (under score) başlamalıdır.\n", 26 | "2. Değişken isimleri harf,sayı ve alt çizgi içerebilir.\n", 27 | "3. Büyük küçük harf duyarlılığı vardır.\n" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "metadata": { 33 | "id": "kmSrCyoqAWwP", 34 | "outputId": "f839ffe4-35e7-46c5-eb22-c51f1192c4ef", 35 | "colab": { 36 | "base_uri": "https://localhost:8080/", 37 | "height": 102 38 | } 39 | }, 40 | "source": [ 41 | "x=9\n", 42 | "X=25\n", 43 | "_y='Merhaba Dünya'\n", 44 | "print(x,_y)\n", 45 | "print(X)\n", 46 | "Akhisar='MYO'\n", 47 | "akhisar='Bilgisayar Programcılığı'\n", 48 | "print(Akhisar)\n", 49 | "print(akhisar)\n", 50 | "print('Bölümümüzün Adı:', akhisar )" 51 | ], 52 | "execution_count": 7, 53 | "outputs": [ 54 | { 55 | "output_type": "stream", 56 | "text": [ 57 | "9 Merhaba Dünya\n", 58 | "25\n", 59 | "MYO\n", 60 | "Bilgisayar Programcılığı\n", 61 | "Bölümümüzün Adı: Bilgisayar Programcılığı\n" 62 | ], 63 | "name": "stdout" 64 | } 65 | ] 66 | }, 67 | { 68 | "cell_type": "code", 69 | "metadata": { 70 | "id": "OsK-nXsjCCDQ", 71 | "outputId": "5786e940-35d4-4da7-8363-e9b21c649e99", 72 | "colab": { 73 | "base_uri": "https://localhost:8080/", 74 | "height": 130 75 | } 76 | }, 77 | "source": [ 78 | "9a='Merhaba Dünya'\n", 79 | "print(9a)\n", 80 | "#Değişken isimleri sayı ile başlayamaz..." 81 | ], 82 | "execution_count": null, 83 | "outputs": [ 84 | { 85 | "output_type": "error", 86 | "ename": "SyntaxError", 87 | "evalue": "ignored", 88 | "traceback": [ 89 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m 9a='Merhaba Dünya'\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" 90 | ] 91 | } 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "metadata": { 97 | "id": "aIqLhr0qCL4S", 98 | "outputId": "59518f87-4c21-4586-9767-1047e3fbad66", 99 | "colab": { 100 | "base_uri": "https://localhost:8080/", 101 | "height": 85 102 | } 103 | }, 104 | "source": [ 105 | "tamSayi=25\n", 106 | "ondalikli=3.14\n", 107 | "metin='Merhaba Dünya'\n", 108 | "dogruYanlis=True\n", 109 | "print(type(tamSayi))\n", 110 | "print(type(ondalikli))\n", 111 | "print(type(metin))\n", 112 | "print(type(dogruYanlis))" 113 | ], 114 | "execution_count": null, 115 | "outputs": [ 116 | { 117 | "output_type": "stream", 118 | "text": [ 119 | "\n", 120 | "\n", 121 | "\n", 122 | "\n" 123 | ], 124 | "name": "stdout" 125 | } 126 | ] 127 | }, 128 | { 129 | "cell_type": "code", 130 | "metadata": { 131 | "id": "73AbHez7C-P4", 132 | "outputId": "b2932d03-ae06-48de-9539-3519031e91ab", 133 | "colab": { 134 | "base_uri": "https://localhost:8080/", 135 | "height": 51 136 | } 137 | }, 138 | "source": [ 139 | "a,b,c=1,2,3\n", 140 | "print(a,b,c)\n", 141 | "A=B=C=1\n", 142 | "print(A,B,C)" 143 | ], 144 | "execution_count": 16, 145 | "outputs": [ 146 | { 147 | "output_type": "stream", 148 | "text": [ 149 | "1 2 3\n", 150 | "1 1 1\n" 151 | ], 152 | "name": "stdout" 153 | } 154 | ] 155 | }, 156 | { 157 | "cell_type": "code", 158 | "metadata": { 159 | "id": "SNnPQ1AbDMEt", 160 | "outputId": "ef7332bc-6ea7-4a00-f716-d55ac62f817f", 161 | "colab": { 162 | "base_uri": "https://localhost:8080/", 163 | "height": 198 164 | } 165 | }, 166 | "source": [ 167 | "w,y,z=1,2\n", 168 | "print(w,y,z)\n", 169 | "#3 değişken(w,y,z) tanımlanmış fakat 2 değer(1,2) girişi yapılmış..." 170 | ], 171 | "execution_count": 11, 172 | "outputs": [ 173 | { 174 | "output_type": "error", 175 | "ename": "ValueError", 176 | "evalue": "ignored", 177 | "traceback": [ 178 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", 179 | "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", 180 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mw\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mz\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mw\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mz\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;31m#3 değişken(w,y,z) tanımlanmış fakat 2 değer(1,2) girişi yapılmış...\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 181 | "\u001b[0;31mValueError\u001b[0m: not enough values to unpack (expected 3, got 2)" 182 | ] 183 | } 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "metadata": { 189 | "id": "XE4G4DttFcfG", 190 | "outputId": "79e20053-5997-49ca-d67e-3f52f474bbca", 191 | "colab": { 192 | "base_uri": "https://localhost:8080/", 193 | "height": 850 194 | } 195 | }, 196 | "source": [ 197 | "#Kompleks(karmaşık) Sayılar\n", 198 | "ksayi = 35.6 + 3.52j \n", 199 | "dir(ksayi)" 200 | ], 201 | "execution_count": null, 202 | "outputs": [ 203 | { 204 | "output_type": "execute_result", 205 | "data": { 206 | "text/plain": [ 207 | "['__abs__',\n", 208 | " '__add__',\n", 209 | " '__bool__',\n", 210 | " '__class__',\n", 211 | " '__delattr__',\n", 212 | " '__dir__',\n", 213 | " '__divmod__',\n", 214 | " '__doc__',\n", 215 | " '__eq__',\n", 216 | " '__float__',\n", 217 | " '__floordiv__',\n", 218 | " '__format__',\n", 219 | " '__ge__',\n", 220 | " '__getattribute__',\n", 221 | " '__getnewargs__',\n", 222 | " '__gt__',\n", 223 | " '__hash__',\n", 224 | " '__init__',\n", 225 | " '__init_subclass__',\n", 226 | " '__int__',\n", 227 | " '__le__',\n", 228 | " '__lt__',\n", 229 | " '__mod__',\n", 230 | " '__mul__',\n", 231 | " '__ne__',\n", 232 | " '__neg__',\n", 233 | " '__new__',\n", 234 | " '__pos__',\n", 235 | " '__pow__',\n", 236 | " '__radd__',\n", 237 | " '__rdivmod__',\n", 238 | " '__reduce__',\n", 239 | " '__reduce_ex__',\n", 240 | " '__repr__',\n", 241 | " '__rfloordiv__',\n", 242 | " '__rmod__',\n", 243 | " '__rmul__',\n", 244 | " '__rpow__',\n", 245 | " '__rsub__',\n", 246 | " '__rtruediv__',\n", 247 | " '__setattr__',\n", 248 | " '__sizeof__',\n", 249 | " '__str__',\n", 250 | " '__sub__',\n", 251 | " '__subclasshook__',\n", 252 | " '__truediv__',\n", 253 | " 'conjugate',\n", 254 | " 'imag',\n", 255 | " 'real']" 256 | ] 257 | }, 258 | "metadata": { 259 | "tags": [] 260 | }, 261 | "execution_count": 11 262 | } 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "metadata": { 268 | "id": "LIHPLBtyFrXi", 269 | "outputId": "a9d8906c-f91f-46df-84a1-2113bc64b867", 270 | "colab": { 271 | "base_uri": "https://localhost:8080/", 272 | "height": 68 273 | } 274 | }, 275 | "source": [ 276 | "ksayi = 14.5 + 7.02j\n", 277 | "print(\"Gerçek Bölüm: \",ksayi.real)\n", 278 | "print(\"Sanal Bölümü: \",ksayi.imag)\n", 279 | "print(type(ksayi))" 280 | ], 281 | "execution_count": 12, 282 | "outputs": [ 283 | { 284 | "output_type": "stream", 285 | "text": [ 286 | "Gerçek Bölüm: 14.5\n", 287 | "Sanal Bölümü: 7.02\n", 288 | "\n" 289 | ], 290 | "name": "stdout" 291 | } 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "metadata": { 297 | "id": "h8gtvOoiF2Eh", 298 | "outputId": "4a85cd5e-3734-45b4-a05d-95902cec5e86", 299 | "colab": { 300 | "base_uri": "https://localhost:8080/", 301 | "height": 85 302 | } 303 | }, 304 | "source": [ 305 | "deger1 = \"123\"#string\n", 306 | "print(deger1*3)\n", 307 | "print(deger1+deger1) #string + string\n", 308 | "deger2 = int(deger1)#convert.ToInt32(deger1) c# int\n", 309 | "print(deger2*3)\n", 310 | "print(deger2+deger2)#int + int" 311 | ], 312 | "execution_count": 14, 313 | "outputs": [ 314 | { 315 | "output_type": "stream", 316 | "text": [ 317 | "123123123\n", 318 | "123123\n", 319 | "369\n", 320 | "246\n" 321 | ], 322 | "name": "stdout" 323 | } 324 | ] 325 | }, 326 | { 327 | "cell_type": "markdown", 328 | "metadata": { 329 | "id": "DsMS7mr1D0gm" 330 | }, 331 | "source": [ 332 | "Python döngü ve karşılaştırma deyimlerinde vb. yapısal olarak tab boşlukları(indentation) kullanılır." 333 | ] 334 | }, 335 | { 336 | "cell_type": "code", 337 | "metadata": { 338 | "id": "zMCM1zLEDTOA", 339 | "outputId": "1b812654-74b5-47c9-db58-5e5026309d00", 340 | "colab": { 341 | "base_uri": "https://localhost:8080/", 342 | "height": 68 343 | } 344 | }, 345 | "source": [ 346 | "#a=1 ve b=2 olarak yukarıda tanımlanmıştı...\n", 347 | "if a > b: \n", 348 | " print(a)\n", 349 | " print('Eğer çalıştı...')\n", 350 | "else: \n", 351 | " print(b)\n", 352 | " print('Else çalıştı...')\n", 353 | " \n", 354 | "print('İşlem Tamam...')" 355 | ], 356 | "execution_count": 18, 357 | "outputs": [ 358 | { 359 | "output_type": "stream", 360 | "text": [ 361 | "2\n", 362 | "Else çalıştı...\n", 363 | "İşlem Tamam...\n" 364 | ], 365 | "name": "stdout" 366 | } 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "metadata": { 372 | "id": "Rf32ZOv0Ee26", 373 | "outputId": "9730e55b-14a6-47f3-f227-f00cf5639a75", 374 | "colab": { 375 | "base_uri": "https://localhost:8080/", 376 | "height": 51 377 | } 378 | }, 379 | "source": [ 380 | "i='123'\n", 381 | "if isinstance(i, int):\n", 382 | " i += 1 # i=i+1\n", 383 | "elif isinstance(i, str): #elif = else if kısaltması\n", 384 | " i = int(i) \n", 385 | " print('int çevirme işlemi başarılı...')\n", 386 | " i *= 2 #i=i*2\n", 387 | "print(i)" 388 | ], 389 | "execution_count": 30, 390 | "outputs": [ 391 | { 392 | "output_type": "stream", 393 | "text": [ 394 | "int çevirme işlemi başarılı...\n", 395 | "246\n" 396 | ], 397 | "name": "stdout" 398 | } 399 | ] 400 | }, 401 | { 402 | "cell_type": "code", 403 | "metadata": { 404 | "id": "UXYix5YzP-oj", 405 | "outputId": "460341a9-5530-4c77-8eef-e12c44684b1e", 406 | "colab": { 407 | "base_uri": "https://localhost:8080/", 408 | "height": 34 409 | } 410 | }, 411 | "source": [ 412 | "sayi=123\n", 413 | "metin=str(sayi) # int to str \n", 414 | "print(type(metin))" 415 | ], 416 | "execution_count": 31, 417 | "outputs": [ 418 | { 419 | "output_type": "stream", 420 | "text": [ 421 | "\n" 422 | ], 423 | "name": "stdout" 424 | } 425 | ] 426 | }, 427 | { 428 | "cell_type": "code", 429 | "metadata": { 430 | "id": "fM0FAWJxGWLb", 431 | "outputId": "6d02fdb8-1e8e-410a-beec-0e415a95a88f", 432 | "colab": { 433 | "base_uri": "https://localhost:8080/", 434 | "height": 34 435 | } 436 | }, 437 | "source": [ 438 | "x = None\n", 439 | "if x is None: #is özelliği \n", 440 | " print('İçerik Yok...')\n", 441 | "else:\n", 442 | " print('None değil...')" 443 | ], 444 | "execution_count": 27, 445 | "outputs": [ 446 | { 447 | "output_type": "stream", 448 | "text": [ 449 | "İçerik Yok...\n" 450 | ], 451 | "name": "stdout" 452 | } 453 | ] 454 | }, 455 | { 456 | "cell_type": "markdown", 457 | "metadata": { 458 | "id": "9ytqmKcCG6zC" 459 | }, 460 | "source": [ 461 | "List(LİSTELER)\n", 462 | "\n", 463 | "Listeler Python dilinde çok kullanılan yapılardır. Diğer dillerde kullanılan dizilere benzerler. Köşeli parantezler içerisine virgül(,) kullanılarak oluştururlar." 464 | ] 465 | }, 466 | { 467 | "cell_type": "code", 468 | "metadata": { 469 | "id": "leykYZ7bG9qJ" 470 | }, 471 | "source": [ 472 | "int_list = [1, 2, 3] \n", 473 | "string_list = ['abc', 'defghi']\n", 474 | "empty_list = []\n", 475 | "mixed_list = [1, 'abc', True, 2.34, None] # Farklı türdeki değişkenlerden oluşan liste..\n", 476 | "nested_list = [['a', 'b', 'c'], [1, 2, 3]]#İçiçe geçmiş listeler.." 477 | ], 478 | "execution_count": null, 479 | "outputs": [] 480 | }, 481 | { 482 | "cell_type": "code", 483 | "metadata": { 484 | "id": "XTlO8GWnHvxb", 485 | "outputId": "4d06c4fe-785a-4c56-c2fc-64657f0e0118", 486 | "colab": { 487 | "base_uri": "https://localhost:8080/", 488 | "height": 51 489 | } 490 | }, 491 | "source": [ 492 | "names = ['Özkan','Bünyamin','Esmanur','Gözde'] #liste adı names , liste 4 elemandan oluşan\n", 493 | "print(names[0])\n", 494 | "print(names[2])" 495 | ], 496 | "execution_count": 33, 497 | "outputs": [ 498 | { 499 | "output_type": "stream", 500 | "text": [ 501 | "Özkan\n", 502 | "Esmanur\n" 503 | ], 504 | "name": "stdout" 505 | } 506 | ] 507 | }, 508 | { 509 | "cell_type": "code", 510 | "metadata": { 511 | "id": "iyNDhUigH8t2", 512 | "outputId": "53a69cab-0c58-4968-87d0-39fca79153ae", 513 | "colab": { 514 | "base_uri": "https://localhost:8080/", 515 | "height": 85 516 | } 517 | }, 518 | "source": [ 519 | "print(names[-1]) # Listeyi tersten yazdırıyor..\n", 520 | "print(names[3])\n", 521 | "print(names[-3])\n", 522 | "print(names[1])" 523 | ], 524 | "execution_count": 37, 525 | "outputs": [ 526 | { 527 | "output_type": "stream", 528 | "text": [ 529 | "Gözde\n", 530 | "Gözde\n", 531 | "Bünyamin\n", 532 | "Bünyamin\n" 533 | ], 534 | "name": "stdout" 535 | } 536 | ] 537 | }, 538 | { 539 | "cell_type": "code", 540 | "metadata": { 541 | "id": "f8PPlzjPIEnW", 542 | "outputId": "a48e1ecf-09cd-456a-e355-779c693691ab", 543 | "colab": { 544 | "base_uri": "https://localhost:8080/", 545 | "height": 34 546 | } 547 | }, 548 | "source": [ 549 | "names[0] = 'Batu'\n", 550 | "print(names)" 551 | ], 552 | "execution_count": 38, 553 | "outputs": [ 554 | { 555 | "output_type": "stream", 556 | "text": [ 557 | "['Batu', 'Bünyamin', 'Esmanur', 'Gözde']\n" 558 | ], 559 | "name": "stdout" 560 | } 561 | ] 562 | }, 563 | { 564 | "cell_type": "code", 565 | "metadata": { 566 | "id": "8ooGOLgtINMD", 567 | "outputId": "00701324-7126-4dd4-9301-71a076c3c692", 568 | "colab": { 569 | "base_uri": "https://localhost:8080/", 570 | "height": 34 571 | } 572 | }, 573 | "source": [ 574 | "names.append('Okan') #Listeye eleman eklemek için...\n", 575 | "print(names)" 576 | ], 577 | "execution_count": null, 578 | "outputs": [ 579 | { 580 | "output_type": "stream", 581 | "text": [ 582 | "['Batu', 'Bünyamin', 'Esmanur', 'Gözde', 'Okan']\n" 583 | ], 584 | "name": "stdout" 585 | } 586 | ] 587 | }, 588 | { 589 | "cell_type": "code", 590 | "metadata": { 591 | "id": "7jwhtWZ5IdeD", 592 | "outputId": "a7007ff3-507a-4826-d7cf-812804c3d333", 593 | "colab": { 594 | "base_uri": "https://localhost:8080/", 595 | "height": 34 596 | } 597 | }, 598 | "source": [ 599 | "names.insert(1, 'Efe') #İstenilen indise eleman eklemek için \n", 600 | "print(names)" 601 | ], 602 | "execution_count": null, 603 | "outputs": [ 604 | { 605 | "output_type": "stream", 606 | "text": [ 607 | "['Batu', 'Efe', 'Bünyamin', 'Esmanur', 'Gözde', 'Okan']\n" 608 | ], 609 | "name": "stdout" 610 | } 611 | ] 612 | }, 613 | { 614 | "cell_type": "code", 615 | "metadata": { 616 | "id": "9TqfEnRmIoEX", 617 | "outputId": "e6205aa4-425f-4856-a025-08fc6822d115", 618 | "colab": { 619 | "base_uri": "https://localhost:8080/", 620 | "height": 34 621 | } 622 | }, 623 | "source": [ 624 | "names.remove(\"Okan\") #Listeden eleman çıkarmak için \n", 625 | "print(names) " 626 | ], 627 | "execution_count": null, 628 | "outputs": [ 629 | { 630 | "output_type": "stream", 631 | "text": [ 632 | "['Batu', 'Efe', 'Bünyamin', 'Esmanur', 'Gözde']\n" 633 | ], 634 | "name": "stdout" 635 | } 636 | ] 637 | }, 638 | { 639 | "cell_type": "code", 640 | "metadata": { 641 | "id": "y_fIrGQvI-Rn", 642 | "outputId": "b2b268c1-e064-4952-ce93-3d5778a76b48", 643 | "colab": { 644 | "base_uri": "https://localhost:8080/", 645 | "height": 34 646 | } 647 | }, 648 | "source": [ 649 | "names.index('Efe')" 650 | ], 651 | "execution_count": null, 652 | "outputs": [ 653 | { 654 | "output_type": "execute_result", 655 | "data": { 656 | "text/plain": [ 657 | "1" 658 | ] 659 | }, 660 | "metadata": { 661 | "tags": [] 662 | }, 663 | "execution_count": 32 664 | } 665 | ] 666 | }, 667 | { 668 | "cell_type": "code", 669 | "metadata": { 670 | "id": "k5wNuYo2JDcQ", 671 | "outputId": "7fb477a3-36f6-477f-96da-d2edfdb06a96", 672 | "colab": { 673 | "base_uri": "https://localhost:8080/", 674 | "height": 34 675 | } 676 | }, 677 | "source": [ 678 | "len(names) #Listenin uzunluğunu gösterir..." 679 | ], 680 | "execution_count": null, 681 | "outputs": [ 682 | { 683 | "output_type": "execute_result", 684 | "data": { 685 | "text/plain": [ 686 | "5" 687 | ] 688 | }, 689 | "metadata": { 690 | "tags": [] 691 | }, 692 | "execution_count": 33 693 | } 694 | ] 695 | }, 696 | { 697 | "cell_type": "code", 698 | "metadata": { 699 | "id": "Ulu-cIZAJK1u", 700 | "outputId": "fd181822-bc0d-4649-d023-ae2cc66ef283", 701 | "colab": { 702 | "base_uri": "https://localhost:8080/", 703 | "height": 34 704 | } 705 | }, 706 | "source": [ 707 | "aa = [1, 1, 1, 2, 3, 4] \n", 708 | "aa.count(1)" 709 | ], 710 | "execution_count": null, 711 | "outputs": [ 712 | { 713 | "output_type": "execute_result", 714 | "data": { 715 | "text/plain": [ 716 | "3" 717 | ] 718 | }, 719 | "metadata": { 720 | "tags": [] 721 | }, 722 | "execution_count": 34 723 | } 724 | ] 725 | }, 726 | { 727 | "cell_type": "code", 728 | "metadata": { 729 | "id": "9D-fqb8QJN1U", 730 | "outputId": "3ced4bf3-83dc-496a-8ac1-491b97e064d0", 731 | "colab": { 732 | "base_uri": "https://localhost:8080/", 733 | "height": 34 734 | } 735 | }, 736 | "source": [ 737 | "aa.reverse()\n", 738 | "print(aa)" 739 | ], 740 | "execution_count": null, 741 | "outputs": [ 742 | { 743 | "output_type": "stream", 744 | "text": [ 745 | "[4, 3, 2, 1, 1, 1]\n" 746 | ], 747 | "name": "stdout" 748 | } 749 | ] 750 | }, 751 | { 752 | "cell_type": "code", 753 | "metadata": { 754 | "id": "A8elC8zIJ6N6", 755 | "outputId": "b033d0fb-e641-4600-fb62-79f064a6c3cd", 756 | "colab": { 757 | "base_uri": "https://localhost:8080/", 758 | "height": 34 759 | } 760 | }, 761 | "source": [ 762 | "aa.sort()\n", 763 | "print(aa)" 764 | ], 765 | "execution_count": null, 766 | "outputs": [ 767 | { 768 | "output_type": "stream", 769 | "text": [ 770 | "[1, 1, 1, 2, 3, 4]\n" 771 | ], 772 | "name": "stdout" 773 | } 774 | ] 775 | }, 776 | { 777 | "cell_type": "code", 778 | "metadata": { 779 | "id": "3LlNoc8dWQua", 780 | "outputId": "6106cb04-e070-4743-f29c-af7356210663", 781 | "colab": { 782 | "base_uri": "https://localhost:8080/", 783 | "height": 34 784 | } 785 | }, 786 | "source": [ 787 | "sira=[234,123,356,345]#liste tanımlandı\n", 788 | "sira.sort()#küçükten büyüğe sıralandı.\n", 789 | "sira.reverse()#Liste ters çevrildi. Büyükten küçüğe haline geldi.\n", 790 | "print(sira)" 791 | ], 792 | "execution_count": 41, 793 | "outputs": [ 794 | { 795 | "output_type": "stream", 796 | "text": [ 797 | "[356, 345, 234, 123]\n" 798 | ], 799 | "name": "stdout" 800 | } 801 | ] 802 | }, 803 | { 804 | "cell_type": "code", 805 | "metadata": { 806 | "id": "-qv3d-IDXQOq", 807 | "outputId": "a83c5394-bf03-42c6-8740-f4cc4b94a73c", 808 | "colab": { 809 | "base_uri": "https://localhost:8080/", 810 | "height": 85 811 | } 812 | }, 813 | "source": [ 814 | "for eleman in sira:\n", 815 | " print(eleman)" 816 | ], 817 | "execution_count": 42, 818 | "outputs": [ 819 | { 820 | "output_type": "stream", 821 | "text": [ 822 | "356\n", 823 | "345\n", 824 | "234\n", 825 | "123\n" 826 | ], 827 | "name": "stdout" 828 | } 829 | ] 830 | }, 831 | { 832 | "cell_type": "code", 833 | "metadata": { 834 | "id": "nGdoalP3KFjb", 835 | "outputId": "be707114-dde6-4576-e8e4-2396e6c37368", 836 | "colab": { 837 | "base_uri": "https://localhost:8080/", 838 | "height": 799 839 | } 840 | }, 841 | "source": [ 842 | "dir(aa)" 843 | ], 844 | "execution_count": null, 845 | "outputs": [ 846 | { 847 | "output_type": "execute_result", 848 | "data": { 849 | "text/plain": [ 850 | "['__add__',\n", 851 | " '__class__',\n", 852 | " '__contains__',\n", 853 | " '__delattr__',\n", 854 | " '__delitem__',\n", 855 | " '__dir__',\n", 856 | " '__doc__',\n", 857 | " '__eq__',\n", 858 | " '__format__',\n", 859 | " '__ge__',\n", 860 | " '__getattribute__',\n", 861 | " '__getitem__',\n", 862 | " '__gt__',\n", 863 | " '__hash__',\n", 864 | " '__iadd__',\n", 865 | " '__imul__',\n", 866 | " '__init__',\n", 867 | " '__init_subclass__',\n", 868 | " '__iter__',\n", 869 | " '__le__',\n", 870 | " '__len__',\n", 871 | " '__lt__',\n", 872 | " '__mul__',\n", 873 | " '__ne__',\n", 874 | " '__new__',\n", 875 | " '__reduce__',\n", 876 | " '__reduce_ex__',\n", 877 | " '__repr__',\n", 878 | " '__reversed__',\n", 879 | " '__rmul__',\n", 880 | " '__setattr__',\n", 881 | " '__setitem__',\n", 882 | " '__sizeof__',\n", 883 | " '__str__',\n", 884 | " '__subclasshook__',\n", 885 | " 'append',\n", 886 | " 'clear',\n", 887 | " 'copy',\n", 888 | " 'count',\n", 889 | " 'extend',\n", 890 | " 'index',\n", 891 | " 'insert',\n", 892 | " 'pop',\n", 893 | " 'remove',\n", 894 | " 'reverse',\n", 895 | " 'sort']" 896 | ] 897 | }, 898 | "metadata": { 899 | "tags": [] 900 | }, 901 | "execution_count": 45 902 | } 903 | ] 904 | }, 905 | { 906 | "cell_type": "code", 907 | "metadata": { 908 | "id": "RHE40ImrKnVZ", 909 | "outputId": "b4f57eb5-9f34-47db-cd05-a558b769641e", 910 | "colab": { 911 | "base_uri": "https://localhost:8080/", 912 | "height": 34 913 | } 914 | }, 915 | "source": [ 916 | "#Demetler (tuple)\n", 917 | "demet = (1,2,3,4) \n", 918 | "print(type(demet))" 919 | ], 920 | "execution_count": null, 921 | "outputs": [ 922 | { 923 | "output_type": "stream", 924 | "text": [ 925 | "\n" 926 | ], 927 | "name": "stdout" 928 | } 929 | ] 930 | }, 931 | { 932 | "cell_type": "code", 933 | "metadata": { 934 | "id": "hpWRh30tK0ke", 935 | "outputId": "ec08d461-1cf1-4343-fb7c-dba9716af3a0", 936 | "colab": { 937 | "base_uri": "https://localhost:8080/", 938 | "height": 34 939 | } 940 | }, 941 | "source": [ 942 | " demet = (\"a\",\"b\",\"c\") \n", 943 | " d = demet + demet \n", 944 | " print(d)" 945 | ], 946 | "execution_count": null, 947 | "outputs": [ 948 | { 949 | "output_type": "stream", 950 | "text": [ 951 | "('a', 'b', 'c', 'a', 'b', 'c')\n" 952 | ], 953 | "name": "stdout" 954 | } 955 | ] 956 | }, 957 | { 958 | "cell_type": "code", 959 | "metadata": { 960 | "id": "5NMIwcdRK54F", 961 | "outputId": "13154310-1df5-48c5-8b0c-7193a062df8b", 962 | "colab": { 963 | "base_uri": "https://localhost:8080/", 964 | "height": 34 965 | } 966 | }, 967 | "source": [ 968 | "print(d[2:5])" 969 | ], 970 | "execution_count": null, 971 | "outputs": [ 972 | { 973 | "output_type": "stream", 974 | "text": [ 975 | "('c', 'a', 'b')\n" 976 | ], 977 | "name": "stdout" 978 | } 979 | ] 980 | } 981 | ] 982 | } --------------------------------------------------------------------------------