├── DERS - 10 .ipynb
├── DERS - 15.ipynb
├── DERS - 9.ipynb
├── DERS -11.ipynb
├── DERS 12 .ipynb
├── DERS 13.ipynb
├── DERS 16.ipynb
├── DERS 8 .ipynb
├── DERS NOTU - 3.ipynb
├── DERS-14.ipynb
├── Ders 7 - Notu.ipynb
├── Ders Notu 4.ipynb
├── Ders-5.ipynb
├── Ders-6.ipynb
├── DersNotu-1.ipynb
├── DersNotu-2.ipynb
└── README.md
/DERS - 10 .ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 10"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# Mantıksal Değerler ve Karşılaştırma Operatörleri"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "### Mantıksal Değerler (Boolean)\n",
22 | "\n",
23 | "Mantıksal değerler ya da ingilizce ismiyle *boolean* değerler iki değere sahiplerdir: **True ve False**.\n",
24 | "\n"
25 | ]
26 | },
27 | {
28 | "cell_type": "markdown",
29 | "metadata": {},
30 | "source": [
31 | "### Karşılaştırma Operatörleri \n",
32 | "\n",
33 | "\n",
34 | "\n",
35 | "\n",
36 | "\n",
37 | "\n",
38 | "\n",
39 | "\n",
40 | "\n",
41 | "
\n",
42 | "\n",
43 | "Operatör | Görevi | Örnek | \n",
44 | "
\n",
45 | "\n",
46 | "== | \n",
47 | "İki değer birbirine eşitse True, değilse False değer döner. | \n",
48 | " 2 == 2 (True) , 2 == 3 (False) | \n",
49 | "
\n",
50 | "\n",
51 | "!= | \n",
52 | "İki değer birbirine eşit değilse True, diğer durumda False döner. | \n",
53 | "2 != 2 (False), 2 != 3 (True) | \n",
54 | "
\n",
55 | "\n",
56 | "> | \n",
57 | "Soldaki değer sağdaki değerden büyükse True, değilse False döner. | \n",
58 | " 3 > 2 (True), 2 > 3 (False) | \n",
59 | "
\n",
60 | "\n",
61 | "< | \n",
62 | "Soldaki değer sağdaki değerden küçükse True, değilse False döner. | \n",
63 | " 2 < 3 (True) , 3 < 2 (False) | \n",
64 | "
\n",
65 | "\n",
66 | ">= | \n",
67 | "Soldaki değer sağdaki değerden büyükse veya sağdaki değere eşitse True, değilse False döner. | \n",
68 | " 3 >= 2 (True),3 >= 3 (True) , 2 >= 3 (False) | \n",
69 | "
\n",
70 | "\n",
71 | "<= | \n",
72 | "Soldaki değer sağdaki değerden küçükse veya sağdaki değere eşitse True, değilse False döner. | \n",
73 | " 3 <= 2 (False),3 <= 3 (True) , 2 <= 3 (True) | \n",
74 | "
\n",
75 | "
"
76 | ]
77 | },
78 | {
79 | "cell_type": "code",
80 | "execution_count": 1,
81 | "metadata": {},
82 | "outputs": [
83 | {
84 | "data": {
85 | "text/plain": [
86 | "True"
87 | ]
88 | },
89 | "execution_count": 1,
90 | "metadata": {},
91 | "output_type": "execute_result"
92 | }
93 | ],
94 | "source": [
95 | "\"Hatice\" == \"Hatice\""
96 | ]
97 | },
98 | {
99 | "cell_type": "code",
100 | "execution_count": 2,
101 | "metadata": {},
102 | "outputs": [
103 | {
104 | "data": {
105 | "text/plain": [
106 | "True"
107 | ]
108 | },
109 | "execution_count": 2,
110 | "metadata": {},
111 | "output_type": "execute_result"
112 | }
113 | ],
114 | "source": [
115 | "25 == 25"
116 | ]
117 | },
118 | {
119 | "cell_type": "code",
120 | "execution_count": 3,
121 | "metadata": {},
122 | "outputs": [
123 | {
124 | "data": {
125 | "text/plain": [
126 | "False"
127 | ]
128 | },
129 | "execution_count": 3,
130 | "metadata": {},
131 | "output_type": "execute_result"
132 | }
133 | ],
134 | "source": [
135 | "\"Hatice\" == \"Candan\""
136 | ]
137 | },
138 | {
139 | "cell_type": "code",
140 | "execution_count": 3,
141 | "metadata": {},
142 | "outputs": [
143 | {
144 | "data": {
145 | "text/plain": [
146 | "True"
147 | ]
148 | },
149 | "execution_count": 3,
150 | "metadata": {},
151 | "output_type": "execute_result"
152 | }
153 | ],
154 | "source": [
155 | "\"Hatice\" != \"Candan\" #Hatice, Candan 'a eşit değildir (DOĞRU)"
156 | ]
157 | },
158 | {
159 | "cell_type": "code",
160 | "execution_count": 5,
161 | "metadata": {},
162 | "outputs": [
163 | {
164 | "data": {
165 | "text/plain": [
166 | "False"
167 | ]
168 | },
169 | "execution_count": 5,
170 | "metadata": {},
171 | "output_type": "execute_result"
172 | }
173 | ],
174 | "source": [
175 | "\"Hatice\" < \"Candan\" # Alfabetik olarak bakılır, C harfi H den önce geldiği için false cevabı döner"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": 6,
181 | "metadata": {},
182 | "outputs": [
183 | {
184 | "data": {
185 | "text/plain": [
186 | "True"
187 | ]
188 | },
189 | "execution_count": 6,
190 | "metadata": {},
191 | "output_type": "execute_result"
192 | }
193 | ],
194 | "source": [
195 | "2 < 3"
196 | ]
197 | },
198 | {
199 | "cell_type": "code",
200 | "execution_count": 7,
201 | "metadata": {},
202 | "outputs": [
203 | {
204 | "data": {
205 | "text/plain": [
206 | "True"
207 | ]
208 | },
209 | "execution_count": 7,
210 | "metadata": {},
211 | "output_type": "execute_result"
212 | }
213 | ],
214 | "source": [
215 | "54 >= 54"
216 | ]
217 | },
218 | {
219 | "cell_type": "code",
220 | "execution_count": 8,
221 | "metadata": {},
222 | "outputs": [
223 | {
224 | "data": {
225 | "text/plain": [
226 | "True"
227 | ]
228 | },
229 | "execution_count": 8,
230 | "metadata": {},
231 | "output_type": "execute_result"
232 | }
233 | ],
234 | "source": [
235 | "98 > 32"
236 | ]
237 | },
238 | {
239 | "cell_type": "code",
240 | "execution_count": 9,
241 | "metadata": {},
242 | "outputs": [
243 | {
244 | "data": {
245 | "text/plain": [
246 | "True"
247 | ]
248 | },
249 | "execution_count": 9,
250 | "metadata": {},
251 | "output_type": "execute_result"
252 | }
253 | ],
254 | "source": [
255 | "34 <= 45"
256 | ]
257 | },
258 | {
259 | "cell_type": "markdown",
260 | "metadata": {
261 | "collapsed": true
262 | },
263 | "source": [
264 | "# Mantıksal Bağlaçlar\n",
265 | "\n",
266 | "\n",
267 | "### and Operatörü"
268 | ]
269 | },
270 | {
271 | "cell_type": "markdown",
272 | "metadata": {},
273 | "source": [
274 | "\n",
275 | "and Operatörü, bütün karşılaştırma işlemlerinin sonucunun **True** olmasına bakar. Karşılaştırma işlemlerinin hepsinin sonucu **True** ise genel sonuç **True** , bir tanesi bile False ise sonuç **False** döner "
276 | ]
277 | },
278 | {
279 | "cell_type": "code",
280 | "execution_count": 10,
281 | "metadata": {},
282 | "outputs": [
283 | {
284 | "data": {
285 | "text/plain": [
286 | "True"
287 | ]
288 | },
289 | "execution_count": 10,
290 | "metadata": {},
291 | "output_type": "execute_result"
292 | }
293 | ],
294 | "source": [
295 | "1 < 2 and \"Hatice\" == \"Hatice\" # HER İKİ TARAF DA EVET İSE YANİ DOĞRU İSE AND OPERATÖRÜ TRUE (EVET) DÖNDÜRÜR "
296 | ]
297 | },
298 | {
299 | "cell_type": "code",
300 | "execution_count": 11,
301 | "metadata": {},
302 | "outputs": [
303 | {
304 | "data": {
305 | "text/plain": [
306 | "False"
307 | ]
308 | },
309 | "execution_count": 11,
310 | "metadata": {},
311 | "output_type": "execute_result"
312 | }
313 | ],
314 | "source": [
315 | "2 > 3 and \"Hatice\" == \"Hatice\""
316 | ]
317 | },
318 | {
319 | "cell_type": "code",
320 | "execution_count": 12,
321 | "metadata": {},
322 | "outputs": [
323 | {
324 | "data": {
325 | "text/plain": [
326 | "False"
327 | ]
328 | },
329 | "execution_count": 12,
330 | "metadata": {},
331 | "output_type": "execute_result"
332 | }
333 | ],
334 | "source": [
335 | "2 == 2 and 3.14 < 2.54 and \"Elma\" != \"Armut\""
336 | ]
337 | },
338 | {
339 | "cell_type": "markdown",
340 | "metadata": {},
341 | "source": [
342 | "İşlemlerin birinin bile sonucu **False** ise genel işlemin sonucu **False** çıkar"
343 | ]
344 | },
345 | {
346 | "cell_type": "markdown",
347 | "metadata": {},
348 | "source": [
349 | "### or Operatörü\n",
350 | "or Operatörü, karşılaştırma işlemlerinin sonuçlarından **en az birinin True** olmasını bekler eğer **en az biri True** ise genel sonuç **True** , değilse **False** olarak döner."
351 | ]
352 | },
353 | {
354 | "cell_type": "code",
355 | "execution_count": 13,
356 | "metadata": {},
357 | "outputs": [
358 | {
359 | "data": {
360 | "text/plain": [
361 | "True"
362 | ]
363 | },
364 | "execution_count": 13,
365 | "metadata": {},
366 | "output_type": "execute_result"
367 | }
368 | ],
369 | "source": [
370 | "1 < 2 or \"Hatice\" != \"Hatice\""
371 | ]
372 | },
373 | {
374 | "cell_type": "code",
375 | "execution_count": 14,
376 | "metadata": {},
377 | "outputs": [
378 | {
379 | "data": {
380 | "text/plain": [
381 | "False"
382 | ]
383 | },
384 | "execution_count": 14,
385 | "metadata": {},
386 | "output_type": "execute_result"
387 | }
388 | ],
389 | "source": [
390 | "2 > 3 or \"Hatice\" != \"Hatice\""
391 | ]
392 | },
393 | {
394 | "cell_type": "code",
395 | "execution_count": 15,
396 | "metadata": {},
397 | "outputs": [
398 | {
399 | "data": {
400 | "text/plain": [
401 | "True"
402 | ]
403 | },
404 | "execution_count": 15,
405 | "metadata": {},
406 | "output_type": "execute_result"
407 | }
408 | ],
409 | "source": [
410 | "2 > 3 or \"Hatice\" != \"Haticet\" or 5.9 < 17"
411 | ]
412 | },
413 | {
414 | "cell_type": "markdown",
415 | "metadata": {},
416 | "source": [
417 | "### not operatörü\n",
418 | "\n",
419 | "*not* operatörü aslında bir mantıksal bağlaç değildir, sadece karşılaştırma işlemininin sonucunu tam tersi sonuca çevirir. Yani, \n",
420 | "- **True** olan bir sonucu **False** , \n",
421 | "- **False** olan bir sonucu **True** sonucuna çevirir. "
422 | ]
423 | },
424 | {
425 | "cell_type": "code",
426 | "execution_count": 16,
427 | "metadata": {},
428 | "outputs": [
429 | {
430 | "data": {
431 | "text/plain": [
432 | "False"
433 | ]
434 | },
435 | "execution_count": 16,
436 | "metadata": {},
437 | "output_type": "execute_result"
438 | }
439 | ],
440 | "source": [
441 | "not 2 == 2"
442 | ]
443 | },
444 | {
445 | "cell_type": "code",
446 | "execution_count": 17,
447 | "metadata": {},
448 | "outputs": [
449 | {
450 | "data": {
451 | "text/plain": [
452 | "True"
453 | ]
454 | },
455 | "execution_count": 17,
456 | "metadata": {},
457 | "output_type": "execute_result"
458 | }
459 | ],
460 | "source": [
461 | "not \"Python\" == \"Php\""
462 | ]
463 | },
464 | {
465 | "cell_type": "markdown",
466 | "metadata": {},
467 | "source": [
468 | "### Operatörleri Beraber Kullanma\n"
469 | ]
470 | },
471 | {
472 | "cell_type": "code",
473 | "execution_count": 18,
474 | "metadata": {},
475 | "outputs": [
476 | {
477 | "data": {
478 | "text/plain": [
479 | "True"
480 | ]
481 | },
482 | "execution_count": 18,
483 | "metadata": {},
484 | "output_type": "execute_result"
485 | }
486 | ],
487 | "source": [
488 | "not (2.14 > 3.49 or ( 2 != 2 and \"Hatice\" == \"Hatice\"))"
489 | ]
490 | },
491 | {
492 | "cell_type": "code",
493 | "execution_count": 20,
494 | "metadata": {},
495 | "outputs": [
496 | {
497 | "data": {
498 | "text/plain": [
499 | "True"
500 | ]
501 | },
502 | "execution_count": 20,
503 | "metadata": {},
504 | "output_type": "execute_result"
505 | }
506 | ],
507 | "source": [
508 | "\"Aylin\" < \"Zehra\" and ( \"Bebek\" < \"Çoçuk\" or (not 28 ))"
509 | ]
510 | },
511 | {
512 | "cell_type": "markdown",
513 | "metadata": {},
514 | "source": [
515 | "## ÖDEV 10\n",
516 | "\n",
517 | "DERS NOTUNA ÇALIŞINIZ :)"
518 | ]
519 | },
520 | {
521 | "cell_type": "code",
522 | "execution_count": null,
523 | "metadata": {},
524 | "outputs": [],
525 | "source": []
526 | }
527 | ],
528 | "metadata": {
529 | "kernelspec": {
530 | "display_name": "Python 3",
531 | "language": "python",
532 | "name": "python3"
533 | },
534 | "language_info": {
535 | "codemirror_mode": {
536 | "name": "ipython",
537 | "version": 3
538 | },
539 | "file_extension": ".py",
540 | "mimetype": "text/x-python",
541 | "name": "python",
542 | "nbconvert_exporter": "python",
543 | "pygments_lexer": "ipython3",
544 | "version": "3.7.3"
545 | }
546 | },
547 | "nbformat": 4,
548 | "nbformat_minor": 2
549 | }
550 |
--------------------------------------------------------------------------------
/DERS - 15.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 15\n"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# DÖNGÜLER "
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "### FOR DÖNGÜLERİ"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "For döngüsünü anlayabilmek için **in operatörünü** öğrenmemiz gerekmektedir. \n",
29 | "\n",
30 | "#### in operatörü \n",
31 | "\n",
32 | "Bir elemanın başka bir listede,demette veya stringte (karakter dizileri) bulunup bulunmadığını kontrol eder. "
33 | ]
34 | },
35 | {
36 | "cell_type": "code",
37 | "execution_count": 1,
38 | "metadata": {},
39 | "outputs": [
40 | {
41 | "data": {
42 | "text/plain": [
43 | "True"
44 | ]
45 | },
46 | "execution_count": 1,
47 | "metadata": {},
48 | "output_type": "execute_result"
49 | }
50 | ],
51 | "source": [
52 | "\"a\" in \"merhaba\" #merhaba stringinin içinde a karakteri varsa TRUE döndürür."
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": 2,
58 | "metadata": {},
59 | "outputs": [
60 | {
61 | "data": {
62 | "text/plain": [
63 | "True"
64 | ]
65 | },
66 | "execution_count": 2,
67 | "metadata": {},
68 | "output_type": "execute_result"
69 | }
70 | ],
71 | "source": [
72 | "\"ha\" in \"merhaba\""
73 | ]
74 | },
75 | {
76 | "cell_type": "code",
77 | "execution_count": 3,
78 | "metadata": {},
79 | "outputs": [
80 | {
81 | "data": {
82 | "text/plain": [
83 | "False"
84 | ]
85 | },
86 | "execution_count": 3,
87 | "metadata": {},
88 | "output_type": "execute_result"
89 | }
90 | ],
91 | "source": [
92 | "\"z\" in \"merhaba\""
93 | ]
94 | },
95 | {
96 | "cell_type": "code",
97 | "execution_count": 4,
98 | "metadata": {},
99 | "outputs": [
100 | {
101 | "data": {
102 | "text/plain": [
103 | "True"
104 | ]
105 | },
106 | "execution_count": 4,
107 | "metadata": {},
108 | "output_type": "execute_result"
109 | }
110 | ],
111 | "source": [
112 | "2 in [1,2,3,4,5,6,7]"
113 | ]
114 | },
115 | {
116 | "cell_type": "code",
117 | "execution_count": 5,
118 | "metadata": {},
119 | "outputs": [
120 | {
121 | "data": {
122 | "text/plain": [
123 | "False"
124 | ]
125 | },
126 | "execution_count": 5,
127 | "metadata": {},
128 | "output_type": "execute_result"
129 | }
130 | ],
131 | "source": [
132 | "10 in [1,2,3,4,5,6,7]"
133 | ]
134 | },
135 | {
136 | "cell_type": "code",
137 | "execution_count": 6,
138 | "metadata": {},
139 | "outputs": [
140 | {
141 | "data": {
142 | "text/plain": [
143 | "False"
144 | ]
145 | },
146 | "execution_count": 6,
147 | "metadata": {},
148 | "output_type": "execute_result"
149 | }
150 | ],
151 | "source": [
152 | "10 in (1,2,3,4,5,6,7)"
153 | ]
154 | },
155 | {
156 | "cell_type": "markdown",
157 | "metadata": {},
158 | "source": [
159 | "### for Döngüsü\n",
160 | "\n",
161 | "for Döngüsü ; stringlerin,listelerin ,demetlerin ve sözlüklerin üzerinde dolaşmamızı sağlayan bir döngü türüdür.\n",
162 | "\n",
163 | " for eleman in veri :\n",
164 | " Yapılacak İşlemler"
165 | ]
166 | },
167 | {
168 | "cell_type": "code",
169 | "execution_count": 7,
170 | "metadata": {},
171 | "outputs": [
172 | {
173 | "name": "stdout",
174 | "output_type": "stream",
175 | "text": [
176 | "1\n",
177 | "2\n",
178 | "3\n",
179 | "4\n",
180 | "5\n",
181 | "6\n",
182 | "7\n",
183 | "8\n",
184 | "9\n",
185 | "10\n"
186 | ]
187 | }
188 | ],
189 | "source": [
190 | "#liste elemanlarını ekrana tek tek yazdıralım\n",
191 | "liste = [1,2,3,4,5,6,7,8,9,10]\n",
192 | "\n",
193 | "#liste elemanlarını ekrana yazdırmak için tek tek indeksleriyle beraber yazdırmamız gerekiyor. \n",
194 | "print(liste[0])\n",
195 | "print(liste[1])\n",
196 | "print(liste[2])\n",
197 | "print(liste[3])\n",
198 | "print(liste[4])\n",
199 | "print(liste[5])\n",
200 | "print(liste[6])\n",
201 | "print(liste[7])\n",
202 | "print(liste[8])\n",
203 | "print(liste[9])\n"
204 | ]
205 | },
206 | {
207 | "cell_type": "markdown",
208 | "metadata": {},
209 | "source": [
210 | "Ne kadar uzun ve zahmetli oldu bu satırları yazmak öyle değil mi? \n",
211 | "Hem hataya çok açık hem de zaman kaybı.\n",
212 | "\n",
213 | "**for döngüsü** ile bunu tek satırda yazmak mümkün "
214 | ]
215 | },
216 | {
217 | "cell_type": "code",
218 | "execution_count": 8,
219 | "metadata": {},
220 | "outputs": [
221 | {
222 | "name": "stdout",
223 | "output_type": "stream",
224 | "text": [
225 | "1\n",
226 | "2\n",
227 | "3\n",
228 | "4\n",
229 | "5\n",
230 | "6\n",
231 | "7\n",
232 | "8\n",
233 | "9\n",
234 | "10\n"
235 | ]
236 | }
237 | ],
238 | "source": [
239 | "#LİSTELERİN ÜZERİNDE FOR DÖNGÜSÜ\n",
240 | "\n",
241 | "#liste elemanlarını ekrana tek tek yazdıralım\n",
242 | "liste = [1,2,3,4,5,6,7,8,9,10]\n",
243 | "\n",
244 | "for eleman in liste:\n",
245 | " print(eleman)"
246 | ]
247 | },
248 | {
249 | "cell_type": "code",
250 | "execution_count": 9,
251 | "metadata": {},
252 | "outputs": [
253 | {
254 | "name": "stdout",
255 | "output_type": "stream",
256 | "text": [
257 | "Toplam 55\n"
258 | ]
259 | }
260 | ],
261 | "source": [
262 | "# Liste elemanlarını kümülatif olarak toplayalım\n",
263 | "liste = [1,2,3,4,5,6,7,8,9,10]\n",
264 | "toplam = 0\n",
265 | "for eleman in liste:\n",
266 | " toplam += eleman\n",
267 | "print(\"Toplam\",toplam)"
268 | ]
269 | },
270 | {
271 | "cell_type": "code",
272 | "execution_count": 10,
273 | "metadata": {},
274 | "outputs": [
275 | {
276 | "name": "stdout",
277 | "output_type": "stream",
278 | "text": [
279 | "2\n",
280 | "4\n",
281 | "6\n",
282 | "8\n",
283 | "10\n"
284 | ]
285 | }
286 | ],
287 | "source": [
288 | "# Listedeki çift elemanları ekrana yazdıralım \n",
289 | "liste = [1,2,3,4,5,6,7,8,9,10]\n",
290 | "\n",
291 | "for eleman in liste:\n",
292 | " if eleman % 2 == 0:\n",
293 | " print(eleman)"
294 | ]
295 | },
296 | {
297 | "cell_type": "code",
298 | "execution_count": 11,
299 | "metadata": {},
300 | "outputs": [
301 | {
302 | "name": "stdout",
303 | "output_type": "stream",
304 | "text": [
305 | "P\n",
306 | "y\n",
307 | "t\n",
308 | "h\n",
309 | "o\n",
310 | "n\n"
311 | ]
312 | }
313 | ],
314 | "source": [
315 | "# STRINGLERIN ÜZERİNDE FOR DÖNGÜSÜ\n",
316 | "#stringdeki her bir elemanı ekrana yazdıralım\n",
317 | "kelime = \"Python\"\n",
318 | "for karakter in kelime:\n",
319 | " print(karakter)"
320 | ]
321 | },
322 | {
323 | "cell_type": "code",
324 | "execution_count": 12,
325 | "metadata": {},
326 | "outputs": [
327 | {
328 | "name": "stdout",
329 | "output_type": "stream",
330 | "text": [
331 | "1\n",
332 | "2\n",
333 | "3\n",
334 | "4\n",
335 | "5\n"
336 | ]
337 | }
338 | ],
339 | "source": [
340 | "# DEMETLERİN ÜZERİNDE FOR DÖNGÜSÜ\n",
341 | "#demetteki her bir elemanı ekrana yazdıralım\n",
342 | "demet = (1,2,3,4,5)\n",
343 | "\n",
344 | "for eleman in demet:\n",
345 | " print(eleman)"
346 | ]
347 | },
348 | {
349 | "cell_type": "code",
350 | "execution_count": 13,
351 | "metadata": {},
352 | "outputs": [
353 | {
354 | "name": "stdout",
355 | "output_type": "stream",
356 | "text": [
357 | "(1, 2)\n",
358 | "(3, 4)\n",
359 | "(5, 6)\n",
360 | "(7, 8)\n"
361 | ]
362 | }
363 | ],
364 | "source": [
365 | "# Liste içindeki demetleri ekrana yazdıralım. \n",
366 | "\n",
367 | "liste = [(1,2),(3,4),(5,6),(7,8)]\n",
368 | "\n",
369 | "for eleman in liste:\n",
370 | " print(eleman) "
371 | ]
372 | },
373 | {
374 | "cell_type": "code",
375 | "execution_count": 14,
376 | "metadata": {},
377 | "outputs": [
378 | {
379 | "name": "stdout",
380 | "output_type": "stream",
381 | "text": [
382 | "bir\n",
383 | "iki\n",
384 | "üç\n",
385 | "dört\n"
386 | ]
387 | }
388 | ],
389 | "source": [
390 | "# SÖZLÜKLERİN ÜZERİNDE FOR DÖNGÜSÜ\n",
391 | "# sözlük içindeki anahtarları ekrana yazdıralım. \n",
392 | "sözlük = {\"bir\":1,\"iki\":2,\"üç\":3,\"dört\":4}\n",
393 | "\n",
394 | "for eleman in sözlük:\n",
395 | " print(eleman)"
396 | ]
397 | },
398 | {
399 | "cell_type": "code",
400 | "execution_count": 15,
401 | "metadata": {},
402 | "outputs": [
403 | {
404 | "name": "stdout",
405 | "output_type": "stream",
406 | "text": [
407 | "bir\n",
408 | "iki\n",
409 | "üç\n",
410 | "dört\n"
411 | ]
412 | }
413 | ],
414 | "source": [
415 | "#aynı işlemi keys() methodu ile de yazdırabiliriz. \n",
416 | "sözlük = {\"bir\":1,\"iki\":2,\"üç\":3,\"dört\":4}\n",
417 | "\n",
418 | "for eleman in sözlük.keys():\n",
419 | " print(eleman)"
420 | ]
421 | },
422 | {
423 | "cell_type": "code",
424 | "execution_count": 16,
425 | "metadata": {},
426 | "outputs": [
427 | {
428 | "name": "stdout",
429 | "output_type": "stream",
430 | "text": [
431 | "1\n",
432 | "2\n",
433 | "3\n",
434 | "4\n"
435 | ]
436 | }
437 | ],
438 | "source": [
439 | "# sözlük içindeki values (değerleri) ekrana yazdıralım. \n",
440 | "sözlük = {\"bir\":1,\"iki\":2,\"üç\":3,\"dört\":4}\n",
441 | "\n",
442 | "for eleman in sözlük.values():\n",
443 | " print(eleman)"
444 | ]
445 | },
446 | {
447 | "cell_type": "markdown",
448 | "metadata": {},
449 | "source": [
450 | "## UYGULAMA 1\n",
451 | "\n",
452 | "liste = [2,5,9,6,3,8,5]\n",
453 | "\n",
454 | "liste içindeki her bir elemanın karesini alıp ekrana yazdıran programı yazınız. "
455 | ]
456 | },
457 | {
458 | "cell_type": "code",
459 | "execution_count": 29,
460 | "metadata": {},
461 | "outputs": [
462 | {
463 | "name": "stdout",
464 | "output_type": "stream",
465 | "text": [
466 | "4\n",
467 | "25\n",
468 | "81\n",
469 | "36\n",
470 | "9\n",
471 | "64\n",
472 | "25\n"
473 | ]
474 | }
475 | ],
476 | "source": [
477 | "liste = [2,5,9,6,3,8,5]\n",
478 | "\n",
479 | "for a in liste:\n",
480 | " print(a**2)"
481 | ]
482 | },
483 | {
484 | "cell_type": "code",
485 | "execution_count": 33,
486 | "metadata": {},
487 | "outputs": [
488 | {
489 | "data": {
490 | "text/plain": [
491 | "[4, 25, 81, 36, 9, 64, 25]"
492 | ]
493 | },
494 | "execution_count": 33,
495 | "metadata": {},
496 | "output_type": "execute_result"
497 | }
498 | ],
499 | "source": [
500 | "#karelerini başka bir listeye atayalım.\n",
501 | "liste = [2,5,9,6,3,8,5]\n",
502 | "i=0\n",
503 | "for a in liste:\n",
504 | " liste[i]=(a**2)\n",
505 | " i+=1\n",
506 | "liste"
507 | ]
508 | },
509 | {
510 | "cell_type": "markdown",
511 | "metadata": {},
512 | "source": [
513 | "## UYGULAMA 2"
514 | ]
515 | },
516 | {
517 | "cell_type": "markdown",
518 | "metadata": {},
519 | "source": [
520 | "**a) 1-10 Arası Sayıları Ekranda Listeleyen Python kodunu yazınız.** "
521 | ]
522 | },
523 | {
524 | "cell_type": "code",
525 | "execution_count": 36,
526 | "metadata": {},
527 | "outputs": [
528 | {
529 | "name": "stdout",
530 | "output_type": "stream",
531 | "text": [
532 | "1\n",
533 | "2\n",
534 | "3\n",
535 | "4\n",
536 | "5\n",
537 | "6\n",
538 | "7\n",
539 | "8\n",
540 | "9\n",
541 | "10\n"
542 | ]
543 | }
544 | ],
545 | "source": [
546 | "#range methodu içine yazılan başlangıç ve bitiş değerleri arasında sayı üretmeye yarar.\n",
547 | "for i in range(1,11):\n",
548 | " print(i)"
549 | ]
550 | },
551 | {
552 | "cell_type": "markdown",
553 | "metadata": {},
554 | "source": [
555 | "**b) 1-100 arası Çift Sayıları Listeleyen Python kodunu yazınız.** "
556 | ]
557 | },
558 | {
559 | "cell_type": "code",
560 | "execution_count": 37,
561 | "metadata": {},
562 | "outputs": [
563 | {
564 | "name": "stdout",
565 | "output_type": "stream",
566 | "text": [
567 | "2\n",
568 | "4\n",
569 | "6\n",
570 | "8\n",
571 | "10\n",
572 | "12\n",
573 | "14\n",
574 | "16\n",
575 | "18\n",
576 | "20\n",
577 | "22\n",
578 | "24\n",
579 | "26\n",
580 | "28\n",
581 | "30\n",
582 | "32\n",
583 | "34\n",
584 | "36\n",
585 | "38\n",
586 | "40\n",
587 | "42\n",
588 | "44\n",
589 | "46\n",
590 | "48\n",
591 | "50\n",
592 | "52\n",
593 | "54\n",
594 | "56\n",
595 | "58\n",
596 | "60\n",
597 | "62\n",
598 | "64\n",
599 | "66\n",
600 | "68\n",
601 | "70\n",
602 | "72\n",
603 | "74\n",
604 | "76\n",
605 | "78\n",
606 | "80\n",
607 | "82\n",
608 | "84\n",
609 | "86\n",
610 | "88\n",
611 | "90\n",
612 | "92\n",
613 | "94\n",
614 | "96\n",
615 | "98\n",
616 | "100\n"
617 | ]
618 | }
619 | ],
620 | "source": [
621 | "for i in range(1,101):\n",
622 | " if i%2==0:\n",
623 | " print(i)"
624 | ]
625 | },
626 | {
627 | "cell_type": "markdown",
628 | "metadata": {},
629 | "source": [
630 | "**c) 1-100 arası Tek Sayıları Listeleyen Python kodunu yazınız.** "
631 | ]
632 | },
633 | {
634 | "cell_type": "code",
635 | "execution_count": 38,
636 | "metadata": {},
637 | "outputs": [
638 | {
639 | "name": "stdout",
640 | "output_type": "stream",
641 | "text": [
642 | "1\n",
643 | "3\n",
644 | "5\n",
645 | "7\n",
646 | "9\n",
647 | "11\n",
648 | "13\n",
649 | "15\n",
650 | "17\n",
651 | "19\n",
652 | "21\n",
653 | "23\n",
654 | "25\n",
655 | "27\n",
656 | "29\n",
657 | "31\n",
658 | "33\n",
659 | "35\n",
660 | "37\n",
661 | "39\n",
662 | "41\n",
663 | "43\n",
664 | "45\n",
665 | "47\n",
666 | "49\n",
667 | "51\n",
668 | "53\n",
669 | "55\n",
670 | "57\n",
671 | "59\n",
672 | "61\n",
673 | "63\n",
674 | "65\n",
675 | "67\n",
676 | "69\n",
677 | "71\n",
678 | "73\n",
679 | "75\n",
680 | "77\n",
681 | "79\n",
682 | "81\n",
683 | "83\n",
684 | "85\n",
685 | "87\n",
686 | "89\n",
687 | "91\n",
688 | "93\n",
689 | "95\n",
690 | "97\n",
691 | "99\n"
692 | ]
693 | }
694 | ],
695 | "source": [
696 | "for i in range(1,101):\n",
697 | " if i%2!=0:\n",
698 | " print(i)"
699 | ]
700 | },
701 | {
702 | "cell_type": "markdown",
703 | "metadata": {},
704 | "source": [
705 | "## UYGULAMA 3 \n",
706 | "\n",
707 | "1 den başlayıp kullanıcının Girdiği girdiği sayı da dahil olmak üzere Sayıları Listeleyen Python kodunuz yazınız. "
708 | ]
709 | },
710 | {
711 | "cell_type": "code",
712 | "execution_count": 41,
713 | "metadata": {},
714 | "outputs": [
715 | {
716 | "name": "stdout",
717 | "output_type": "stream",
718 | "text": [
719 | "Sayıyı Gir : 6\n",
720 | "1\n",
721 | "2\n",
722 | "3\n",
723 | "4\n",
724 | "5\n",
725 | "6\n"
726 | ]
727 | }
728 | ],
729 | "source": [
730 | "sayi=int(input('Sayıyı Gir : '))\n",
731 | "for i in range(1,sayi+1):\n",
732 | " print(i)"
733 | ]
734 | },
735 | {
736 | "cell_type": "markdown",
737 | "metadata": {},
738 | "source": [
739 | "## UYGULAMA 4\n",
740 | "\n",
741 | "Kullanıcın girdiği iki sayı arasındaki sayıların toplamını gösteren Python programını yazınız.\n",
742 | "\n"
743 | ]
744 | },
745 | {
746 | "cell_type": "code",
747 | "execution_count": 42,
748 | "metadata": {},
749 | "outputs": [
750 | {
751 | "name": "stdout",
752 | "output_type": "stream",
753 | "text": [
754 | "Birinci sayıyı giriniz: 5\n",
755 | "İkinci sayıyı giriniz: 8\n",
756 | "5 ile 8 arasındaki sayıların toplamı : 13\n"
757 | ]
758 | }
759 | ],
760 | "source": [
761 | "toplam=0;\n",
762 | "sayi1=int(input(\"Birinci sayıyı giriniz: \"))\n",
763 | "sayi2=int(input(\"İkinci sayıyı giriniz: \"))\n",
764 | "for i in range(sayi1+1,sayi2):\n",
765 | " toplam+=i #toplam = toplam + i \n",
766 | "print(\"{} ile {} arasındaki sayıların toplamı : {}\".format(sayi1,sayi2,toplam))\n",
767 | " \n"
768 | ]
769 | },
770 | {
771 | "cell_type": "markdown",
772 | "metadata": {},
773 | "source": [
774 | "## UYGULAMA 5\n",
775 | "\n",
776 | "Girilen Sayının Asal Sayı mı Değil mi olduğunu bulan programı yazınız. "
777 | ]
778 | },
779 | {
780 | "cell_type": "code",
781 | "execution_count": 43,
782 | "metadata": {},
783 | "outputs": [
784 | {
785 | "name": "stdout",
786 | "output_type": "stream",
787 | "text": [
788 | "Sayı Giriniz: 91\n",
789 | "Sayı Asal Değildir\n"
790 | ]
791 | }
792 | ],
793 | "source": [
794 | "sayac=0\n",
795 | "sayi=int(input('Sayı Giriniz: '))\n",
796 | "for i in range(2,sayi):\n",
797 | " if(sayi%i==0):\n",
798 | " sayac+=1\n",
799 | "if(sayac!=0):\n",
800 | " print(\"Sayı Asal Değildir\")\n",
801 | "else:\n",
802 | " print(\"Sayı Asaldır\")"
803 | ]
804 | },
805 | {
806 | "cell_type": "markdown",
807 | "metadata": {},
808 | "source": [
809 | "## ÖDEV 15\n",
810 | "\n",
811 | "**1) listesindeki her bir meyveyi ekrana büyük hafle yazdıran program kodunuz yazınız.**\n",
812 | "\n",
813 | "meyve = [\"kiraz\",\"kayısı\",\"şeftali\",\"muz\",\"portakal\"]\n",
814 | "\n",
815 | "\n",
816 | "**2) liste=[10,100,50,60,15,5]**\n",
817 | "\n",
818 | "listesindeki her bir elemanı 5'e bölüp yeni bir listeye yazan programı yazınız. \n",
819 | "\n",
820 | "**3) demet =(2,5,9,56,3,[20,3,5],80)**\n",
821 | "\n",
822 | "Yukarıdaki demette yer alan elemanların sayısını for döngüsü ile bulan programı yazınız. \n",
823 | "\n"
824 | ]
825 | },
826 | {
827 | "cell_type": "code",
828 | "execution_count": null,
829 | "metadata": {},
830 | "outputs": [],
831 | "source": []
832 | }
833 | ],
834 | "metadata": {
835 | "kernelspec": {
836 | "display_name": "Python 3",
837 | "language": "python",
838 | "name": "python3"
839 | },
840 | "language_info": {
841 | "codemirror_mode": {
842 | "name": "ipython",
843 | "version": 3
844 | },
845 | "file_extension": ".py",
846 | "mimetype": "text/x-python",
847 | "name": "python",
848 | "nbconvert_exporter": "python",
849 | "pygments_lexer": "ipython3",
850 | "version": "3.7.3"
851 | }
852 | },
853 | "nbformat": 4,
854 | "nbformat_minor": 2
855 | }
856 |
--------------------------------------------------------------------------------
/DERS -11.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 11"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# if-else koşullu durumları\n"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "Python programlarımız belirli bloklardan oluşur ve bu bloklar her zaman çalışmak zorunda olmaz.\n",
22 | "Pythonda bir blok tanımlama işlemi **Girintiler** ile olmaktadır. Bu girintiler de **girintiler(tab)** Pythonda bir blok oluşturmak için kullanılır. \n"
23 | ]
24 | },
25 | {
26 | "cell_type": "code",
27 | "execution_count": 2,
28 | "metadata": {},
29 | "outputs": [
30 | {
31 | "name": "stdout",
32 | "output_type": "stream",
33 | "text": [
34 | "2\n",
35 | "Merhaba\n"
36 | ]
37 | }
38 | ],
39 | "source": [
40 | "a = 2 # Blok 1 'e ait kod\n",
41 | "\n",
42 | "if (a == 2):\n",
43 | " print(a) # Blok 2'ye ait kod - Girinti\n",
44 | "print(\"Merhaba\") # Blok 1 ' ait kod"
45 | ]
46 | },
47 | {
48 | "cell_type": "code",
49 | "execution_count": 4,
50 | "metadata": {},
51 | "outputs": [
52 | {
53 | "name": "stdout",
54 | "output_type": "stream",
55 | "text": [
56 | "Merhaba\n"
57 | ]
58 | }
59 | ],
60 | "source": [
61 | "a = 25 # Blok 1 'e ait kod\n",
62 | "\n",
63 | "if (a == 3):\n",
64 | " print(a) # Blok 2'ye ait kod\n",
65 | "print(\"Merhaba\") # Blok 1 ' ait kod"
66 | ]
67 | },
68 | {
69 | "cell_type": "markdown",
70 | "metadata": {},
71 | "source": [
72 | "### Koşullu Durumlar"
73 | ]
74 | },
75 | {
76 | "cell_type": "markdown",
77 | "metadata": {},
78 | "source": [
79 | "\n",
80 | "Programlamada birçok koşullu durumla karşılaşırız. Belirli koşullar sağlanırsa belirli işlemleri yaparız gibi. Bu durumlar \n",
81 | "koşullu durumların temelibş oluşturur. \n"
82 | ]
83 | },
84 | {
85 | "cell_type": "markdown",
86 | "metadata": {},
87 | "source": [
88 | "### if Bloğu\n",
89 | "\n",
90 | "if bloğu programımızın içinde herhangi bir yerde belli bir koşulu kontrol edecek isek kullanılan bloklardır.Yazımı şu şekildedir;\n",
91 | "\n",
92 | " if (koşul): \n",
93 | " # if bloğu - Koşul sağlanınca (True) çalışır. Bu hizadaki her işlem bu if bloğuna ait.\n",
94 | " Koşul sağlandığında yapılacak kod satırları \n",
95 | " \n",
96 | "**if bloğu** *eğer koşul sağlanırsa anlamı taşır*. Eğer if kalıbındaki koşul sağlanırsa (True) if bloğu çalıştırılır, koşul sağlanmazsa (False) if bloğu çalıştırılmaz. "
97 | ]
98 | },
99 | {
100 | "cell_type": "code",
101 | "execution_count": 5,
102 | "metadata": {},
103 | "outputs": [
104 | {
105 | "name": "stdout",
106 | "output_type": "stream",
107 | "text": [
108 | "Lütfen sayi giriniz:15\n",
109 | "Girilen sayı: 15\n"
110 | ]
111 | }
112 | ],
113 | "source": [
114 | "#Kullanıcıdan alınan sayı 10'dan küçük ise ekrana yazan program\n",
115 | "sayi = int(input(\"Lütfen sayi giriniz:\"))\n",
116 | "if (sayi < 10):\n",
117 | " print(sayi)\n",
118 | " print(\"Girdiğiniz sayı 10'dan küçüktür\")\n",
119 | "print(\"Girilen sayı:\",sayi) # her koşulda çalışır, çünkü burası if bloğuna dahil değildir."
120 | ]
121 | },
122 | {
123 | "cell_type": "code",
124 | "execution_count": 6,
125 | "metadata": {},
126 | "outputs": [
127 | {
128 | "name": "stdout",
129 | "output_type": "stream",
130 | "text": [
131 | "Yaşınızı giriniz:14\n",
132 | "Ehliyet alamazsınız.\n"
133 | ]
134 | }
135 | ],
136 | "source": [
137 | "# 18 yaş kontrolü\n",
138 | "yaş = int(input(\"Yaşınızı giriniz:\"))\n",
139 | "\n",
140 | "if (yaş < 18):\n",
141 | " print(\"Ehliyet alamazsınız.\")"
142 | ]
143 | },
144 | {
145 | "cell_type": "code",
146 | "execution_count": 7,
147 | "metadata": {},
148 | "outputs": [
149 | {
150 | "name": "stdout",
151 | "output_type": "stream",
152 | "text": [
153 | "Sayıyı giriniz:-5\n",
154 | "Negatif Sayı\n"
155 | ]
156 | }
157 | ],
158 | "source": [
159 | "# Kullanıcıdan alınan sayının Negatif mi değil mi olduğunu bulan program\n",
160 | "sayı = int (input(\"Sayıyı giriniz:\"))\n",
161 | "\n",
162 | "if (sayı < 0):\n",
163 | " print(\"Negatif Sayı\")\n",
164 | " "
165 | ]
166 | },
167 | {
168 | "cell_type": "markdown",
169 | "metadata": {},
170 | "source": [
171 | "#### else Bloğu\n",
172 | "\n",
173 | "else blokları **if koşulu ** sağlanmadığı zaman (False) çalışan bloklardır. Kullanımı şu şekildedir;\n",
174 | " \n",
175 | "\n",
176 | " else:\n",
177 | " # else bloğu - Yukarısındaki herhangi bir if bloğu (veya ilerde göreceğimiz elif bloğu) çalışmadığı zaman\n",
178 | " Koşul sağlanmadığında yapılacak işlemler\n",
179 | " \n",
180 | "**else** koşulunun yanına herhangi bir koşul yazılmaz çünkü zaten **else** bloğunun çalışması ondan önce gelen diğer koşulların sağlanmamasına bağlıdır."
181 | ]
182 | },
183 | {
184 | "cell_type": "code",
185 | "execution_count": 18,
186 | "metadata": {},
187 | "outputs": [
188 | {
189 | "name": "stdout",
190 | "output_type": "stream",
191 | "text": [
192 | "Bir sayı giriniz:10\n",
193 | "Girilen sayı pozitif\n"
194 | ]
195 | }
196 | ],
197 | "source": [
198 | "#Kullanıcıdan alınan sayı negatif ise (IF KOŞULU) ekrana \"negatif\", değilse (ELSE) ekrana \"Pozitif\" yazan programı yazalım\n",
199 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
200 | "\n",
201 | "if (sayi<0):\n",
202 | " print(\"Girilen sayı negatif\")\n",
203 | "else: #eğer if koşulu sağlanmıyorsa else kodu çalıştırılır.\n",
204 | " print(\"Girilen sayı pozitif\")"
205 | ]
206 | },
207 | {
208 | "cell_type": "code",
209 | "execution_count": 21,
210 | "metadata": {},
211 | "outputs": [
212 | {
213 | "name": "stdout",
214 | "output_type": "stream",
215 | "text": [
216 | "Bir sayı giriniz:10\n",
217 | "Girilen sayı pozitif\n"
218 | ]
219 | }
220 | ],
221 | "source": [
222 | "#YUKARIDAKİ İLE TAMAMEN AYNI \n",
223 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
224 | "\n",
225 | "if (sayi<0):\n",
226 | " print(\"Girilen sayı negatif\")\n",
227 | "if (sayi>0): \n",
228 | " print(\"Girilen sayı pozitif\")"
229 | ]
230 | },
231 | {
232 | "cell_type": "code",
233 | "execution_count": 8,
234 | "metadata": {},
235 | "outputs": [
236 | {
237 | "name": "stdout",
238 | "output_type": "stream",
239 | "text": [
240 | "Yaşınızı giriniz:25\n",
241 | "Ehliyet alabilirsiniz.\n"
242 | ]
243 | }
244 | ],
245 | "source": [
246 | "# 18 yaş kontrolü yapan programı yazınız\n",
247 | "yaş = int(input(\"Yaşınızı giriniz:\"))\n",
248 | "\n",
249 | "if (yaş < 18):\n",
250 | " # if bloğu - Girinti ile sağlanıyor.\n",
251 | " print(\"Ehliyet alamazsınız.\")\n",
252 | "else:\n",
253 | " # else bloğu - if koşulu sağlanmazsa çalışacak.\n",
254 | " print(\"Ehliyet alabilirsiniz.\")"
255 | ]
256 | },
257 | {
258 | "cell_type": "code",
259 | "execution_count": 9,
260 | "metadata": {},
261 | "outputs": [
262 | {
263 | "ename": "SyntaxError",
264 | "evalue": "invalid syntax (, line 2)",
265 | "output_type": "error",
266 | "traceback": [
267 | "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m else:\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
268 | ]
269 | }
270 | ],
271 | "source": [
272 | "# else tek başına yazılamaz mutlaka bir if koşuluna bağlıdır. \n",
273 | "else:\n",
274 | " print(\"Girilen ilk sayı büyüktür\")"
275 | ]
276 | },
277 | {
278 | "cell_type": "markdown",
279 | "metadata": {},
280 | "source": [
281 | "Buradaki kod hata verdi çünkü bir **else** bloğu kendinden önce herhangi bir koşul bloğu yok ise çalışamaz ve Pythonda hataya yol açar.\n"
282 | ]
283 | },
284 | {
285 | "cell_type": "markdown",
286 | "metadata": {
287 | "collapsed": true
288 | },
289 | "source": [
290 | "### ÖDEV 11\n",
291 | "\n",
292 | "**Aşağıdaki kod satırlarının çıktısı ne olur ?**\n",
293 | "\n",
294 | " - not (28 >5)\n",
295 | " - not (5==5)\n",
296 | " - (\"Bursa\" != \"Balıkesir\") and (8<18)\n",
297 | " - ((3+5)==8) and ((20-9)==10)\n",
298 | " - (\"Hatice\"== \"Hayriye\") and (2<3)\n",
299 | " - (\"Bursa\" != \"Balıkesir\") or (8<18)\n",
300 | " - ((3+5)>=8) or ((20-9)!=10)\n",
301 | " - 63==60 or \"Hatice\" == \"Candan\"\n"
302 | ]
303 | },
304 | {
305 | "cell_type": "markdown",
306 | "metadata": {},
307 | "source": [
308 | "**2) Kullanıcıdan bir sayı alınız ve alınan sayı 100'den büyük ise sayıyı ekrana yazdıran programı yazınız.** "
309 | ]
310 | },
311 | {
312 | "cell_type": "markdown",
313 | "metadata": {},
314 | "source": [
315 | "**3) Kullanıcıdan bir sayı alınız ve alınan sayı 200'dan küçük ise sayıyı ekrana yazdıran programı yazınız.** "
316 | ]
317 | },
318 | {
319 | "cell_type": "markdown",
320 | "metadata": {},
321 | "source": [
322 | "**4) Kullanıcıdan bir sayı alınız ve eğer sayı 100'den büyük *VE* 200'den küçük ise sayıyı ekrana yazdıran programı yazınız.** "
323 | ]
324 | },
325 | {
326 | "cell_type": "code",
327 | "execution_count": 1,
328 | "metadata": {},
329 | "outputs": [
330 | {
331 | "data": {
332 | "text/plain": [
333 | "False"
334 | ]
335 | },
336 | "execution_count": 1,
337 | "metadata": {},
338 | "output_type": "execute_result"
339 | }
340 | ],
341 | "source": [
342 | "not (28 >5)"
343 | ]
344 | },
345 | {
346 | "cell_type": "code",
347 | "execution_count": 2,
348 | "metadata": {},
349 | "outputs": [
350 | {
351 | "data": {
352 | "text/plain": [
353 | "False"
354 | ]
355 | },
356 | "execution_count": 2,
357 | "metadata": {},
358 | "output_type": "execute_result"
359 | }
360 | ],
361 | "source": [
362 | "not (5==5)"
363 | ]
364 | },
365 | {
366 | "cell_type": "code",
367 | "execution_count": 3,
368 | "metadata": {},
369 | "outputs": [
370 | {
371 | "data": {
372 | "text/plain": [
373 | "True"
374 | ]
375 | },
376 | "execution_count": 3,
377 | "metadata": {},
378 | "output_type": "execute_result"
379 | }
380 | ],
381 | "source": [
382 | "(\"Bursa\" != \"Balıkesir\") and (8<18)"
383 | ]
384 | },
385 | {
386 | "cell_type": "code",
387 | "execution_count": 4,
388 | "metadata": {},
389 | "outputs": [
390 | {
391 | "data": {
392 | "text/plain": [
393 | "False"
394 | ]
395 | },
396 | "execution_count": 4,
397 | "metadata": {},
398 | "output_type": "execute_result"
399 | }
400 | ],
401 | "source": [
402 | "((3+5)==8) and ((20-9)==10)"
403 | ]
404 | },
405 | {
406 | "cell_type": "code",
407 | "execution_count": 5,
408 | "metadata": {},
409 | "outputs": [
410 | {
411 | "data": {
412 | "text/plain": [
413 | "False"
414 | ]
415 | },
416 | "execution_count": 5,
417 | "metadata": {},
418 | "output_type": "execute_result"
419 | }
420 | ],
421 | "source": [
422 | "(\"Hatice\"== \"Hayriye\") and (2<3)"
423 | ]
424 | },
425 | {
426 | "cell_type": "code",
427 | "execution_count": 6,
428 | "metadata": {},
429 | "outputs": [
430 | {
431 | "data": {
432 | "text/plain": [
433 | "True"
434 | ]
435 | },
436 | "execution_count": 6,
437 | "metadata": {},
438 | "output_type": "execute_result"
439 | }
440 | ],
441 | "source": [
442 | "(\"Bursa\" != \"Balıkesir\") or (8<18)"
443 | ]
444 | },
445 | {
446 | "cell_type": "code",
447 | "execution_count": 7,
448 | "metadata": {},
449 | "outputs": [
450 | {
451 | "data": {
452 | "text/plain": [
453 | "True"
454 | ]
455 | },
456 | "execution_count": 7,
457 | "metadata": {},
458 | "output_type": "execute_result"
459 | }
460 | ],
461 | "source": [
462 | "((3+5)>=8) or ((20-9)!=10)"
463 | ]
464 | },
465 | {
466 | "cell_type": "code",
467 | "execution_count": 8,
468 | "metadata": {},
469 | "outputs": [
470 | {
471 | "data": {
472 | "text/plain": [
473 | "False"
474 | ]
475 | },
476 | "execution_count": 8,
477 | "metadata": {},
478 | "output_type": "execute_result"
479 | }
480 | ],
481 | "source": [
482 | "63==60 or \"Hatice\" == \"Candan\""
483 | ]
484 | },
485 | {
486 | "cell_type": "code",
487 | "execution_count": 19,
488 | "metadata": {},
489 | "outputs": [
490 | {
491 | "name": "stdout",
492 | "output_type": "stream",
493 | "text": [
494 | "Bir sayı giriniz:99\n"
495 | ]
496 | }
497 | ],
498 | "source": [
499 | "#2\n",
500 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
501 | "\n",
502 | "if (sayi>100):\n",
503 | " print(\"sayi:\",sayi)"
504 | ]
505 | },
506 | {
507 | "cell_type": "code",
508 | "execution_count": 21,
509 | "metadata": {},
510 | "outputs": [
511 | {
512 | "name": "stdout",
513 | "output_type": "stream",
514 | "text": [
515 | "Bir sayı giriniz:250\n"
516 | ]
517 | }
518 | ],
519 | "source": [
520 | "#3\n",
521 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
522 | "\n",
523 | "if (sayi<200):\n",
524 | " print(\"sayi:\",sayi)"
525 | ]
526 | },
527 | {
528 | "cell_type": "code",
529 | "execution_count": 23,
530 | "metadata": {},
531 | "outputs": [
532 | {
533 | "name": "stdout",
534 | "output_type": "stream",
535 | "text": [
536 | "Bir sayı giriniz:40\n"
537 | ]
538 | }
539 | ],
540 | "source": [
541 | "#4\n",
542 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
543 | "\n",
544 | "if (sayi>100) and (sayi<200):\n",
545 | " print(\"sayi:\",sayi)"
546 | ]
547 | },
548 | {
549 | "cell_type": "code",
550 | "execution_count": 25,
551 | "metadata": {},
552 | "outputs": [
553 | {
554 | "name": "stdout",
555 | "output_type": "stream",
556 | "text": [
557 | "Bir sayı giriniz:105\n",
558 | "sayi: 105\n"
559 | ]
560 | }
561 | ],
562 | "source": [
563 | "#4 veya şu şekilde de yazılabilir \n",
564 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
565 | "\n",
566 | "if (100= 50):\n",
41 | " print(\"GEÇTİ\")\n",
42 | "else:\n",
43 | " print(\"KALDI\")"
44 | ]
45 | },
46 | {
47 | "cell_type": "code",
48 | "execution_count": null,
49 | "metadata": {},
50 | "outputs": [],
51 | "source": []
52 | },
53 | {
54 | "cell_type": "markdown",
55 | "metadata": {},
56 | "source": [
57 | "### UYGULAMA 2: \n",
58 | "Kullanıcıdan alınan sayının tek mi çift mi olduğunu bulan programı yazınız. "
59 | ]
60 | },
61 | {
62 | "cell_type": "code",
63 | "execution_count": 4,
64 | "metadata": {},
65 | "outputs": [
66 | {
67 | "name": "stdout",
68 | "output_type": "stream",
69 | "text": [
70 | "Bir sayı giriniz:10\n",
71 | "Girilen sayı çift sayıdır.\n"
72 | ]
73 | }
74 | ],
75 | "source": [
76 | "sayi = int(input(\"Bir sayı giriniz:\"))\n",
77 | "# sayının 2ye bölümünden kalan sıfır ise o sayı çift sayıdır. \n",
78 | "if (sayi%2 == 0):\n",
79 | " print(\"Girilen sayı çift sayıdır.\")\n",
80 | "else:\n",
81 | " print(\"Girilen sayı tek sayıdır.\") "
82 | ]
83 | },
84 | {
85 | "cell_type": "code",
86 | "execution_count": null,
87 | "metadata": {},
88 | "outputs": [],
89 | "source": []
90 | },
91 | {
92 | "cell_type": "code",
93 | "execution_count": null,
94 | "metadata": {},
95 | "outputs": [],
96 | "source": []
97 | },
98 | {
99 | "cell_type": "markdown",
100 | "metadata": {},
101 | "source": [
102 | "### UYGULAMA 3:\n",
103 | "Kullanıcıdan alınan iki adet sayıdan büyük olanını bulan programı yazınız. "
104 | ]
105 | },
106 | {
107 | "cell_type": "code",
108 | "execution_count": 11,
109 | "metadata": {},
110 | "outputs": [
111 | {
112 | "name": "stdout",
113 | "output_type": "stream",
114 | "text": [
115 | "Bir sayı giriniz:90\n",
116 | "İkinci sayıyı giriniz:10\n",
117 | "Büyük olan sayı: 90\n"
118 | ]
119 | }
120 | ],
121 | "source": [
122 | "sayi1= int(input(\"Bir sayı giriniz:\"))\n",
123 | "sayi2= int(input(\"İkinci sayıyı giriniz:\"))\n",
124 | "\n",
125 | "if (sayi1>sayi2):\n",
126 | " print(\"Büyük olan sayı:\",sayi1)\n",
127 | "if (sayi1=170):\n",
177 | " print(\"Boyunuz Uzundur.\")"
178 | ]
179 | },
180 | {
181 | "cell_type": "code",
182 | "execution_count": null,
183 | "metadata": {},
184 | "outputs": [],
185 | "source": []
186 | },
187 | {
188 | "cell_type": "code",
189 | "execution_count": null,
190 | "metadata": {},
191 | "outputs": [],
192 | "source": []
193 | },
194 | {
195 | "cell_type": "markdown",
196 | "metadata": {},
197 | "source": [
198 | "### UYGULAMA 5:\n",
199 | "Kullanıcı bir uygulamaya girmek için Email ve parola bilgileri ile giriş yapacaktır. Daha önceden sistemde kayıtlı bilgiler ile girilen bilgileri karşılaştırarak eğer doğru kullanıcı adı ve parolayla giriş yapmışsa ekrana \"\"GİRİŞ İŞLEMİ BAŞARILI\" yazan programı kodlayınız . "
200 | ]
201 | },
202 | {
203 | "cell_type": "code",
204 | "execution_count": 14,
205 | "metadata": {},
206 | "outputs": [
207 | {
208 | "name": "stdout",
209 | "output_type": "stream",
210 | "text": [
211 | "Mail adresinizi giriniz:kodlama@gmail.com\n",
212 | "Şifrenizi giriniz:20212021\n",
213 | "LÜTFEN YENİDEN GİRİNİZ!\n"
214 | ]
215 | }
216 | ],
217 | "source": [
218 | "#sistemde kayıtlı bilgiler\n",
219 | "mail_sistem = \"kodlama@gmail.com\"\n",
220 | "sifre_sistem =\"20212022\"\n",
221 | "\n",
222 | "#kullanıcıdan alınan bilgiler \n",
223 | "mail=input(\"Mail adresinizi giriniz:\")\n",
224 | "sifre = input(\"Şifrenizi giriniz:\")\n",
225 | "\n",
226 | "\n",
227 | "if (mail==mail_sistem) and (sifre ==sifre_sistem):\n",
228 | " print(\"GİRİŞ İŞLEMİ BAŞARILI\")\n",
229 | "else:\n",
230 | " print(\"LÜTFEN YENİDEN GİRİNİZ!\")\n",
231 | "\n"
232 | ]
233 | },
234 | {
235 | "cell_type": "markdown",
236 | "metadata": {},
237 | "source": [
238 | "# ÖDEV 12 \n",
239 | "**1) Bir otoparkta park eden kişinin kaldığı dakikaya göre ödeyeceği ücreti hesaplayan programı yazınız. Dakikayı kullanıcıdan alınız.** \n",
240 | "\n",
241 | "Otopark kullanım ücreti şu şekildedir:\n",
242 | "\n",
243 | "- 15 dakikadan az kalındıysa 5 TL\n",
244 | "- 15 dakika ile 45 dakika arasındaysa 15 TL\n",
245 | "- 45 dakika ile 60 dakika arasındaysa 25 TL\n",
246 | "- 1 saatten uzun kalındıysa 40 TL\n",
247 | "\n"
248 | ]
249 | },
250 | {
251 | "cell_type": "code",
252 | "execution_count": 6,
253 | "metadata": {},
254 | "outputs": [
255 | {
256 | "name": "stdout",
257 | "output_type": "stream",
258 | "text": [
259 | "Kullanım dakikanızı giriniz:25\n",
260 | "Ödemeniz gereken tutar 15 TL\n"
261 | ]
262 | }
263 | ],
264 | "source": [
265 | "dk = int(input(\"Kullanım dakikanızı giriniz:\"))\n",
266 | "\n",
267 | "if (dk <15):\n",
268 | " print(\"Ödemeniz gereken tutar 5 TL\")\n",
269 | "if (15<= dk<45):\n",
270 | " print(\"Ödemeniz gereken tutar 15 TL\")\n",
271 | "if (45<=dk<60):\n",
272 | " print(\"Ödemeniz gereken tutar 25 TL\")\n",
273 | "if (dk>=60):\n",
274 | " print(\"Ödemeniz gereken tutar 40 TL\") "
275 | ]
276 | },
277 | {
278 | "cell_type": "code",
279 | "execution_count": null,
280 | "metadata": {},
281 | "outputs": [],
282 | "source": []
283 | },
284 | {
285 | "cell_type": "code",
286 | "execution_count": null,
287 | "metadata": {},
288 | "outputs": [],
289 | "source": []
290 | },
291 | {
292 | "cell_type": "markdown",
293 | "metadata": {},
294 | "source": [
295 | "**2) liste = [10,5,25,30,80]**\n",
296 | "\n",
297 | "yukarıdaki liste için eğer listenin ilk ve sonuncu elemanı 5'e tam bölünüyorsa \n",
298 | "ekrana \"Listenin ilk ve son elemanı 5'e tam bölünüyor\", değilse \"Listenin ilk ve son elemanı 5'e tam bölünmüyor\" yazan programı kodlayınız."
299 | ]
300 | },
301 | {
302 | "cell_type": "code",
303 | "execution_count": 9,
304 | "metadata": {},
305 | "outputs": [
306 | {
307 | "name": "stdout",
308 | "output_type": "stream",
309 | "text": [
310 | "Listenin ilk ve son elemanı 5'e tam bölünüyor\n"
311 | ]
312 | }
313 | ],
314 | "source": [
315 | "list = [10,5,25,30,80]\n",
316 | "if (list[0]%5 == 0) and (list[-1]%5 == 0):\n",
317 | " print(\"Listenin ilk ve son elemanı 5'e tam bölünüyor\")\n",
318 | "else:\n",
319 | " print(\"Listenin ilk ve son elemanı 5'e tam bölünmüyor\")"
320 | ]
321 | },
322 | {
323 | "cell_type": "markdown",
324 | "metadata": {},
325 | "source": [
326 | "**3) Kullanıcının ehliyet alıp alamayacağına karar veren programı bulunuz. Direksiyon puanını ve yazılı puanı kullanıcıdan alınız.** \n",
327 | "\n",
328 | "Kullanıcının ehliyet alabilmesi için gerekli puan koşulu 70 ve üzeri olmalıdır ve şu şekilde hesaplanır :\n",
329 | " \n",
330 | " Puan = (Direksiyon Sınavı x 0.6) + (Yazılı Puan x 0.4)\n",
331 | " \n",
332 | "Eğer puan 70 ve üzeri ise ehliyet almaya hak kazanılır, değilse ehliyet sınavına yeniden girmek gereklidir. \n",
333 | " "
334 | ]
335 | },
336 | {
337 | "cell_type": "code",
338 | "execution_count": 10,
339 | "metadata": {},
340 | "outputs": [
341 | {
342 | "name": "stdout",
343 | "output_type": "stream",
344 | "text": [
345 | "Direksiyon sınavı puanınızı giriniz:50\n",
346 | "Yazılı sınavı puanınızı giriniz:100\n",
347 | "Ehliyet almaya hak kazandınız\n"
348 | ]
349 | }
350 | ],
351 | "source": [
352 | "direksiyon = float(input(\"Direksiyon sınavı puanınızı giriniz:\"))\n",
353 | "yazili = float(input(\"Yazılı sınavı puanınızı giriniz:\"))\n",
354 | "\n",
355 | "\n",
356 | "puan = direksiyon *0.6 + yazili*0.4\n",
357 | "\n",
358 | "if puan>=70 :\n",
359 | " print(\"Ehliyet almaya hak kazandınız\")\n",
360 | "else:\n",
361 | " print(\"Ehliyet almaya hak KAZANAMADINIZ\")"
362 | ]
363 | },
364 | {
365 | "cell_type": "markdown",
366 | "metadata": {},
367 | "source": [
368 | "**4)Kullanıcıdan ismini ve soy ismini ayrı değişkenlerde alınız. Eğer kullanıcının ismi yada soyisminden hangisi daha uzunsa onu büyük harflerle \n",
369 | "ekrana yazan programı yazınız.** "
370 | ]
371 | },
372 | {
373 | "cell_type": "code",
374 | "execution_count": null,
375 | "metadata": {},
376 | "outputs": [],
377 | "source": [
378 | "ad = input(\"isminiz:\")\n",
379 | "soyad = input(\"soyisminiz:\")\n",
380 | "\n",
381 | "if len(ad)>len(soyad) : \n",
382 | " print(\"İsminiz daha uzundur\",ad.upper())\n",
383 | "else:\n",
384 | " print(\"Soyisminiz daha uzundur\",soyad.upper())"
385 | ]
386 | },
387 | {
388 | "cell_type": "code",
389 | "execution_count": null,
390 | "metadata": {},
391 | "outputs": [],
392 | "source": []
393 | }
394 | ],
395 | "metadata": {
396 | "kernelspec": {
397 | "display_name": "Python 3",
398 | "language": "python",
399 | "name": "python3"
400 | },
401 | "language_info": {
402 | "codemirror_mode": {
403 | "name": "ipython",
404 | "version": 3
405 | },
406 | "file_extension": ".py",
407 | "mimetype": "text/x-python",
408 | "name": "python",
409 | "nbconvert_exporter": "python",
410 | "pygments_lexer": "ipython3",
411 | "version": "3.7.3"
412 | }
413 | },
414 | "nbformat": 4,
415 | "nbformat_minor": 2
416 | }
417 |
--------------------------------------------------------------------------------
/DERS 13.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 13"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# if - elif - else koşullu durumları "
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "### if-elif-else Blokları"
22 | ]
23 | },
24 | {
25 | "cell_type": "markdown",
26 | "metadata": {},
27 | "source": [
28 | "Önceki konumuzda koşullu durumlarımızla sadece tek bir koşulu kontrol edebiliyorduk. Ancak programlamada bir durum bir çok koşula bağlı olabilir. Bu tür durumlar için if-elif-else kalıplarını kullanırız. Kullanımı şu şekildedir;\n",
29 | "\n",
30 | " if koşul: \n",
31 | " Yapılacak İşlemler\n",
32 | " elif başka bir koşul:\n",
33 | " Yapılacak İşlemler\n",
34 | " elif başka bir koşul:\n",
35 | " Yapılacak İşlemler\n",
36 | " \n",
37 | " //\n",
38 | " //\n",
39 | " else:\n",
40 | " Yapılacak İşlemler \n",
41 | "Programlarımızda, Kaç tane koşulumuz var ise o kadar elif bloğu oluşturabiliriz. \n",
42 | " \n",
43 | " "
44 | ]
45 | },
46 | {
47 | "cell_type": "code",
48 | "execution_count": 9,
49 | "metadata": {},
50 | "outputs": [
51 | {
52 | "name": "stdout",
53 | "output_type": "stream",
54 | "text": [
55 | "Bir sayı giriniz:20\n",
56 | "İkinci sayıyı giriniz:20\n",
57 | "Girdiğiniz sayılar birbirine eşittir.\n"
58 | ]
59 | }
60 | ],
61 | "source": [
62 | "sayi1= int(input(\"Bir sayı giriniz:\"))\n",
63 | "sayi2= int(input(\"İkinci sayıyı giriniz:\"))\n",
64 | "\n",
65 | "if (sayi1>sayi2):\n",
66 | " print(\"Büyük olan sayı:\",sayi1)\n",
67 | "elif (sayi1, line 3)",
176 | "output_type": "error",
177 | "traceback": [
178 | "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m elif işlem == 2:\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
179 | ]
180 | }
181 | ],
182 | "source": [
183 | "işlem = int(input(\"İşlem seçiniz:\")) # 3 tane işlemimiz olsun.\n",
184 | "\n",
185 | "elif işlem == 2:\n",
186 | " print(\"2. işlem seçildi.\")\n",
187 | "elif işlem == 3:\n",
188 | " print(\"3. işlem seçildi.\")\n",
189 | "else:\n",
190 | " print(\"Geçersiz İşlem!\")"
191 | ]
192 | },
193 | {
194 | "cell_type": "code",
195 | "execution_count": 1,
196 | "metadata": {},
197 | "outputs": [
198 | {
199 | "name": "stdout",
200 | "output_type": "stream",
201 | "text": [
202 | "Notunuzu giriniz:60\n",
203 | "CC\n"
204 | ]
205 | }
206 | ],
207 | "source": [
208 | "#Bir dersten alınan nota göre harf puanını hesaplayan programı yazalım. elif yapısında herhangi bir koşul sağlandığında\n",
209 | "# o satır çalışıp bloklar sona erecek.\n",
210 | "\n",
211 | "note = float(input(\"Notunuzu giriniz:\"))\n",
212 | "\n",
213 | "if note >= 90:\n",
214 | " print(\"AA\")\n",
215 | "elif note >= 80:\n",
216 | " print(\"BA\")\n",
217 | "elif note >= 70:\n",
218 | " print(\"CB\")\n",
219 | "elif note >= 60:\n",
220 | " print(\"CC\")\n",
221 | "elif note >= 55:\n",
222 | " print(\"DC\")\n",
223 | "elif note >= 50:\n",
224 | " print(\"DD\")\n",
225 | "else:\n",
226 | " print(\"Dersten Kaldınız\")\n"
227 | ]
228 | },
229 | {
230 | "cell_type": "markdown",
231 | "metadata": {},
232 | "source": [
233 | "**Peki aynı kodu if-if-if blokları ile yazarsak ne olurdu ?**"
234 | ]
235 | },
236 | {
237 | "cell_type": "markdown",
238 | "metadata": {
239 | "collapsed": true
240 | },
241 | "source": [
242 | "### if-if-if Blokları"
243 | ]
244 | },
245 | {
246 | "cell_type": "code",
247 | "execution_count": 2,
248 | "metadata": {},
249 | "outputs": [
250 | {
251 | "name": "stdout",
252 | "output_type": "stream",
253 | "text": [
254 | "Notunuzu giriniz:60\n",
255 | "CC\n",
256 | "DC\n",
257 | "DD\n"
258 | ]
259 | }
260 | ],
261 | "source": [
262 | "# Bütün if blokları koşul için kontrol edilir ve koşullar doğruysa o blok çalıştırırılır. \n",
263 | "\n",
264 | "note = float(input(\"Notunuzu giriniz:\"))\n",
265 | "\n",
266 | "if note >= 90:\n",
267 | " print(\"AA\")\n",
268 | "if note >= 80:\n",
269 | " print(\"BA\")\n",
270 | "if note >= 70:\n",
271 | " print(\"CB\")\n",
272 | "if note >= 60:\n",
273 | " print(\"CC\")\n",
274 | "if note >= 55:\n",
275 | " print(\"DC\")\n",
276 | "if note >= 50:\n",
277 | " print(\"DD\")\n",
278 | "else:\n",
279 | " print(\"Dersten Kaldınız\")"
280 | ]
281 | },
282 | {
283 | "cell_type": "markdown",
284 | "metadata": {},
285 | "source": [
286 | "*aynı notu girdik ama bize 3 farklı harf notu döndürdü. elif bloklarının önemi dikkatimizi çekmiştir umarım. "
287 | ]
288 | },
289 | {
290 | "cell_type": "markdown",
291 | "metadata": {
292 | "collapsed": true
293 | },
294 | "source": [
295 | "### UYGULAMA :\n",
296 | "Kullanıcının boy ve kilogram bilgilerini alıp vücut kitle indeksine göre hangi kategoriye girdiğini bulan programı yazınız. \n",
297 | "\n",
298 | "vücut kitle indeksi = kilo / (boy)**2\n",
299 | "\n",
300 | "- 19'dan küçükse - zayıfsınız sağlık riski yok\n",
301 | "- 19.1 - 26 arasındaysa - normalsiniz sağlık riski yok\n",
302 | "- 26.1 - 32.2 arasındaysa - şişmanlık sınırındasınız, risklisiniz. \n",
303 | "- 32.2 ve üzerindeyse - obezite, büyük risk altındasınız. "
304 | ]
305 | },
306 | {
307 | "cell_type": "code",
308 | "execution_count": 24,
309 | "metadata": {},
310 | "outputs": [
311 | {
312 | "name": "stdout",
313 | "output_type": "stream",
314 | "text": [
315 | "Boyunuzu metre cinsinden giriniz:1.65\n",
316 | "Kilogramınızı giriniz:58\n",
317 | "normalsiniz sağlık riski yok\n"
318 | ]
319 | }
320 | ],
321 | "source": [
322 | "boy = float(input(\"Boyunuzu metre cinsinden giriniz:\"))\n",
323 | "kg = float(input(\"Kilogramınızı giriniz:\"))\n",
324 | "\n",
325 | "vki=kg/(boy**2)\n",
326 | "\n",
327 | "if (vki<=19):\n",
328 | " print(\"zayıfsınız sağlık riski yok\")\n",
329 | "elif (19.1<=vki<=26):\n",
330 | " print(\"normalsiniz sağlık riski yok\")\n",
331 | "elif (26.1<=vki<=32.2):\n",
332 | " print(\"şişmanlık sınırındasınız, risklisiniz\")\n",
333 | "else:\n",
334 | " print(\" obezite, büyük risk altındasınız.\")"
335 | ]
336 | },
337 | {
338 | "cell_type": "markdown",
339 | "metadata": {},
340 | "source": [
341 | "### ÖDEV 13:\n",
342 | "**1)Kullanıcıdan iki sayı ve bir işlem numarası alarak seçilen işlem numarasına göre hesaplama yapan programı yazınız.** \n",
343 | "\n",
344 | "- Eğer işlem 1 seçilirse toplama işlemi,\n",
345 | "- Eğer işlem 2 seçilirse çıkarma işlemi,\n",
346 | "- Eğer işlem 3 seçilirse çarpma işlemi,\n",
347 | "- Eğer işlem 4 seçilirse bölme işlemi yapılacaktır. \n",
348 | "\n",
349 | "\n",
350 | "**Örnek Program Çıktısı**\n",
351 | "\n",
352 | "Birinci sayıyı giriniz : 30\n",
353 | "\n",
354 | "İkinci sayıyı giriniz : 18\n",
355 | "\n",
356 | "İşlem numarası seçiniz : 2 \n",
357 | "\n",
358 | "\n",
359 | "Yapılan işlem sonrası cevap = 12'dir. \n",
360 | "\n"
361 | ]
362 | },
363 | {
364 | "cell_type": "markdown",
365 | "metadata": {},
366 | "source": [
367 | "**2)Kullanıcıdan alınan 3 basamaklı bir sayının onlar ve birler basamağı birbirine eşitse ekrana \"girdiğiniz sayı mutlu sayı\" değilse \"girdiğiniz sayı üzgün sayı\" \n",
368 | "yazdıran programı yazınız.** "
369 | ]
370 | },
371 | {
372 | "cell_type": "markdown",
373 | "metadata": {},
374 | "source": [
375 | "**3)Kullanıcıdan alınan 3 tane sayıdan en büyük sayıyı ekrana yazdıran programı yazınız.**"
376 | ]
377 | },
378 | {
379 | "cell_type": "code",
380 | "execution_count": null,
381 | "metadata": {},
382 | "outputs": [],
383 | "source": []
384 | }
385 | ],
386 | "metadata": {
387 | "kernelspec": {
388 | "display_name": "Python 3",
389 | "language": "python",
390 | "name": "python3"
391 | },
392 | "language_info": {
393 | "codemirror_mode": {
394 | "name": "ipython",
395 | "version": 3
396 | },
397 | "file_extension": ".py",
398 | "mimetype": "text/x-python",
399 | "name": "python",
400 | "nbconvert_exporter": "python",
401 | "pygments_lexer": "ipython3",
402 | "version": "3.7.3"
403 | }
404 | },
405 | "nbformat": 4,
406 | "nbformat_minor": 2
407 | }
408 |
--------------------------------------------------------------------------------
/DERS 16.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## ÖDEV 15 CEVAPLARI \n",
8 | "\n",
9 | "**1) listesindeki her bir meyveyi ekrana büyük hafle yazdıran program kodunuz yazınız.**\n",
10 | "\n",
11 | "meyve = [\"kiraz\",\"kayısı\",\"şeftali\",\"muz\",\"portakal\"]\n",
12 | "\n",
13 | "\n",
14 | "**2) liste=[10,100,50,60,15,5]**\n",
15 | "\n",
16 | "listesindeki her bir elemanı 5'e bölüp yeni bir listeye yazan programı yazınız. \n",
17 | "\n",
18 | "**3) demet =(2,5,9,56,3,[20,3,5],80)**\n",
19 | "\n",
20 | "Yukarıdaki demette yer alan elemanların sayısını for döngüsü ile bulan programı yazınız. "
21 | ]
22 | },
23 | {
24 | "cell_type": "code",
25 | "execution_count": 19,
26 | "metadata": {},
27 | "outputs": [
28 | {
29 | "name": "stdout",
30 | "output_type": "stream",
31 | "text": [
32 | "KIRAZ\n",
33 | "KAYISI\n",
34 | "ŞEFTALI\n",
35 | "MUZ\n",
36 | "PORTAKAL\n"
37 | ]
38 | }
39 | ],
40 | "source": [
41 | "#1#\n",
42 | "meyve = [\"kiraz\",\"kayısı\",\"şeftali\",\"muz\",\"portakal\"]\n",
43 | "\n",
44 | "for i in meyve:\n",
45 | " print(i.upper())"
46 | ]
47 | },
48 | {
49 | "cell_type": "code",
50 | "execution_count": 1,
51 | "metadata": {},
52 | "outputs": [
53 | {
54 | "name": "stdout",
55 | "output_type": "stream",
56 | "text": [
57 | "[2.0, 20.0, 10.0, 12.0, 3.0, 1.0]\n",
58 | "6\n"
59 | ]
60 | }
61 | ],
62 | "source": [
63 | "#2#\n",
64 | "liste=[10,100,50,60,15,5]\n",
65 | "i=0\n",
66 | "for a in liste:\n",
67 | " liste[i]=(a/5)\n",
68 | " i+=1\n",
69 | "print(liste) \n",
70 | "print(i)"
71 | ]
72 | },
73 | {
74 | "cell_type": "code",
75 | "execution_count": 3,
76 | "metadata": {},
77 | "outputs": [
78 | {
79 | "data": {
80 | "text/plain": [
81 | "7"
82 | ]
83 | },
84 | "execution_count": 3,
85 | "metadata": {},
86 | "output_type": "execute_result"
87 | }
88 | ],
89 | "source": [
90 | "#3#\n",
91 | "demet =(2,5,9,56,3,[20,3,5],80)\n",
92 | "sayac = 0\n",
93 | "for i in demet:\n",
94 | " sayac+=1\n",
95 | "sayac \n",
96 | "\n",
97 | "len(demet)"
98 | ]
99 | },
100 | {
101 | "cell_type": "markdown",
102 | "metadata": {},
103 | "source": [
104 | "## DERS 16"
105 | ]
106 | },
107 | {
108 | "cell_type": "markdown",
109 | "metadata": {},
110 | "source": [
111 | "#### While döngüleri"
112 | ]
113 | },
114 | {
115 | "cell_type": "markdown",
116 | "metadata": {},
117 | "source": [
118 | "while döngüleri belli bir koşul sağlandığı sürece blokta yazılan satırları gerçekleştirir. \n",
119 | "*while* döngülerinin sona ermesi için koşul durumunun bir süre sonra **False** olması gereklidir yoksa sonsuz döngü olur. \n",
120 | "\n",
121 | " while (koşul):\n",
122 | " İşlem1\n",
123 | " İşlem2\n",
124 | " İşlem3\n",
125 | " //\n",
126 | " //"
127 | ]
128 | },
129 | {
130 | "cell_type": "code",
131 | "execution_count": 2,
132 | "metadata": {},
133 | "outputs": [
134 | {
135 | "name": "stdout",
136 | "output_type": "stream",
137 | "text": [
138 | "1\n",
139 | "2\n",
140 | "3\n",
141 | "4\n",
142 | "5\n",
143 | "6\n",
144 | "7\n",
145 | "8\n",
146 | "9\n"
147 | ]
148 | }
149 | ],
150 | "source": [
151 | "#1'den 10'a kadar sayıları ekrana yazdırmak istiyorum.\n",
152 | "\n",
153 | "i=1\n",
154 | "while (i<10):\n",
155 | " print(i)\n",
156 | " i+=1 #koşulu false yapabilmek için gerekli"
157 | ]
158 | },
159 | {
160 | "cell_type": "code",
161 | "execution_count": 5,
162 | "metadata": {},
163 | "outputs": [
164 | {
165 | "name": "stdout",
166 | "output_type": "stream",
167 | "text": [
168 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
169 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
170 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
171 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
172 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
173 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
174 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
175 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
176 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
177 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n"
178 | ]
179 | }
180 | ],
181 | "source": [
182 | "# EKRANA 10 KEZ \"PYTHON İLE KODLAMA ÖĞRENİYORUM\" YAZALIM.\n",
183 | "\n",
184 | "i=0\n",
185 | "while(i<10):\n",
186 | " print(\"PYTHON İLE KODLAMA ÖĞRENİYORUM\")\n",
187 | " i+=1"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": 6,
193 | "metadata": {},
194 | "outputs": [
195 | {
196 | "name": "stdout",
197 | "output_type": "stream",
198 | "text": [
199 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
200 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
201 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
202 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
203 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
204 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
205 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
206 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
207 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n",
208 | "PYTHON İLE KODLAMA ÖĞRENİYORUM\n"
209 | ]
210 | }
211 | ],
212 | "source": [
213 | "#aynı kodu for ile nasıl yazardık ?\n",
214 | "\n",
215 | "for i in range(0,10):\n",
216 | " print(\"PYTHON İLE KODLAMA ÖĞRENİYORUM\")"
217 | ]
218 | },
219 | {
220 | "cell_type": "code",
221 | "execution_count": 8,
222 | "metadata": {},
223 | "outputs": [
224 | {
225 | "name": "stdout",
226 | "output_type": "stream",
227 | "text": [
228 | "Indeks: 0 Eleman: 1\n",
229 | "Indeks: 1 Eleman: 2\n",
230 | "Indeks: 2 Eleman: 3\n",
231 | "Indeks: 3 Eleman: 4\n",
232 | "Indeks: 4 Eleman: 5\n"
233 | ]
234 | }
235 | ],
236 | "source": [
237 | "# Liste üzerinde while döngüsü\n",
238 | "liste = [1,2,3,4,5]\n",
239 | "\n",
240 | "i = 0 \n",
241 | "\n",
242 | "while (i < len(liste)):\n",
243 | " print(\"Indeks:\",i,\"Eleman:\",liste[i])\n",
244 | " i +=1"
245 | ]
246 | },
247 | {
248 | "cell_type": "code",
249 | "execution_count": 25,
250 | "metadata": {},
251 | "outputs": [
252 | {
253 | "name": "stdout",
254 | "output_type": "stream",
255 | "text": [
256 | "Indeks: 0 Eleman: 1\n",
257 | "Indeks: 1 Eleman: 2\n",
258 | "Indeks: 2 Eleman: 3\n",
259 | "Indeks: 3 Eleman: 4\n",
260 | "Indeks: 4 Eleman: 5\n"
261 | ]
262 | }
263 | ],
264 | "source": [
265 | "#aynı işlemi for ile nasıl yapardık\n",
266 | "liste = [1,2,3,4,5]\n",
267 | "a = 0\n",
268 | "for eleman in liste:\n",
269 | " print(\"Indeks:\",a,\"Eleman:\",eleman)\n",
270 | " a+=1"
271 | ]
272 | },
273 | {
274 | "cell_type": "markdown",
275 | "metadata": {},
276 | "source": [
277 | "#### SONSUZ DÖNGÜ "
278 | ]
279 | },
280 | {
281 | "cell_type": "markdown",
282 | "metadata": {},
283 | "source": [
284 | "while döngü koşulu bir süre sonra **False** olmazsa döngü sonsuza kadar devam edebilir, dolayısıyla while döngüsü kullanılırken koşullar kontrol edilip döngünün sonlandığından emin olmak önemlidir. "
285 | ]
286 | },
287 | {
288 | "cell_type": "code",
289 | "execution_count": null,
290 | "metadata": {},
291 | "outputs": [],
292 | "source": [
293 | "i = 0 \n",
294 | "while (i < 5):\n",
295 | " print(i)\n",
296 | " # i değişkenini artırma işlemi yapmadığımız için i değişkeninin değeri sürekli 0 kalıyor \n",
297 | " # ve döngü koşulu sürekli True kalıyor."
298 | ]
299 | },
300 | {
301 | "cell_type": "markdown",
302 | "metadata": {},
303 | "source": [
304 | "### range() Fonksiyonu\n",
305 | "\n",
306 | "range(başlangıç,bitiş,artım değeri) \n",
307 | "\n",
308 | "başlangıç, bitiş ve opsiyonel olarak artırma değeri alarak listelere benzeyen bir sayı dizisi oluşturur."
309 | ]
310 | },
311 | {
312 | "cell_type": "code",
313 | "execution_count": 8,
314 | "metadata": {},
315 | "outputs": [
316 | {
317 | "name": "stdout",
318 | "output_type": "stream",
319 | "text": [
320 | "0 1 2 3 4 5 6 7 8 9\n"
321 | ]
322 | }
323 | ],
324 | "source": [
325 | "range(0,10) # 0'dan 10' a kadar (10 dahil değil) sayı dizisi oluşturur. \n",
326 | "print(*range(0,10)) #yazdırmak için başına \"*\" koymak zorundayız"
327 | ]
328 | },
329 | {
330 | "cell_type": "code",
331 | "execution_count": 33,
332 | "metadata": {},
333 | "outputs": [
334 | {
335 | "name": "stdout",
336 | "output_type": "stream",
337 | "text": [
338 | "range(0, 10)\n",
339 | "0 1 2 3 4 5 6 7 8 9\n",
340 | "\n"
341 | ]
342 | }
343 | ],
344 | "source": [
345 | "a=range(0,10)\n",
346 | "print(a)\n",
347 | "print(*a)\n",
348 | "print(type(a))"
349 | ]
350 | },
351 | {
352 | "cell_type": "markdown",
353 | "metadata": {},
354 | "source": [
355 | "**Eğer listeye dönüştürmek istersem de list() fonksiyonu kullanmam gerekir.**"
356 | ]
357 | },
358 | {
359 | "cell_type": "code",
360 | "execution_count": 35,
361 | "metadata": {},
362 | "outputs": [
363 | {
364 | "name": "stdout",
365 | "output_type": "stream",
366 | "text": [
367 | "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n"
368 | ]
369 | },
370 | {
371 | "data": {
372 | "text/plain": [
373 | "list"
374 | ]
375 | },
376 | "execution_count": 35,
377 | "metadata": {},
378 | "output_type": "execute_result"
379 | }
380 | ],
381 | "source": [
382 | "a = list(range(0,10))\n",
383 | "print(a)\n",
384 | "type(a)"
385 | ]
386 | },
387 | {
388 | "cell_type": "code",
389 | "execution_count": 37,
390 | "metadata": {},
391 | "outputs": [
392 | {
393 | "data": {
394 | "text/plain": [
395 | "[5, 6, 7, 8, 9]"
396 | ]
397 | },
398 | "execution_count": 37,
399 | "metadata": {},
400 | "output_type": "execute_result"
401 | }
402 | ],
403 | "source": [
404 | "b = list(range(5,10)) #5 ile başlar 10'a kadar(10 dahil değil)\n",
405 | "b"
406 | ]
407 | },
408 | {
409 | "cell_type": "code",
410 | "execution_count": 39,
411 | "metadata": {},
412 | "outputs": [
413 | {
414 | "name": "stdout",
415 | "output_type": "stream",
416 | "text": [
417 | "0 1 2 3 4 5 6 7 8 9 10 11\n"
418 | ]
419 | }
420 | ],
421 | "source": [
422 | "print(*range(12)) #tek bir sayı yazarsam ise 0'dan başlar yazılan sayıya kadar (yazılan sayı dahil değil)"
423 | ]
424 | },
425 | {
426 | "cell_type": "code",
427 | "execution_count": 41,
428 | "metadata": {},
429 | "outputs": [
430 | {
431 | "data": {
432 | "text/plain": [
433 | "[5, 7, 9, 11, 13, 15, 17, 19]"
434 | ]
435 | },
436 | "execution_count": 41,
437 | "metadata": {},
438 | "output_type": "execute_result"
439 | }
440 | ],
441 | "source": [
442 | "c = list(range(5,20,2)) # 5 ile 20 arasında 2'şer aralıklarla sayı üretir\n",
443 | "c"
444 | ]
445 | },
446 | {
447 | "cell_type": "code",
448 | "execution_count": 42,
449 | "metadata": {},
450 | "outputs": [
451 | {
452 | "name": "stdout",
453 | "output_type": "stream",
454 | "text": [
455 | "5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95\n"
456 | ]
457 | }
458 | ],
459 | "source": [
460 | "print(*range(5,100,5)) # 5'ten 100'e kadar olan 5'er aralıklarla sayılar"
461 | ]
462 | },
463 | {
464 | "cell_type": "markdown",
465 | "metadata": {},
466 | "source": [
467 | "**Diyelim ki geriye doğru sayılar üretmek istiyoruz, yani 10,9,8,7,6,5.... gibi**"
468 | ]
469 | },
470 | {
471 | "cell_type": "code",
472 | "execution_count": 46,
473 | "metadata": {},
474 | "outputs": [
475 | {
476 | "name": "stdout",
477 | "output_type": "stream",
478 | "text": [
479 | "10 9 8 7 6 5 4 3 2 1\n"
480 | ]
481 | }
482 | ],
483 | "source": [
484 | "print(*range(10,0,-1)) #0 dahil değildir. geriye doğru sayı üretmek için "
485 | ]
486 | },
487 | {
488 | "cell_type": "code",
489 | "execution_count": 47,
490 | "metadata": {},
491 | "outputs": [
492 | {
493 | "name": "stdout",
494 | "output_type": "stream",
495 | "text": [
496 | "* \n",
497 | "* * \n",
498 | "* * * \n",
499 | "* * * * \n",
500 | "* * * * * \n",
501 | "* * * * * * \n",
502 | "* * * * * * * \n",
503 | "* * * * * * * * \n",
504 | "* * * * * * * * * \n"
505 | ]
506 | }
507 | ],
508 | "source": [
509 | "for sayı in range(1,10):\n",
510 | " print(\"* \" * sayı)"
511 | ]
512 | },
513 | {
514 | "cell_type": "markdown",
515 | "metadata": {},
516 | "source": [
517 | "# break ve continue ifadeleri"
518 | ]
519 | },
520 | {
521 | "cell_type": "markdown",
522 | "metadata": {},
523 | "source": [
524 | "### break ifadesi"
525 | ]
526 | },
527 | {
528 | "cell_type": "markdown",
529 | "metadata": {},
530 | "source": [
531 | "break ifadesi döngülerde en çok kullanılan ifadedir. Anlamı şu şekildedir;\n",
532 | "\n",
533 | " Döngü herhangi bir yerde ve herhangi bir zamanda break ifadesiyle karşılaştığı zaman\n",
534 | " çalışmasını bir anda durdurur. Böylelikle döngü hiçbir koşula bağlı kalmadan sonlanmış olur.\n",
535 | " \n",
536 | " \n",
537 | "break ifadesi **sadece ve sadece** içindeki bulunduğu döngüyü sonlandırır. Eğer iç içe döngüler bulunuyorsa ve en içteki döngüde break kullanılmışsa sadece içteki döngü sona erer. "
538 | ]
539 | },
540 | {
541 | "cell_type": "code",
542 | "execution_count": 48,
543 | "metadata": {},
544 | "outputs": [
545 | {
546 | "name": "stdout",
547 | "output_type": "stream",
548 | "text": [
549 | "0\n",
550 | "1\n",
551 | "2\n",
552 | "3\n",
553 | "4\n",
554 | "5\n",
555 | "6\n",
556 | "7\n",
557 | "8\n",
558 | "9\n"
559 | ]
560 | }
561 | ],
562 | "source": [
563 | "i = 0 # Bu döngüyü biliyoruz. 0-10 arası sayıları ekrana yazıyor\n",
564 | "\n",
565 | "while (i < 10):\n",
566 | " print(i)\n",
567 | " i +=1"
568 | ]
569 | },
570 | {
571 | "cell_type": "code",
572 | "execution_count": 49,
573 | "metadata": {},
574 | "outputs": [
575 | {
576 | "name": "stdout",
577 | "output_type": "stream",
578 | "text": [
579 | "0\n",
580 | "1\n",
581 | "2\n",
582 | "3\n",
583 | "4\n",
584 | "5\n"
585 | ]
586 | }
587 | ],
588 | "source": [
589 | "# Şimdi ise sayıları ekrana yazdırırken sayı 5 olduğunda artık yazdırmayı keselim. Bunun için break kullanırız.\n",
590 | "i = 0 \n",
591 | "\n",
592 | "while (i < 10):\n",
593 | " print(i)\n",
594 | " if (i == 5):\n",
595 | " break # i'nin değeri 5 olunca bu koşul sağlanıyor ve break ifadesiyle karşılaşıldığı için döngü anında sona eriyor.\n",
596 | " i +=1"
597 | ]
598 | },
599 | {
600 | "cell_type": "code",
601 | "execution_count": 50,
602 | "metadata": {},
603 | "outputs": [
604 | {
605 | "name": "stdout",
606 | "output_type": "stream",
607 | "text": [
608 | "1\n",
609 | "2\n",
610 | "3\n",
611 | "4\n"
612 | ]
613 | }
614 | ],
615 | "source": [
616 | "# for döngüsüyle break kullanalım.\n",
617 | "liste = [1,2,3,4,5,6,7,8,9]\n",
618 | "for i in liste:\n",
619 | " if (i == 5):\n",
620 | " break\n",
621 | " print(i)"
622 | ]
623 | },
624 | {
625 | "cell_type": "markdown",
626 | "metadata": {},
627 | "source": [
628 | "### continue ifadesi\n",
629 | "*continue* ifadesi *break*'e göre biraz daha az kullanılan bir ifadedir. Anlamı şu şekildedir;\n",
630 | " \n",
631 | " Döngü herhangi bir yerde ve herhangi bir zamanda continue ifadesiyle karşılaştığı zaman geri kalan işlemlerini\n",
632 | " yapmadan direk bloğunun başına döner."
633 | ]
634 | },
635 | {
636 | "cell_type": "code",
637 | "execution_count": 53,
638 | "metadata": {},
639 | "outputs": [
640 | {
641 | "name": "stdout",
642 | "output_type": "stream",
643 | "text": [
644 | "eleman: 1\n",
645 | "eleman: 2\n",
646 | "eleman: 3\n",
647 | "eleman: 4\n",
648 | "eleman: 5\n",
649 | "eleman: 6\n",
650 | "eleman: 7\n",
651 | "eleman: 8\n",
652 | "eleman: 9\n",
653 | "eleman: 10\n"
654 | ]
655 | }
656 | ],
657 | "source": [
658 | "#Liste elemanlarını tek tek ekrana yazdıran program\n",
659 | "liste = [1,2,3,4,5,6,7,8,9,10]\n",
660 | "\n",
661 | "for eleman in liste:\n",
662 | " print(\"eleman:\",eleman)"
663 | ]
664 | },
665 | {
666 | "cell_type": "code",
667 | "execution_count": 55,
668 | "metadata": {},
669 | "outputs": [
670 | {
671 | "name": "stdout",
672 | "output_type": "stream",
673 | "text": [
674 | "eleman: 1\n",
675 | "eleman: 2\n",
676 | "eleman: 4\n",
677 | "eleman: 6\n",
678 | "eleman: 7\n",
679 | "eleman: 8\n",
680 | "eleman: 9\n"
681 | ]
682 | }
683 | ],
684 | "source": [
685 | "# Şimdi ise elemanlardan birisi 3 veya 5 ise onları ekrana yazdırmayan ama diğerlerini ekrana yazdıran programı \n",
686 | "#continue kullanarak yazalım\n",
687 | "\n",
688 | "liste = [1,2,3,4,5,6,7,8,9] \n",
689 | "\n",
690 | "for eleman in liste:\n",
691 | " if (eleman == 3 or eleman == 5):\n",
692 | " continue\n",
693 | " print(\"eleman:\",eleman)"
694 | ]
695 | },
696 | {
697 | "cell_type": "code",
698 | "execution_count": null,
699 | "metadata": {},
700 | "outputs": [],
701 | "source": []
702 | }
703 | ],
704 | "metadata": {
705 | "kernelspec": {
706 | "display_name": "Python 3",
707 | "language": "python",
708 | "name": "python3"
709 | },
710 | "language_info": {
711 | "codemirror_mode": {
712 | "name": "ipython",
713 | "version": 3
714 | },
715 | "file_extension": ".py",
716 | "mimetype": "text/x-python",
717 | "name": "python",
718 | "nbconvert_exporter": "python",
719 | "pygments_lexer": "ipython3",
720 | "version": "3.7.3"
721 | }
722 | },
723 | "nbformat": 4,
724 | "nbformat_minor": 2
725 | }
726 |
--------------------------------------------------------------------------------
/DERS 8 .ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## DERS 8 : UYGULAMA \n",
8 | "Bu derste de uygulamalarla devam edeceğiz. "
9 | ]
10 | },
11 | {
12 | "cell_type": "markdown",
13 | "metadata": {},
14 | "source": [
15 | "### UYGULAMA 1 : \n",
16 | "Kullanıcıdan bir dik üçgenin dik olan iki kenarını(a,b) alın ve hipotenüs uzunluğunu bulmaya çalışın.\n",
17 | "\n",
18 | "Hipotenüs Formülü: a^2 + b^2 = c^2"
19 | ]
20 | },
21 | {
22 | "cell_type": "code",
23 | "execution_count": 28,
24 | "metadata": {},
25 | "outputs": [
26 | {
27 | "name": "stdout",
28 | "output_type": "stream",
29 | "text": [
30 | "Üçgenin dik kenarından ilkini giriniz:6\n",
31 | "Üçgenin dik kenarından ikincisini giriniz : 8\n"
32 | ]
33 | },
34 | {
35 | "data": {
36 | "text/plain": [
37 | "10.0"
38 | ]
39 | },
40 | "execution_count": 28,
41 | "metadata": {},
42 | "output_type": "execute_result"
43 | }
44 | ],
45 | "source": [
46 | "a = int(input(\"Üçgenin dik kenarından ilkini giriniz:\"))\n",
47 | "b = int(input(\"Üçgenin dik kenarından ikincisini giriniz : \"))\n",
48 | "ckare = a**2 + b**2\n",
49 | "c = ckare**(1/2) #kök almak demektir \n",
50 | "c"
51 | ]
52 | },
53 | {
54 | "cell_type": "code",
55 | "execution_count": null,
56 | "metadata": {},
57 | "outputs": [],
58 | "source": []
59 | },
60 | {
61 | "cell_type": "markdown",
62 | "metadata": {},
63 | "source": [
64 | "### UYGULAMA 2 : \n",
65 | "\n",
66 | "**y = 5x + 8 doğrusu için kullanıcının girdiği x değerine karşılık gelen y değerini bulan programı yazalım.**\n",
67 | "\n"
68 | ]
69 | },
70 | {
71 | "cell_type": "code",
72 | "execution_count": 32,
73 | "metadata": {},
74 | "outputs": [
75 | {
76 | "name": "stdout",
77 | "output_type": "stream",
78 | "text": [
79 | "x değerini giriniz: -2.5\n",
80 | "Girdiğiniz -2.5 değerinin y ekseninde denk gelen değeri -4.5'dir.\n"
81 | ]
82 | }
83 | ],
84 | "source": [
85 | "x = float(input(\"x değerini giriniz: \"))\n",
86 | "#doğru denklemini yazmam gerekiyor\n",
87 | "y = 5*x + 8\n",
88 | "print(\"Girdiğiniz {} değerinin y ekseninde denk gelen değeri {}'dir.\".format(x,y))"
89 | ]
90 | },
91 | {
92 | "cell_type": "code",
93 | "execution_count": null,
94 | "metadata": {},
95 | "outputs": [],
96 | "source": []
97 | },
98 | {
99 | "cell_type": "markdown",
100 | "metadata": {},
101 | "source": [
102 | "### UYGULAMA 3 : \n",
103 | "Kullanıcıdan alınan ilk tüketim değeri ve son tüketim değeri bilgilerine göre harcanan elektrik fatura bedelini aşağıdaki gibi ekrana yazdıran Python programanı yazınız. (Elektriğin birim fiyatı 1.35 TL'dır.)\n",
104 | "\n",
105 | "**ÖRNEK PROGRAM ÇIKTISI**\n",
106 | "\n",
107 | "İlk tüketim değerini giriniz : 850\n",
108 | "\n",
109 | "Son tüketim değerini giriniz : 890\n",
110 | "\n",
111 | "Tüketim Miktarı : 40\n",
112 | "\n",
113 | "Tüketim Tutarı : 54 TL \n",
114 | "\n",
115 | "KDV (%18) : 9.72 TL \n",
116 | "\n",
117 | "\n",
118 | "\n",
119 | "**TOPLAM TUTAR : 63.72 TL** \n"
120 | ]
121 | },
122 | {
123 | "cell_type": "code",
124 | "execution_count": 34,
125 | "metadata": {},
126 | "outputs": [
127 | {
128 | "name": "stdout",
129 | "output_type": "stream",
130 | "text": [
131 | "İlk tüketim değerini giriniz: 850\n",
132 | "Son tüketim değerini giriniz: 890\n",
133 | "Tüketim miktarı: 40.0 \n",
134 | "Tüketim Tutarı: 54.0 TL\n",
135 | " KDV(%18): 9.72 TL\n",
136 | " TOPLAM TUTAR: 63.72 TL\n"
137 | ]
138 | }
139 | ],
140 | "source": [
141 | "ilk_tuketim = float(input(\"İlk tüketim değerini giriniz: \"))\n",
142 | "son_tuketim = float(input(\"Son tüketim değerini giriniz: \"))\n",
143 | "tuketim = son_tuketim - ilk_tuketim\n",
144 | "tuketim_tutarı = tuketim * 1.35 #Elektriğin birim fiyatı 1.35 TL'dır.\n",
145 | "kdv = tuketim_tutarı * 18 /100\n",
146 | "toplam_tutar = tuketim_tutarı + kdv \n",
147 | "print(\"Tüketim miktarı: \",tuketim, \"\\nTüketim Tutarı: \",tuketim_tutarı,\"TL\\n KDV(%18):\",kdv,\"TL\\n TOPLAM TUTAR:\",toplam_tutar, \"TL\")\n"
148 | ]
149 | },
150 | {
151 | "cell_type": "code",
152 | "execution_count": null,
153 | "metadata": {},
154 | "outputs": [],
155 | "source": []
156 | },
157 | {
158 | "cell_type": "markdown",
159 | "metadata": {},
160 | "source": [
161 | "#### mod, % , bölümünden kalan işlemi \n",
162 | "\n",
163 | "mod diye bilinen % işareti bölümünden kalan demektir. Eğer kalan sıfır ise o sayı bölünen sayıya tam bölünüyor demektir. \n",
164 | "\n",
165 | "Yani 10 sayısını 2 ye böldüğümüzde kalan 0, 10 sayısı 2ye tam bölünüyor demektir. "
166 | ]
167 | },
168 | {
169 | "cell_type": "code",
170 | "execution_count": 2,
171 | "metadata": {},
172 | "outputs": [
173 | {
174 | "data": {
175 | "text/plain": [
176 | "0"
177 | ]
178 | },
179 | "execution_count": 2,
180 | "metadata": {},
181 | "output_type": "execute_result"
182 | }
183 | ],
184 | "source": [
185 | "#Örnek \n",
186 | "kalan = 10 % 2 #tam bölündüğü için kalan sıfır oldu\n",
187 | "kalan"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": 4,
193 | "metadata": {},
194 | "outputs": [
195 | {
196 | "data": {
197 | "text/plain": [
198 | "2"
199 | ]
200 | },
201 | "execution_count": 4,
202 | "metadata": {},
203 | "output_type": "execute_result"
204 | }
205 | ],
206 | "source": [
207 | "#Örnek\n",
208 | "kalan = 10 % 4\n",
209 | "kalan"
210 | ]
211 | },
212 | {
213 | "cell_type": "code",
214 | "execution_count": 6,
215 | "metadata": {},
216 | "outputs": [
217 | {
218 | "data": {
219 | "text/plain": [
220 | "4"
221 | ]
222 | },
223 | "execution_count": 6,
224 | "metadata": {},
225 | "output_type": "execute_result"
226 | }
227 | ],
228 | "source": [
229 | "#Örnek\n",
230 | "kalan = 100 % 8\n",
231 | "kalan"
232 | ]
233 | },
234 | {
235 | "cell_type": "markdown",
236 | "metadata": {},
237 | "source": [
238 | "mod işlemini genelde bir tam sayının ondalık basamaklarını bulmak ya da saniye cinsinden verilen zamanı saat ve dakikaya çevirirken kullanırız. "
239 | ]
240 | },
241 | {
242 | "cell_type": "markdown",
243 | "metadata": {},
244 | "source": [
245 | "### UYGULAMA 4 : \n",
246 | "\n",
247 | "Klavyeden girilen 3 basamaklı sayının basamaklarını mod (%) işlemi ile bulunuz. "
248 | ]
249 | },
250 | {
251 | "cell_type": "code",
252 | "execution_count": 15,
253 | "metadata": {},
254 | "outputs": [
255 | {
256 | "name": "stdout",
257 | "output_type": "stream",
258 | "text": [
259 | "3 basamaklı bir sayı giriniz: 589\n",
260 | "Girilen 589 sayısının birler basamağı 9, onlar basamağı 8 ve yüzler basamağı 5'dir'\n"
261 | ]
262 | }
263 | ],
264 | "source": [
265 | "sayi=int(input(\"3 basamaklı bir sayı giriniz: \"))\n",
266 | "birler = int(sayi%10)\n",
267 | "onlar = int((sayi/10)%10)\n",
268 | "yuzler = int(sayi/100)\n",
269 | "\n",
270 | "print(\"Girilen {} sayısının birler basamağı {}, onlar basamağı {} ve yüzler basamağı {}'dir'\".format(sayi,birler,onlar,yuzler))"
271 | ]
272 | },
273 | {
274 | "cell_type": "code",
275 | "execution_count": null,
276 | "metadata": {},
277 | "outputs": [],
278 | "source": []
279 | },
280 | {
281 | "cell_type": "markdown",
282 | "metadata": {},
283 | "source": [
284 | "### UYGULAMA 5 : \n",
285 | "Kullanıcıdan saniye cinsinden alınan süreyi saat , dakika ve saniye cinsine dönüştürüp ekrana yazan programı yazınız. \n",
286 | "\n",
287 | " **ÖRNEK ÇIKTI**\n",
288 | " \n",
289 | " Lütfen saniye cinsinden süreyi giriniz : 7322\n",
290 | " \n",
291 | " Girilen bu süre 2 saat, 2 dakika, 2 saniye etmektedir. "
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": 2,
297 | "metadata": {},
298 | "outputs": [
299 | {
300 | "name": "stdout",
301 | "output_type": "stream",
302 | "text": [
303 | "Lütfen saniye cinsinden süreyi giriniz: 7322\n",
304 | "Girilen bu süre 2 saat, 2 dakika, 2 saniye etmektedir.\n"
305 | ]
306 | }
307 | ],
308 | "source": []
309 | },
310 | {
311 | "cell_type": "code",
312 | "execution_count": null,
313 | "metadata": {},
314 | "outputs": [],
315 | "source": []
316 | },
317 | {
318 | "cell_type": "markdown",
319 | "metadata": {},
320 | "source": [
321 | "### ÖDEV 8 : \n",
322 | "\n",
323 | "**1 ) Klavyeden girilen 4 basamaklı sayının basamaklarını mod (%) işlemi ile bulunuz.** "
324 | ]
325 | },
326 | {
327 | "cell_type": "markdown",
328 | "metadata": {},
329 | "source": [
330 | "**2) Bir su faturası hesaplama programı tasarlayınız.** \n",
331 | "\n",
332 | "Kullanıcıdan ilk su okuma birimini ve son su okuma birimini alarak son harcanan suyun metreküpünü bulunuz. \n",
333 | "Ardından metreküp başına kullanım fiyatı olan 2 TL ile çarpınız. \n",
334 | "Ve %22 oranında KDV tutarını da ekleyip ödecenecek toplam tutarı belirleyiniz. \n",
335 | "\n",
336 | "**Örnek Program Çıktısı**\n",
337 | "\n",
338 | "İlk su okuma biriminiz giriniz : 150\n",
339 | "\n",
340 | "Son su okuma birimini giriniz : 200\n",
341 | "\n",
342 | "Tüketim biriminiz : 50\n",
343 | "\n",
344 | "Tüketim Tutarı : 100 TL \n",
345 | "\n",
346 | "KDV (%22) : 22 TL \n",
347 | "\n",
348 | "\n",
349 | "TOPLAM TUTAR : 122 TL \n"
350 | ]
351 | },
352 | {
353 | "cell_type": "code",
354 | "execution_count": null,
355 | "metadata": {},
356 | "outputs": [],
357 | "source": []
358 | }
359 | ],
360 | "metadata": {
361 | "kernelspec": {
362 | "display_name": "Python 3",
363 | "language": "python",
364 | "name": "python3"
365 | },
366 | "language_info": {
367 | "codemirror_mode": {
368 | "name": "ipython",
369 | "version": 3
370 | },
371 | "file_extension": ".py",
372 | "mimetype": "text/x-python",
373 | "name": "python",
374 | "nbconvert_exporter": "python",
375 | "pygments_lexer": "ipython3",
376 | "version": "3.7.3"
377 | }
378 | },
379 | "nbformat": 4,
380 | "nbformat_minor": 2
381 | }
382 |
--------------------------------------------------------------------------------
/DERS NOTU - 3.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### DERS 3"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### VERİ TİPLERİ (DATA TYPES)"
15 | ]
16 | },
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {},
20 | "source": [
21 | "\n",
22 | "- Sayılar : Tam Sayı ya da Ondalıklı Sayı (Numbers : İnteger & Float)\n",
23 | "- Karakter Dizileri (String)\n",
24 | "- Boolean (True / False)\n",
25 | "- Listeler (Liste)\n",
26 | "- Demetler (Tuple)\n",
27 | "- Sözlükler (Dictionary)\n",
28 | "- Kümeler (Set)"
29 | ]
30 | },
31 | {
32 | "cell_type": "markdown",
33 | "metadata": {},
34 | "source": [
35 | "## 1) SAYILAR (NUMBERS)\n",
36 | "Sayılar kısmını daha önce detaylı olarak işledik. Kısaca örneklerle devam edelim. İntegerı floata float sayıyı integere dönüştürelim."
37 | ]
38 | },
39 | {
40 | "cell_type": "code",
41 | "execution_count": 1,
42 | "metadata": {},
43 | "outputs": [
44 | {
45 | "name": "stdout",
46 | "output_type": "stream",
47 | "text": [
48 | "2\n"
49 | ]
50 | }
51 | ],
52 | "source": [
53 | "a = 1 \n",
54 | "a = a+1\n",
55 | "print(a)"
56 | ]
57 | },
58 | {
59 | "cell_type": "code",
60 | "execution_count": 2,
61 | "metadata": {},
62 | "outputs": [
63 | {
64 | "name": "stdout",
65 | "output_type": "stream",
66 | "text": [
67 | "2\n"
68 | ]
69 | }
70 | ],
71 | "source": [
72 | "a = 1\n",
73 | "a +=1\n",
74 | "print(a)"
75 | ]
76 | },
77 | {
78 | "cell_type": "code",
79 | "execution_count": 3,
80 | "metadata": {},
81 | "outputs": [
82 | {
83 | "name": "stdout",
84 | "output_type": "stream",
85 | "text": [
86 | "2\n"
87 | ]
88 | }
89 | ],
90 | "source": [
91 | "b = 3\n",
92 | "b = b-1\n",
93 | "print(b)"
94 | ]
95 | },
96 | {
97 | "cell_type": "code",
98 | "execution_count": 4,
99 | "metadata": {},
100 | "outputs": [
101 | {
102 | "name": "stdout",
103 | "output_type": "stream",
104 | "text": [
105 | "2\n"
106 | ]
107 | }
108 | ],
109 | "source": [
110 | "b = 3\n",
111 | "b -=1 # b değerini 1 azaltır\n",
112 | "print(b)"
113 | ]
114 | },
115 | {
116 | "cell_type": "code",
117 | "execution_count": 5,
118 | "metadata": {},
119 | "outputs": [
120 | {
121 | "name": "stdout",
122 | "output_type": "stream",
123 | "text": [
124 | "6\n"
125 | ]
126 | }
127 | ],
128 | "source": [
129 | "c = 3\n",
130 | "c *=2\n",
131 | "print(c)"
132 | ]
133 | },
134 | {
135 | "cell_type": "code",
136 | "execution_count": 6,
137 | "metadata": {},
138 | "outputs": [
139 | {
140 | "name": "stdout",
141 | "output_type": "stream",
142 | "text": [
143 | "5.0\n"
144 | ]
145 | }
146 | ],
147 | "source": [
148 | "d = 10\n",
149 | "d /=2\n",
150 | "print(d)"
151 | ]
152 | },
153 | {
154 | "cell_type": "code",
155 | "execution_count": 11,
156 | "metadata": {},
157 | "outputs": [
158 | {
159 | "data": {
160 | "text/plain": [
161 | "float"
162 | ]
163 | },
164 | "execution_count": 11,
165 | "metadata": {},
166 | "output_type": "execute_result"
167 | }
168 | ],
169 | "source": [
170 | "sayi = 5.3\n",
171 | "type(sayi)"
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": 12,
177 | "metadata": {},
178 | "outputs": [
179 | {
180 | "name": "stdout",
181 | "output_type": "stream",
182 | "text": [
183 | "5\n"
184 | ]
185 | },
186 | {
187 | "data": {
188 | "text/plain": [
189 | "int"
190 | ]
191 | },
192 | "execution_count": 12,
193 | "metadata": {},
194 | "output_type": "execute_result"
195 | }
196 | ],
197 | "source": [
198 | "sayi = int(sayi)\n",
199 | "print(sayi)\n",
200 | "type(sayi)"
201 | ]
202 | },
203 | {
204 | "cell_type": "code",
205 | "execution_count": 13,
206 | "metadata": {},
207 | "outputs": [
208 | {
209 | "name": "stdout",
210 | "output_type": "stream",
211 | "text": [
212 | "5\n"
213 | ]
214 | }
215 | ],
216 | "source": [
217 | "sayi = 5.8\n",
218 | "type(sayi)\n",
219 | "sayi=int(sayi)\n",
220 | "print(sayi)"
221 | ]
222 | },
223 | {
224 | "cell_type": "code",
225 | "execution_count": 14,
226 | "metadata": {},
227 | "outputs": [
228 | {
229 | "data": {
230 | "text/plain": [
231 | "float"
232 | ]
233 | },
234 | "execution_count": 14,
235 | "metadata": {},
236 | "output_type": "execute_result"
237 | }
238 | ],
239 | "source": [
240 | "deger = 5.8\n",
241 | "type(deger)\n"
242 | ]
243 | },
244 | {
245 | "cell_type": "code",
246 | "execution_count": 16,
247 | "metadata": {},
248 | "outputs": [
249 | {
250 | "name": "stdout",
251 | "output_type": "stream",
252 | "text": [
253 | "6\n"
254 | ]
255 | },
256 | {
257 | "data": {
258 | "text/plain": [
259 | "int"
260 | ]
261 | },
262 | "execution_count": 16,
263 | "metadata": {},
264 | "output_type": "execute_result"
265 | }
266 | ],
267 | "source": [
268 | "#round fonksiyonu içerisine yazılan değeri yuvarlamaya yarar.\n",
269 | "\n",
270 | "deger = 5.8\n",
271 | "deger = round(deger)\n",
272 | "print(deger)\n",
273 | "type(deger)"
274 | ]
275 | },
276 | {
277 | "cell_type": "code",
278 | "execution_count": 19,
279 | "metadata": {},
280 | "outputs": [
281 | {
282 | "data": {
283 | "text/plain": [
284 | "float"
285 | ]
286 | },
287 | "execution_count": 19,
288 | "metadata": {},
289 | "output_type": "execute_result"
290 | }
291 | ],
292 | "source": [
293 | "number = 6.6\n",
294 | "type(number)"
295 | ]
296 | },
297 | {
298 | "cell_type": "code",
299 | "execution_count": 21,
300 | "metadata": {},
301 | "outputs": [
302 | {
303 | "name": "stdout",
304 | "output_type": "stream",
305 | "text": [
306 | "6\n"
307 | ]
308 | },
309 | {
310 | "data": {
311 | "text/plain": [
312 | "int"
313 | ]
314 | },
315 | "execution_count": 21,
316 | "metadata": {},
317 | "output_type": "execute_result"
318 | }
319 | ],
320 | "source": [
321 | "number = int(number)\n",
322 | "print(number)\n",
323 | "type(number)"
324 | ]
325 | },
326 | {
327 | "cell_type": "markdown",
328 | "metadata": {},
329 | "source": [
330 | "### MATEMATİKSEL İŞLEMLERİ BİR ARADA KULLANMAK \n",
331 | "\n",
332 | "İşlem sırasına dikkat etmek gereklidir. Kurallar şu şekildedir:\n",
333 | "- Parantez içi () her zaman önce yapılır\n",
334 | "- Çarpma ve bölme işlemi (* /) çıkarma ve toplama (- + ) işleminden önce yapılır\n",
335 | "- İşlemler soldan sağa değerlendirilir"
336 | ]
337 | },
338 | {
339 | "cell_type": "code",
340 | "execution_count": 42,
341 | "metadata": {},
342 | "outputs": [
343 | {
344 | "name": "stdout",
345 | "output_type": "stream",
346 | "text": [
347 | "14.0\n"
348 | ]
349 | }
350 | ],
351 | "source": [
352 | "islem1 = 8 + ((4*3) / 2)\n",
353 | "print(islem1)"
354 | ]
355 | },
356 | {
357 | "cell_type": "code",
358 | "execution_count": 43,
359 | "metadata": {},
360 | "outputs": [
361 | {
362 | "name": "stdout",
363 | "output_type": "stream",
364 | "text": [
365 | "18.0\n"
366 | ]
367 | }
368 | ],
369 | "source": [
370 | "islem2 = 20-10/5\n",
371 | "print(islem2)"
372 | ]
373 | },
374 | {
375 | "cell_type": "code",
376 | "execution_count": 44,
377 | "metadata": {},
378 | "outputs": [
379 | {
380 | "name": "stdout",
381 | "output_type": "stream",
382 | "text": [
383 | "13\n"
384 | ]
385 | }
386 | ],
387 | "source": [
388 | "islem3 = 8+8-6+3\n",
389 | "print(islem3)"
390 | ]
391 | },
392 | {
393 | "cell_type": "code",
394 | "execution_count": 45,
395 | "metadata": {},
396 | "outputs": [
397 | {
398 | "name": "stdout",
399 | "output_type": "stream",
400 | "text": [
401 | "2.0\n"
402 | ]
403 | }
404 | ],
405 | "source": [
406 | "islem4 = (8+8)/2-6\n",
407 | "print(islem4)"
408 | ]
409 | },
410 | {
411 | "cell_type": "code",
412 | "execution_count": 46,
413 | "metadata": {},
414 | "outputs": [
415 | {
416 | "name": "stdout",
417 | "output_type": "stream",
418 | "text": [
419 | "25.0\n"
420 | ]
421 | }
422 | ],
423 | "source": [
424 | "islem5 = (10*2)+(10/2)\n",
425 | "print(islem5)"
426 | ]
427 | },
428 | {
429 | "cell_type": "markdown",
430 | "metadata": {},
431 | "source": [
432 | "## 2) String (Karakter Dizileri)\n",
433 | "\n",
434 | "Karakter dizileri tanımlamak için tek tırnak, çift tırnak ya da üç tırnak kullanabiliriz.\n",
435 | "\n",
436 | "type = str\n",
437 | "\n",
438 | "'Ali' \n",
439 | "\n",
440 | "\"Ali\" \n",
441 | "\n",
442 | "\"\"\"Ali\"\"\" gibi"
443 | ]
444 | },
445 | {
446 | "cell_type": "code",
447 | "execution_count": 22,
448 | "metadata": {},
449 | "outputs": [
450 | {
451 | "data": {
452 | "text/plain": [
453 | "str"
454 | ]
455 | },
456 | "execution_count": 22,
457 | "metadata": {},
458 | "output_type": "execute_result"
459 | }
460 | ],
461 | "source": [
462 | "isim = \"Hatice\"\n",
463 | "type(isim)"
464 | ]
465 | },
466 | {
467 | "cell_type": "code",
468 | "execution_count": 30,
469 | "metadata": {},
470 | "outputs": [
471 | {
472 | "name": "stdout",
473 | "output_type": "stream",
474 | "text": [
475 | "ders 3\n"
476 | ]
477 | },
478 | {
479 | "data": {
480 | "text/plain": [
481 | "str"
482 | ]
483 | },
484 | "execution_count": 30,
485 | "metadata": {},
486 | "output_type": "execute_result"
487 | }
488 | ],
489 | "source": [
490 | "a=\"\"\"ders 3\"\"\"\n",
491 | "print(a)\n",
492 | "type(a)"
493 | ]
494 | },
495 | {
496 | "cell_type": "code",
497 | "execution_count": null,
498 | "metadata": {},
499 | "outputs": [],
500 | "source": [
501 | "ad_soyad= 'Hatice Candan'\n",
502 | "print(ad_soyad)\n",
503 | "type(ad_soyad)"
504 | ]
505 | },
506 | {
507 | "cell_type": "code",
508 | "execution_count": 34,
509 | "metadata": {},
510 | "outputs": [
511 | {
512 | "name": "stdout",
513 | "output_type": "stream",
514 | "text": [
515 | "Türkiye'nin başkenti Ankara'dır.\n"
516 | ]
517 | }
518 | ],
519 | "source": [
520 | "#kesme işaretleri karışmaması için çift tırnak kullanılır\n",
521 | "cumle = \"Türkiye'nin başkenti Ankara'dır.\"\n",
522 | "print(cumle)"
523 | ]
524 | },
525 | {
526 | "cell_type": "code",
527 | "execution_count": 47,
528 | "metadata": {},
529 | "outputs": [
530 | {
531 | "data": {
532 | "text/plain": [
533 | "\"Türkiye'nin başkenti Ankara'dır. 25 yıldır Ankara'da yaşıyorum. \""
534 | ]
535 | },
536 | "execution_count": 47,
537 | "metadata": {},
538 | "output_type": "execute_result"
539 | }
540 | ],
541 | "source": [
542 | "#alt satıra inme işlemi '\\n' ile yapılır \n",
543 | "cumle1 = \"Türkiye'nin başkenti Ankara'dır. 25 yıldır Ankara'da yaşıyorum. \"\n",
544 | "cumle1"
545 | ]
546 | },
547 | {
548 | "cell_type": "code",
549 | "execution_count": 48,
550 | "metadata": {},
551 | "outputs": [
552 | {
553 | "name": "stdout",
554 | "output_type": "stream",
555 | "text": [
556 | "Türkiye'nin başkenti Ankara'dır. 25 yıldır Ankara'da yaşıyorum. \n",
557 | "Türkiye'nin başkenti Ankara'dır.\n",
558 | "25 yıldır Ankara'da yaşıyorum. \n"
559 | ]
560 | }
561 | ],
562 | "source": [
563 | "cumle2 = \"Türkiye'nin başkenti Ankara'dır.\\n25 yıldır Ankara'da yaşıyorum. \"\n",
564 | "print(cumle1)\n",
565 | "print(cumle2)"
566 | ]
567 | },
568 | {
569 | "cell_type": "markdown",
570 | "metadata": {},
571 | "source": [
572 | "### Stringlerde İndeksleme\n",
573 | "\n",
574 | "Stringler birer karakter dizisidir ve içindeki karakterlerin herbirinin yeri vardır. Bu karakterlerin yerlerine \"indeks\" denir.\n",
575 | "\n",
576 | "Stringlerin indekslemesi 0 ile başlar.\n",
577 | "İndeksleme işlemi için [] kullanılır.\n",
578 | "\n",
579 | "Formül şu şekildedir:\n",
580 | "\n",
581 | "[başlama noktası:bitiş noktası : atlama değeri]"
582 | ]
583 | },
584 | {
585 | "cell_type": "code",
586 | "execution_count": 32,
587 | "metadata": {},
588 | "outputs": [
589 | {
590 | "data": {
591 | "text/plain": [
592 | "'H'"
593 | ]
594 | },
595 | "execution_count": 32,
596 | "metadata": {},
597 | "output_type": "execute_result"
598 | }
599 | ],
600 | "source": [
601 | "# indekleme şu şekilde yapılır : [başlangıç : bitiş : atlama sayısı]\n",
602 | "\n",
603 | "ad_soyad= 'Hatice Candan'\n",
604 | "ad_soyad[0]"
605 | ]
606 | },
607 | {
608 | "cell_type": "code",
609 | "execution_count": 24,
610 | "metadata": {},
611 | "outputs": [
612 | {
613 | "data": {
614 | "text/plain": [
615 | "'a'"
616 | ]
617 | },
618 | "execution_count": 24,
619 | "metadata": {},
620 | "output_type": "execute_result"
621 | }
622 | ],
623 | "source": [
624 | "ad_soyad[1]"
625 | ]
626 | },
627 | {
628 | "cell_type": "code",
629 | "execution_count": 25,
630 | "metadata": {},
631 | "outputs": [
632 | {
633 | "data": {
634 | "text/plain": [
635 | "'e'"
636 | ]
637 | },
638 | "execution_count": 25,
639 | "metadata": {},
640 | "output_type": "execute_result"
641 | }
642 | ],
643 | "source": [
644 | "ad_soyad[5]"
645 | ]
646 | },
647 | {
648 | "cell_type": "code",
649 | "execution_count": 26,
650 | "metadata": {},
651 | "outputs": [
652 | {
653 | "data": {
654 | "text/plain": [
655 | "' '"
656 | ]
657 | },
658 | "execution_count": 26,
659 | "metadata": {},
660 | "output_type": "execute_result"
661 | }
662 | ],
663 | "source": [
664 | "ad_soyad[6]"
665 | ]
666 | },
667 | {
668 | "cell_type": "code",
669 | "execution_count": 27,
670 | "metadata": {},
671 | "outputs": [
672 | {
673 | "data": {
674 | "text/plain": [
675 | "'n'"
676 | ]
677 | },
678 | "execution_count": 27,
679 | "metadata": {},
680 | "output_type": "execute_result"
681 | }
682 | ],
683 | "source": [
684 | "ad_soyad[9]"
685 | ]
686 | },
687 | {
688 | "cell_type": "code",
689 | "execution_count": 49,
690 | "metadata": {},
691 | "outputs": [
692 | {
693 | "data": {
694 | "text/plain": [
695 | "'Hatic'"
696 | ]
697 | },
698 | "execution_count": 49,
699 | "metadata": {},
700 | "output_type": "execute_result"
701 | }
702 | ],
703 | "source": [
704 | "ad_soyad[0:6]"
705 | ]
706 | },
707 | {
708 | "cell_type": "code",
709 | "execution_count": 41,
710 | "metadata": {},
711 | "outputs": [
712 | {
713 | "data": {
714 | "text/plain": [
715 | "'Candan'"
716 | ]
717 | },
718 | "execution_count": 41,
719 | "metadata": {},
720 | "output_type": "execute_result"
721 | }
722 | ],
723 | "source": [
724 | "ad_soyad[7:13]"
725 | ]
726 | },
727 | {
728 | "cell_type": "code",
729 | "execution_count": 50,
730 | "metadata": {},
731 | "outputs": [
732 | {
733 | "data": {
734 | "text/plain": [
735 | "'Htc adn'"
736 | ]
737 | },
738 | "execution_count": 50,
739 | "metadata": {},
740 | "output_type": "execute_result"
741 | }
742 | ],
743 | "source": [
744 | "ad_soyad[0:13:2]"
745 | ]
746 | },
747 | {
748 | "cell_type": "code",
749 | "execution_count": 51,
750 | "metadata": {},
751 | "outputs": [
752 | {
753 | "data": {
754 | "text/plain": [
755 | "'n'"
756 | ]
757 | },
758 | "execution_count": 51,
759 | "metadata": {},
760 | "output_type": "execute_result"
761 | }
762 | ],
763 | "source": [
764 | "ad_soyad[-1] #karakter dizisinin son elemanını getirir."
765 | ]
766 | },
767 | {
768 | "cell_type": "code",
769 | "execution_count": null,
770 | "metadata": {},
771 | "outputs": [],
772 | "source": []
773 | },
774 | {
775 | "cell_type": "code",
776 | "execution_count": null,
777 | "metadata": {},
778 | "outputs": [],
779 | "source": []
780 | },
781 | {
782 | "cell_type": "markdown",
783 | "metadata": {},
784 | "source": [
785 | "## Stringin Uzunluğunu Bulmak\n",
786 | "\n",
787 | "String karakter dizisinin boyu len() fonksiyonu ile bulunur.\n"
788 | ]
789 | },
790 | {
791 | "cell_type": "code",
792 | "execution_count": 52,
793 | "metadata": {},
794 | "outputs": [
795 | {
796 | "name": "stdout",
797 | "output_type": "stream",
798 | "text": [
799 | "13\n"
800 | ]
801 | }
802 | ],
803 | "source": [
804 | "boyu = len(ad_soyad) #len() fonksiyonu dizinin boyunu söyler. \n",
805 | "print(boyu)"
806 | ]
807 | },
808 | {
809 | "cell_type": "markdown",
810 | "metadata": {},
811 | "source": [
812 | "# ÖDEV 3 \n",
813 | "\n"
814 | ]
815 | },
816 | {
817 | "cell_type": "code",
818 | "execution_count": null,
819 | "metadata": {},
820 | "outputs": [],
821 | "source": [
822 | "a = 5 \n",
823 | "b = 6\n",
824 | "a +=1\n",
825 | "b -=2\n",
826 | "c= a+2*b\n",
827 | "\n",
828 | "c değişkeninin değeri nedir ?"
829 | ]
830 | },
831 | {
832 | "cell_type": "markdown",
833 | "metadata": {},
834 | "source": [
835 | "Aşağıdaki işlemlerin sonucu ne olur ? \n",
836 | "\n",
837 | " - ((10**2) / 4) + 5\n",
838 | " - 27 - 8/2 + 8/4\n",
839 | " - (2**3)*5 + 16-7\n",
840 | " - 5+5+5-5*3\n",
841 | " - 6+(9/3)*5"
842 | ]
843 | },
844 | {
845 | "cell_type": "code",
846 | "execution_count": null,
847 | "metadata": {},
848 | "outputs": [],
849 | "source": [
850 | "cumle = \"Python ile kodlama yapmayı öğreniyorum\"\n",
851 | "\n",
852 | "Yukarıda verilen cumle karakter dizisi(string) için aşağıdaki kodlamaların çıktısı ne olur?\n",
853 | "\n",
854 | "- cumle[8]\n",
855 | "- cumle[24]\n",
856 | "- cumle[0:6]\n",
857 | "- cumle[11:14]\n",
858 | "- cumle[19:22]\n",
859 | "- len(cumle)\n",
860 | "- cumle[0:26:2]\n",
861 | "\n",
862 | "Aşağıdaki çıktıları elde edebilmek için nasıl bir kodlama satırı yazılmalıdır?\n",
863 | "\n",
864 | "- 'ile' \n",
865 | "- 'ğ'\n",
866 | "- 'öğreniyorum'\n",
867 | "- 'Python'\n",
868 | "- 'dlama yap'\n",
869 | "- 'ö'\n",
870 | "\n"
871 | ]
872 | },
873 | {
874 | "cell_type": "code",
875 | "execution_count": null,
876 | "metadata": {},
877 | "outputs": [],
878 | "source": []
879 | },
880 | {
881 | "cell_type": "code",
882 | "execution_count": null,
883 | "metadata": {},
884 | "outputs": [],
885 | "source": []
886 | },
887 | {
888 | "cell_type": "code",
889 | "execution_count": null,
890 | "metadata": {},
891 | "outputs": [],
892 | "source": []
893 | },
894 | {
895 | "cell_type": "code",
896 | "execution_count": null,
897 | "metadata": {},
898 | "outputs": [],
899 | "source": []
900 | },
901 | {
902 | "cell_type": "code",
903 | "execution_count": null,
904 | "metadata": {},
905 | "outputs": [],
906 | "source": []
907 | },
908 | {
909 | "cell_type": "code",
910 | "execution_count": null,
911 | "metadata": {},
912 | "outputs": [],
913 | "source": []
914 | },
915 | {
916 | "cell_type": "code",
917 | "execution_count": null,
918 | "metadata": {},
919 | "outputs": [],
920 | "source": []
921 | },
922 | {
923 | "cell_type": "code",
924 | "execution_count": null,
925 | "metadata": {},
926 | "outputs": [],
927 | "source": []
928 | },
929 | {
930 | "cell_type": "code",
931 | "execution_count": null,
932 | "metadata": {},
933 | "outputs": [],
934 | "source": []
935 | },
936 | {
937 | "cell_type": "code",
938 | "execution_count": null,
939 | "metadata": {},
940 | "outputs": [],
941 | "source": []
942 | },
943 | {
944 | "cell_type": "code",
945 | "execution_count": null,
946 | "metadata": {},
947 | "outputs": [],
948 | "source": []
949 | },
950 | {
951 | "cell_type": "code",
952 | "execution_count": null,
953 | "metadata": {},
954 | "outputs": [],
955 | "source": []
956 | },
957 | {
958 | "cell_type": "code",
959 | "execution_count": null,
960 | "metadata": {},
961 | "outputs": [],
962 | "source": []
963 | },
964 | {
965 | "cell_type": "code",
966 | "execution_count": null,
967 | "metadata": {},
968 | "outputs": [],
969 | "source": []
970 | }
971 | ],
972 | "metadata": {
973 | "kernelspec": {
974 | "display_name": "Python 3",
975 | "language": "python",
976 | "name": "python3"
977 | },
978 | "language_info": {
979 | "codemirror_mode": {
980 | "name": "ipython",
981 | "version": 3
982 | },
983 | "file_extension": ".py",
984 | "mimetype": "text/x-python",
985 | "name": "python",
986 | "nbconvert_exporter": "python",
987 | "pygments_lexer": "ipython3",
988 | "version": "3.7.3"
989 | }
990 | },
991 | "nbformat": 4,
992 | "nbformat_minor": 2
993 | }
994 |
--------------------------------------------------------------------------------
/DERS-14.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 14"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### ÖDEV 13 CEVABI:"
15 | ]
16 | },
17 | {
18 | "cell_type": "code",
19 | "execution_count": 8,
20 | "metadata": {},
21 | "outputs": [
22 | {
23 | "name": "stdout",
24 | "output_type": "stream",
25 | "text": [
26 | "Birinci Sayıyı Giriniz:40\n",
27 | "İkinci Sayıyı Giriniz:50\n",
28 | "İşlem Numarasını Seçiniz:8\n",
29 | "Geçersiz İşlem numarası girdiniz ! Lütfen geçerli bir işlem giriniz\n"
30 | ]
31 | }
32 | ],
33 | "source": [
34 | "#1\n",
35 | "\n",
36 | "sayi1 = int(input(\"Birinci Sayıyı Giriniz:\")) \n",
37 | "sayi2 = int(input(\"İkinci Sayıyı Giriniz:\")) \n",
38 | "\n",
39 | "işlem = input(\"İşlem Numarasını Seçiniz:\") \n",
40 | "\n",
41 | "if (işlem == \"1\"): \n",
42 | "\n",
43 | " print(\"Yapılan işlem sonrası cevap {} dır.\".format(sayi1+sayi2))\n",
44 | "elif (işlem == \"2\"):\n",
45 | "\n",
46 | " print(\"Yapılan işlem sonrası cevap {} dır.\".format(sayi1 - sayi2))\n",
47 | "\n",
48 | "elif (işlem == \"3\"):\n",
49 | "\n",
50 | " print(\"Yapılan işlem sonrası cevap {} dır.\".format( sayi1 * sayi2))\n",
51 | "\n",
52 | "elif (işlem == \"4\"):\n",
53 | "\n",
54 | " print(\"Yapılan işlem sonrası cevap {} dır.\".format( sayi1 / sayi2))\n",
55 | "else:\n",
56 | "\n",
57 | " print(\"Geçersiz İşlem numarası girdiniz ! Lütfen geçerli bir işlem giriniz\")\n"
58 | ]
59 | },
60 | {
61 | "cell_type": "code",
62 | "execution_count": 10,
63 | "metadata": {},
64 | "outputs": [
65 | {
66 | "name": "stdout",
67 | "output_type": "stream",
68 | "text": [
69 | "lütfen bir sayı giriniz:122\n",
70 | "Girdiğiniz sayı mutlu sayı\n"
71 | ]
72 | }
73 | ],
74 | "source": [
75 | "#2\n",
76 | "sayi = int(input(\"lütfen bir sayı giriniz:\"))\n",
77 | "\n",
78 | "birler = int(sayi%10)\n",
79 | "onlar = int((sayi/10)%10)\n",
80 | "\n",
81 | "if birler == onlar:\n",
82 | " print(\"Girdiğiniz sayı mutlu sayı\")\n",
83 | "else:\n",
84 | " print(\"Girdiğiniz sayı üzgün sayı\")"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 2,
90 | "metadata": {},
91 | "outputs": [
92 | {
93 | "name": "stdout",
94 | "output_type": "stream",
95 | "text": [
96 | "İlk sayıyı giriniz:50\n",
97 | "İkinci sayıyı giriniz:20\n",
98 | "Üçüncü sayıyı giriniz:68\n",
99 | "En büyük sayı: 68\n"
100 | ]
101 | }
102 | ],
103 | "source": [
104 | "#3\n",
105 | "sayi1 = int(input(\"İlk sayıyı giriniz:\"))\n",
106 | "\n",
107 | "sayi2 = int(input(\"İkinci sayıyı giriniz:\"))\n",
108 | "\n",
109 | "sayi3 = int(input(\"Üçüncü sayıyı giriniz:\"))\n",
110 | "\n",
111 | "if (sayi1 >= sayi2 and sayi1 >= sayi3):\n",
112 | " print(\"En büyük sayı:\",sayi1)\n",
113 | "elif (sayi2 >= sayi1 and sayi2 >= sayi3):\n",
114 | " print(\"En büyük sayı:\",sayi2)\n",
115 | "elif (sayi3 >= sayi1 and sayi3 >= sayi2):\n",
116 | " print(\"En büyük sayı:\",sayi3)"
117 | ]
118 | },
119 | {
120 | "cell_type": "code",
121 | "execution_count": null,
122 | "metadata": {},
123 | "outputs": [],
124 | "source": []
125 | },
126 | {
127 | "cell_type": "markdown",
128 | "metadata": {},
129 | "source": [
130 | "## UYGULAMA :\n",
131 | "**Kullanıcıdan alınan üçgen kenarları bilgisine göre üçgenin tipini bulan programı yazınız.**\n",
132 | "\n",
133 | "Kullanıcıdan 3 adet kenar almamız gerekmektedir. \n",
134 | "\n",
135 | "- Üçgenin ikizkenar mı , eşkenar mı yoksa sıradan bir üçgen mi olduğunu bulan,\n",
136 | " - Eğer verilen kenarlar bir üçgen belirtmiyorsa da ekrana \"Girdiğiniz kenarlar üçgen belirtmiyor\" şeklinde bir yazı yazan\n",
137 | "\n",
138 | "Programı yazınız. \n",
139 | "\n",
140 | "\n",
141 | "**Üçgen Belirtme Koşulu**\n",
142 | "\n",
143 | "abs(a+b) > c > abs(a-b) , abs(a+c) > b > abs(a-c), abs(b+c) > a >abs(b-c)"
144 | ]
145 | },
146 | {
147 | "cell_type": "code",
148 | "execution_count": 17,
149 | "metadata": {},
150 | "outputs": [
151 | {
152 | "name": "stdout",
153 | "output_type": "stream",
154 | "text": [
155 | "Kenar 1'i giriniz:8\n",
156 | "Kenar 2'yi giriniz:6\n",
157 | "Kenar 3'ü giriniz:8\n",
158 | "İkizkenar Üçgen\n"
159 | ]
160 | }
161 | ],
162 | "source": [
163 | "a = int(input(\"Kenar 1'i giriniz:\"))\n",
164 | "b = int(input(\"Kenar 2'yi giriniz:\"))\n",
165 | "c = int(input(\"Kenar 3'ü giriniz:\"))\n",
166 | "\n",
167 | "if (abs(b-c) < a < abs(a+b)) and (abs(a-c) < b < abs(a+c)) and (abs(a-b) < c < abs(a+b)):\n",
168 | " if (a==b) and (a==c):\n",
169 | " print(\"Eşkenar Üçgen\")\n",
170 | " elif ((a==b) and (a!=c)) or ((a==c) and (a!=b)) or ((b==c) and (b!=a)):\n",
171 | " print(\"İkizkenar Üçgen\")\n",
172 | " else:\n",
173 | " print(\"Sıradan Üçgen\")\n",
174 | "\n",
175 | "else:\n",
176 | " print(\"Girdiğiniz kenarlar üçgen belirtmiyor.\")\n",
177 | " "
178 | ]
179 | },
180 | {
181 | "cell_type": "code",
182 | "execution_count": null,
183 | "metadata": {},
184 | "outputs": [],
185 | "source": []
186 | },
187 | {
188 | "cell_type": "code",
189 | "execution_count": null,
190 | "metadata": {},
191 | "outputs": [],
192 | "source": []
193 | },
194 | {
195 | "cell_type": "code",
196 | "execution_count": null,
197 | "metadata": {},
198 | "outputs": [],
199 | "source": []
200 | },
201 | {
202 | "cell_type": "code",
203 | "execution_count": null,
204 | "metadata": {},
205 | "outputs": [],
206 | "source": []
207 | },
208 | {
209 | "cell_type": "code",
210 | "execution_count": null,
211 | "metadata": {},
212 | "outputs": [],
213 | "source": []
214 | },
215 | {
216 | "cell_type": "markdown",
217 | "metadata": {},
218 | "source": [
219 | "## UYGULAMA:\n",
220 | "Kullanıcının yaptığı seçime göre istenilen geometrik şeklin alanını bulan programı yazınız. \n",
221 | "\n",
222 | "Geometrik şekiller: üçgen , kare, dikdörtgen ve dairedir. \n",
223 | "\n",
224 | "**ÖRNEK ÇIKTI**\n",
225 | "\n",
226 | "**Lütfen geometrik şekil seçiminizi giriniz(üçgen, kare, dikdörtgen, daire) :** daire\n",
227 | "\n",
228 | "**Dairenin yarıçapını giriniz :** 5\n",
229 | "\n",
230 | "**Yarıçapı 5 olan dairenin alanı 75'dir.** \n"
231 | ]
232 | },
233 | {
234 | "cell_type": "code",
235 | "execution_count": 22,
236 | "metadata": {},
237 | "outputs": [
238 | {
239 | "name": "stdout",
240 | "output_type": "stream",
241 | "text": [
242 | "Lütfen geometrik şekil seçiminizi giriniz(üçgen, kare, dikdörtgen, daire):yamuk\n",
243 | "Yanlış bir seçim yaptınız lütfen tekrar seçim yapınız!\n"
244 | ]
245 | }
246 | ],
247 | "source": [
248 | "secim = input(\"Lütfen geometrik şekil seçiminizi giriniz(üçgen, kare, dikdörtgen, daire):\")\n",
249 | "\n",
250 | "if secim == \"üçgen\" :\n",
251 | " yukseklik = int(input(\"Üçgenin yüksekliğini giriniz:\"))\n",
252 | " taban = int(input(\"Üçgenin taban uzunluğunu giriniz:\"))\n",
253 | " alan = (taban * yukseklik)/2\n",
254 | " print(\"Yüksekliği {} olan taban uzunluğu {} olan üçgenin alanı {}'dur.\".format(yukseklik,taban,alan))\n",
255 | "\n",
256 | "elif secim ==\"kare\":\n",
257 | " kenar = int(input(\"Karenin bir kenarını giriniz:\"))\n",
258 | " alan = kenar**2\n",
259 | " print(\"Bir kenarı\",kenar, \"olan karenin alanı = \", alan)\n",
260 | "\n",
261 | "elif secim ==\"dikdörtgen\":\n",
262 | " uzunkenar = int(input(\"Lütfen uzun kenarı giriniz:\"))\n",
263 | " kısakenar = int(input(\"Lütfen kısa kenarı giriniz:\"))\n",
264 | " alan = uzunkenar * kısakenar\n",
265 | " print(\"Uzun kenarı\",uzunkenar,\"olan kısa kenarı\",kısakenar,\"olan dikdörtgenin alanı = \",alan)\n",
266 | " \n",
267 | "elif secim == \"daire\":\n",
268 | " yarıcap = int(input(\"Dairenin yarıçapını giriniz:\"))\n",
269 | " alan = 3 * yarıcap**2\n",
270 | " print(\"yarıçapı\",yarıcap,\"olan dairenin alanı=\",alan)\n",
271 | " \n",
272 | "else:\n",
273 | " print(\"Yanlış bir seçim yaptınız lütfen tekrar seçim yapınız!\")"
274 | ]
275 | },
276 | {
277 | "cell_type": "code",
278 | "execution_count": null,
279 | "metadata": {},
280 | "outputs": [],
281 | "source": []
282 | },
283 | {
284 | "cell_type": "code",
285 | "execution_count": null,
286 | "metadata": {},
287 | "outputs": [],
288 | "source": []
289 | },
290 | {
291 | "cell_type": "code",
292 | "execution_count": null,
293 | "metadata": {},
294 | "outputs": [],
295 | "source": []
296 | }
297 | ],
298 | "metadata": {
299 | "kernelspec": {
300 | "display_name": "Python 3",
301 | "language": "python",
302 | "name": "python3"
303 | },
304 | "language_info": {
305 | "codemirror_mode": {
306 | "name": "ipython",
307 | "version": 3
308 | },
309 | "file_extension": ".py",
310 | "mimetype": "text/x-python",
311 | "name": "python",
312 | "nbconvert_exporter": "python",
313 | "pygments_lexer": "ipython3",
314 | "version": "3.7.3"
315 | }
316 | },
317 | "nbformat": 4,
318 | "nbformat_minor": 2
319 | }
320 |
--------------------------------------------------------------------------------
/Ders 7 - Notu.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 7 : UYGULAMA DERSİ"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### UYGULAMA 1 : \n",
15 | "**Kullanıcıdan alınan 3 basamaklı tam sayının basamaklarını bulan programı yazalım.** \n",
16 | "\n",
17 | "Çıktı şu şekilde olmalıdır : \n",
18 | "\n",
19 | "\n",
20 | "Lütfen 3 basamaklı bir sayı giriniz : 256\n",
21 | "\n",
22 | "Girilen 256 sayısının\n",
23 | "\n",
24 | "Birler basamağı : 6\n",
25 | "\n",
26 | "Onlar basamağı : 5\n",
27 | "\n",
28 | "Yüzler basamağı : 2"
29 | ]
30 | },
31 | {
32 | "cell_type": "code",
33 | "execution_count": null,
34 | "metadata": {},
35 | "outputs": [],
36 | "source": [
37 | "sayi = input(\"Lütfen 3 basamaklı bir sayı giriniz: \")\n",
38 | "yuzler = int(sayi[0])\n",
39 | "onlar = int(sayi[1])\n",
40 | "birler = int(sayi[2])\n",
41 | "\n",
42 | "print(\"Girilen\", sayi,\"sayısının\\n Birler basamağı : \",birler, \"\\nOnlar basamağı :\",onlar,\"\\nYüzler basamağı:\",birler)"
43 | ]
44 | },
45 | {
46 | "cell_type": "markdown",
47 | "metadata": {},
48 | "source": [
49 | "### UYGULAMA 2 : \n",
50 | "**Kullanıcıdan alınan santigrat derece cinsinden girilen sıcaklığı Kelvin derece cinsine çeviren programı yazalım.** \n",
51 | "*0 °C = 273 K olduğunu unutmayalım. Alınan santigrat cinsinden sıcaklığı Kelvin'e çevirmek için 273 ile toplamamız gereklidir.* \n",
52 | "\n",
53 | "\n",
54 | "Çıktı şu şekilde olmalıdır : \n",
55 | "\n",
56 | "\n",
57 | "Lütfen santigrat derece cinsinden sıcaklığı giriniz: 22 \n",
58 | "\n",
59 | "Girilen 22 Santigrat derece 295 Kelvin'e eşittir. \n"
60 | ]
61 | },
62 | {
63 | "cell_type": "code",
64 | "execution_count": 3,
65 | "metadata": {},
66 | "outputs": [
67 | {
68 | "name": "stdout",
69 | "output_type": "stream",
70 | "text": [
71 | "Lütfen santigrat derece cinsinden sıcaklığı giriniz:0\n",
72 | "Girilen 0 santigrat derece 273 Kelvin'e eşittir.\n"
73 | ]
74 | }
75 | ],
76 | "source": [
77 | "santigrat = int(input(\"Lütfen santigrat derece cinsinden sıcaklığı giriniz:\"))\n",
78 | "# O derece = 273 kelvindir\n",
79 | "kelvin = santigrat + 273 #kelvine dönüşüm\n",
80 | "print(\"Girilen {} santigrat derece {} Kelvin'e eşittir.\".format(santigrat,kelvin))"
81 | ]
82 | },
83 | {
84 | "cell_type": "markdown",
85 | "metadata": {},
86 | "source": [
87 | "### UYGULAMA 3 : \n",
88 | "**Kullanıcıdan Cumartesi günü arabası ile gittiği yol bilgisini (kilometre cinsinden) ve zaman bilgisini(saat cinsinden) aldıktan sonra arabasının ortalama hızını hesaplayan programı yazalım.** \n",
89 | "\n",
90 | "Fen Bilgisi ya da Fizik dersinden hatırlayacağımız üzere ;\n",
91 | "\n",
92 | "**Yol = Hız * Zaman** formülünden hız hesaplanacağı için ;\n",
93 | "\n",
94 | "**Hız = Yol / Zaman** formülü kullanılması gerekmektedir. \n",
95 | "\n"
96 | ]
97 | },
98 | {
99 | "cell_type": "code",
100 | "execution_count": 5,
101 | "metadata": {},
102 | "outputs": [
103 | {
104 | "name": "stdout",
105 | "output_type": "stream",
106 | "text": [
107 | "Kaç km gittiğinizi yazınız: 120\n",
108 | "Ne kadar saat gezdiniz: 2\n",
109 | "Cumartesi günü yapmış olduğunuz 2 saatlik gezi sonucunda 120 kilometre yol gittiniz ve ortalama hızınız 60.0'km/saattir\n"
110 | ]
111 | }
112 | ],
113 | "source": [
114 | "# hız = yol / zaman formülü kullanılacaktır \n",
115 | "yol = int(input(\"Kaç km gittiğinizi yazınız: \"))\n",
116 | "zaman = int(input(\"Ne kadar saat gezdiniz: \"))\n",
117 | "hız = yol / zaman \n",
118 | "\n",
119 | "print(\"Cumartesi günü yapmış olduğunuz {} saatlik gezi sonucunda {} kilometre yol gittiniz ve ortalama hızınız {}'km/saattir\".format(zaman,yol,hız))"
120 | ]
121 | },
122 | {
123 | "cell_type": "code",
124 | "execution_count": null,
125 | "metadata": {},
126 | "outputs": [],
127 | "source": []
128 | },
129 | {
130 | "cell_type": "code",
131 | "execution_count": null,
132 | "metadata": {},
133 | "outputs": [],
134 | "source": []
135 | },
136 | {
137 | "cell_type": "markdown",
138 | "metadata": {},
139 | "source": [
140 | "### UYGULAMA 4 : \n",
141 | "**Kullanıcıdan alınan 4 basamaklı sayının basamaklarını sırasıyla bir listeye atınız.Liste elemanları string türünde değil tam sayı olmalıdır** \n",
142 | "\n"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 6,
148 | "metadata": {},
149 | "outputs": [
150 | {
151 | "name": "stdout",
152 | "output_type": "stream",
153 | "text": [
154 | "4 basamaklı bir sayı giriniz: 2356\n"
155 | ]
156 | },
157 | {
158 | "data": {
159 | "text/plain": [
160 | "['2', '3', '5', '6']"
161 | ]
162 | },
163 | "execution_count": 6,
164 | "metadata": {},
165 | "output_type": "execute_result"
166 | }
167 | ],
168 | "source": [
169 | "sayi=input(\"4 basamaklı bir sayı giriniz: \")\n",
170 | "liste = list(sayi)\n",
171 | "liste"
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": 7,
177 | "metadata": {},
178 | "outputs": [
179 | {
180 | "data": {
181 | "text/plain": [
182 | "[2, 3, 5, 6]"
183 | ]
184 | },
185 | "execution_count": 7,
186 | "metadata": {},
187 | "output_type": "execute_result"
188 | }
189 | ],
190 | "source": [
191 | "liste[0] = int(sayi[0])\n",
192 | "liste[1] = int(sayi[1])\n",
193 | "liste[2] = int(sayi[2])\n",
194 | "liste[3] = int(sayi[3])\n",
195 | "liste"
196 | ]
197 | },
198 | {
199 | "cell_type": "markdown",
200 | "metadata": {},
201 | "source": [
202 | "### ÖDEV 7:\n",
203 | "\n",
204 | "\n",
205 | "**1) Kullanıcının santimetre cinsinden boyu ve kg cinsinden kilosunu alıp buna göre vücut kitle indeksini bulan programı yazınız. **\n",
206 | "\n",
207 | "**Vücut Kitle İndeksi = Kilosu / (Boyux Boyu)** formülünden hesaplanmaktadır. \n",
208 | "\n",
209 | "*Buradaki boyun metre cinsinden olması gerekmektedir. **Yani kullanıcıdan alınan santimetre cinsinden boyun önce metreye çevirip** işlem yaparken metre cinsinden olan boyu kullanınız. *\n",
210 | "\n",
211 | "**ÖRNEK PROGRAM ÇIKTISI **\n",
212 | "\n",
213 | "\n",
214 | "Boyunuzu giriniz (cm) : 165 \n",
215 | "\n",
216 | "Kilonuzu giriniz (kg) : 55\n",
217 | "\n",
218 | "Beden Kitle İndeksiniz : 20.20\n"
219 | ]
220 | },
221 | {
222 | "cell_type": "code",
223 | "execution_count": null,
224 | "metadata": {},
225 | "outputs": [],
226 | "source": []
227 | },
228 | {
229 | "cell_type": "code",
230 | "execution_count": null,
231 | "metadata": {},
232 | "outputs": [],
233 | "source": []
234 | },
235 | {
236 | "cell_type": "code",
237 | "execution_count": null,
238 | "metadata": {},
239 | "outputs": [],
240 | "source": []
241 | },
242 | {
243 | "cell_type": "code",
244 | "execution_count": null,
245 | "metadata": {},
246 | "outputs": [],
247 | "source": []
248 | }
249 | ],
250 | "metadata": {
251 | "kernelspec": {
252 | "display_name": "Python 3",
253 | "language": "python",
254 | "name": "python3"
255 | },
256 | "language_info": {
257 | "codemirror_mode": {
258 | "name": "ipython",
259 | "version": 3
260 | },
261 | "file_extension": ".py",
262 | "mimetype": "text/x-python",
263 | "name": "python",
264 | "nbconvert_exporter": "python",
265 | "pygments_lexer": "ipython3",
266 | "version": "3.7.3"
267 | }
268 | },
269 | "nbformat": 4,
270 | "nbformat_minor": 2
271 | }
272 |
--------------------------------------------------------------------------------
/Ders Notu 4.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### ÖDEV 3 : CEVAPLAR\n"
8 | ]
9 | },
10 | {
11 | "cell_type": "code",
12 | "execution_count": 1,
13 | "metadata": {},
14 | "outputs": [
15 | {
16 | "name": "stdout",
17 | "output_type": "stream",
18 | "text": [
19 | "14\n"
20 | ]
21 | }
22 | ],
23 | "source": [
24 | "a = 5 \n",
25 | "b = 6\n",
26 | "a +=1\n",
27 | "b -=2\n",
28 | "c= a+2*b\n",
29 | "print(c)"
30 | ]
31 | },
32 | {
33 | "cell_type": "code",
34 | "execution_count": 2,
35 | "metadata": {},
36 | "outputs": [
37 | {
38 | "data": {
39 | "text/plain": [
40 | "30.0"
41 | ]
42 | },
43 | "execution_count": 2,
44 | "metadata": {},
45 | "output_type": "execute_result"
46 | }
47 | ],
48 | "source": [
49 | "((10**2) / 4) + 5"
50 | ]
51 | },
52 | {
53 | "cell_type": "code",
54 | "execution_count": 3,
55 | "metadata": {},
56 | "outputs": [
57 | {
58 | "data": {
59 | "text/plain": [
60 | "25.0"
61 | ]
62 | },
63 | "execution_count": 3,
64 | "metadata": {},
65 | "output_type": "execute_result"
66 | }
67 | ],
68 | "source": [
69 | "27 - 8/2 + 8/4"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": 7,
75 | "metadata": {},
76 | "outputs": [
77 | {
78 | "data": {
79 | "text/plain": [
80 | "39"
81 | ]
82 | },
83 | "execution_count": 7,
84 | "metadata": {},
85 | "output_type": "execute_result"
86 | }
87 | ],
88 | "source": [
89 | "(2*3)*5 + 16-7"
90 | ]
91 | },
92 | {
93 | "cell_type": "code",
94 | "execution_count": 8,
95 | "metadata": {},
96 | "outputs": [
97 | {
98 | "data": {
99 | "text/plain": [
100 | "0"
101 | ]
102 | },
103 | "execution_count": 8,
104 | "metadata": {},
105 | "output_type": "execute_result"
106 | }
107 | ],
108 | "source": [
109 | "5+5+5-5*3"
110 | ]
111 | },
112 | {
113 | "cell_type": "code",
114 | "execution_count": 9,
115 | "metadata": {},
116 | "outputs": [
117 | {
118 | "data": {
119 | "text/plain": [
120 | "21.0"
121 | ]
122 | },
123 | "execution_count": 9,
124 | "metadata": {},
125 | "output_type": "execute_result"
126 | }
127 | ],
128 | "source": [
129 | "6+(9/3)*5"
130 | ]
131 | },
132 | {
133 | "cell_type": "code",
134 | "execution_count": 10,
135 | "metadata": {},
136 | "outputs": [
137 | {
138 | "data": {
139 | "text/plain": [
140 | "'l'"
141 | ]
142 | },
143 | "execution_count": 10,
144 | "metadata": {},
145 | "output_type": "execute_result"
146 | }
147 | ],
148 | "source": [
149 | "cumle = \"Python ile kodlama yapmayı öğreniyorum\"\n",
150 | "cumle[8]"
151 | ]
152 | },
153 | {
154 | "cell_type": "code",
155 | "execution_count": 11,
156 | "metadata": {},
157 | "outputs": [
158 | {
159 | "data": {
160 | "text/plain": [
161 | "'y'"
162 | ]
163 | },
164 | "execution_count": 11,
165 | "metadata": {},
166 | "output_type": "execute_result"
167 | }
168 | ],
169 | "source": [
170 | "cumle[24]"
171 | ]
172 | },
173 | {
174 | "cell_type": "code",
175 | "execution_count": 12,
176 | "metadata": {},
177 | "outputs": [
178 | {
179 | "data": {
180 | "text/plain": [
181 | "'Python'"
182 | ]
183 | },
184 | "execution_count": 12,
185 | "metadata": {},
186 | "output_type": "execute_result"
187 | }
188 | ],
189 | "source": [
190 | "cumle[0:6]"
191 | ]
192 | },
193 | {
194 | "cell_type": "code",
195 | "execution_count": 13,
196 | "metadata": {},
197 | "outputs": [
198 | {
199 | "data": {
200 | "text/plain": [
201 | "'kod'"
202 | ]
203 | },
204 | "execution_count": 13,
205 | "metadata": {},
206 | "output_type": "execute_result"
207 | }
208 | ],
209 | "source": [
210 | "cumle[11:14]"
211 | ]
212 | },
213 | {
214 | "cell_type": "code",
215 | "execution_count": 14,
216 | "metadata": {},
217 | "outputs": [
218 | {
219 | "data": {
220 | "text/plain": [
221 | "'yap'"
222 | ]
223 | },
224 | "execution_count": 14,
225 | "metadata": {},
226 | "output_type": "execute_result"
227 | }
228 | ],
229 | "source": [
230 | "cumle[19:22]"
231 | ]
232 | },
233 | {
234 | "cell_type": "code",
235 | "execution_count": 15,
236 | "metadata": {},
237 | "outputs": [
238 | {
239 | "data": {
240 | "text/plain": [
241 | "38"
242 | ]
243 | },
244 | "execution_count": 15,
245 | "metadata": {},
246 | "output_type": "execute_result"
247 | }
248 | ],
249 | "source": [
250 | "len(cumle)"
251 | ]
252 | },
253 | {
254 | "cell_type": "code",
255 | "execution_count": 16,
256 | "metadata": {},
257 | "outputs": [
258 | {
259 | "data": {
260 | "text/plain": [
261 | "'Pto l olm amy'"
262 | ]
263 | },
264 | "execution_count": 16,
265 | "metadata": {},
266 | "output_type": "execute_result"
267 | }
268 | ],
269 | "source": [
270 | "cumle[0:26:2]"
271 | ]
272 | },
273 | {
274 | "cell_type": "code",
275 | "execution_count": 17,
276 | "metadata": {},
277 | "outputs": [
278 | {
279 | "data": {
280 | "text/plain": [
281 | "'ile'"
282 | ]
283 | },
284 | "execution_count": 17,
285 | "metadata": {},
286 | "output_type": "execute_result"
287 | }
288 | ],
289 | "source": [
290 | "cumle[7:10]"
291 | ]
292 | },
293 | {
294 | "cell_type": "code",
295 | "execution_count": 19,
296 | "metadata": {},
297 | "outputs": [
298 | {
299 | "data": {
300 | "text/plain": [
301 | "'ğ'"
302 | ]
303 | },
304 | "execution_count": 19,
305 | "metadata": {},
306 | "output_type": "execute_result"
307 | }
308 | ],
309 | "source": [
310 | "cumle[28]"
311 | ]
312 | },
313 | {
314 | "cell_type": "code",
315 | "execution_count": 20,
316 | "metadata": {},
317 | "outputs": [
318 | {
319 | "data": {
320 | "text/plain": [
321 | "'öğreniyorum'"
322 | ]
323 | },
324 | "execution_count": 20,
325 | "metadata": {},
326 | "output_type": "execute_result"
327 | }
328 | ],
329 | "source": [
330 | "cumle[27:38]"
331 | ]
332 | },
333 | {
334 | "cell_type": "code",
335 | "execution_count": 21,
336 | "metadata": {},
337 | "outputs": [
338 | {
339 | "data": {
340 | "text/plain": [
341 | "'Python'"
342 | ]
343 | },
344 | "execution_count": 21,
345 | "metadata": {},
346 | "output_type": "execute_result"
347 | }
348 | ],
349 | "source": [
350 | "cumle[0:6]"
351 | ]
352 | },
353 | {
354 | "cell_type": "code",
355 | "execution_count": 23,
356 | "metadata": {},
357 | "outputs": [
358 | {
359 | "data": {
360 | "text/plain": [
361 | "'dlama yap'"
362 | ]
363 | },
364 | "execution_count": 23,
365 | "metadata": {},
366 | "output_type": "execute_result"
367 | }
368 | ],
369 | "source": [
370 | "cumle[13:22]"
371 | ]
372 | },
373 | {
374 | "cell_type": "code",
375 | "execution_count": 24,
376 | "metadata": {},
377 | "outputs": [
378 | {
379 | "data": {
380 | "text/plain": [
381 | "'ö'"
382 | ]
383 | },
384 | "execution_count": 24,
385 | "metadata": {},
386 | "output_type": "execute_result"
387 | }
388 | ],
389 | "source": [
390 | "cumle[27]"
391 | ]
392 | },
393 | {
394 | "cell_type": "markdown",
395 | "metadata": {},
396 | "source": [
397 | "# DERS 4 \n",
398 | "Stringlerden devam edeceğiz."
399 | ]
400 | },
401 | {
402 | "cell_type": "code",
403 | "execution_count": 58,
404 | "metadata": {},
405 | "outputs": [
406 | {
407 | "data": {
408 | "text/plain": [
409 | "'m'"
410 | ]
411 | },
412 | "execution_count": 58,
413 | "metadata": {},
414 | "output_type": "execute_result"
415 | }
416 | ],
417 | "source": [
418 | "cumle=\"Python öğreniyorum\"\n",
419 | "cumle[-1]"
420 | ]
421 | },
422 | {
423 | "cell_type": "code",
424 | "execution_count": 26,
425 | "metadata": {},
426 | "outputs": [
427 | {
428 | "data": {
429 | "text/plain": [
430 | "'u'"
431 | ]
432 | },
433 | "execution_count": 26,
434 | "metadata": {},
435 | "output_type": "execute_result"
436 | }
437 | ],
438 | "source": [
439 | "cumle[-2] # - ifadesi stringin sonundan başlar"
440 | ]
441 | },
442 | {
443 | "cell_type": "code",
444 | "execution_count": 27,
445 | "metadata": {},
446 | "outputs": [
447 | {
448 | "data": {
449 | "text/plain": [
450 | "'r'"
451 | ]
452 | },
453 | "execution_count": 27,
454 | "metadata": {},
455 | "output_type": "execute_result"
456 | }
457 | ],
458 | "source": [
459 | "cumle[-3]"
460 | ]
461 | },
462 | {
463 | "cell_type": "code",
464 | "execution_count": 33,
465 | "metadata": {},
466 | "outputs": [
467 | {
468 | "data": {
469 | "text/plain": [
470 | "'Python'"
471 | ]
472 | },
473 | "execution_count": 33,
474 | "metadata": {},
475 | "output_type": "execute_result"
476 | }
477 | ],
478 | "source": [
479 | "#formül = [başlangıç:bitiş:adım]\n",
480 | "cumle[:6] #başına sayı yazmazsam en baştan başla demektiryani en baştan başla 6.indekse kadar git demek"
481 | ]
482 | },
483 | {
484 | "cell_type": "code",
485 | "execution_count": 36,
486 | "metadata": {},
487 | "outputs": [
488 | {
489 | "data": {
490 | "text/plain": [
491 | "'Python öğren'"
492 | ]
493 | },
494 | "execution_count": 36,
495 | "metadata": {},
496 | "output_type": "execute_result"
497 | }
498 | ],
499 | "source": [
500 | "cumle[:12] #en baştan başla 12.indekse kadar git demek"
501 | ]
502 | },
503 | {
504 | "cell_type": "code",
505 | "execution_count": 34,
506 | "metadata": {},
507 | "outputs": [
508 | {
509 | "data": {
510 | "text/plain": [
511 | "'hon öğreniyorum'"
512 | ]
513 | },
514 | "execution_count": 34,
515 | "metadata": {},
516 | "output_type": "execute_result"
517 | }
518 | ],
519 | "source": [
520 | "cumle[3:] #3.indeksten başla en sona kadar git demektir."
521 | ]
522 | },
523 | {
524 | "cell_type": "code",
525 | "execution_count": 37,
526 | "metadata": {},
527 | "outputs": [
528 | {
529 | "data": {
530 | "text/plain": [
531 | "'ğreniyorum'"
532 | ]
533 | },
534 | "execution_count": 37,
535 | "metadata": {},
536 | "output_type": "execute_result"
537 | }
538 | ],
539 | "source": [
540 | "cumle[8:] #8.indeksten başla en sona kadar git demektir."
541 | ]
542 | },
543 | {
544 | "cell_type": "code",
545 | "execution_count": 40,
546 | "metadata": {},
547 | "outputs": [
548 | {
549 | "data": {
550 | "text/plain": [
551 | "'Python öğreniyorum'"
552 | ]
553 | },
554 | "execution_count": 40,
555 | "metadata": {},
556 | "output_type": "execute_result"
557 | }
558 | ],
559 | "source": [
560 | "cumle[:] #en baştan en sonra kadar hepsi\n",
561 | "cumle[::] #en baştan en sonra kadar hepsi"
562 | ]
563 | },
564 | {
565 | "cell_type": "code",
566 | "execution_count": 41,
567 | "metadata": {},
568 | "outputs": [
569 | {
570 | "data": {
571 | "text/plain": [
572 | "'Python öğreniyoru'"
573 | ]
574 | },
575 | "execution_count": 41,
576 | "metadata": {},
577 | "output_type": "execute_result"
578 | }
579 | ],
580 | "source": [
581 | "cumle[:-1] #en baştan sondan bir öncekine kadar hepsi"
582 | ]
583 | },
584 | {
585 | "cell_type": "code",
586 | "execution_count": 60,
587 | "metadata": {},
588 | "outputs": [
589 | {
590 | "data": {
591 | "text/plain": [
592 | "'Python öğreniyo'"
593 | ]
594 | },
595 | "execution_count": 60,
596 | "metadata": {},
597 | "output_type": "execute_result"
598 | }
599 | ],
600 | "source": [
601 | "# En baştan sondan 3.ye kadar nasıl yazılır ?\n",
602 | "cumle[:-3]"
603 | ]
604 | },
605 | {
606 | "cell_type": "code",
607 | "execution_count": 44,
608 | "metadata": {},
609 | "outputs": [
610 | {
611 | "data": {
612 | "text/plain": [
613 | "'Ph rir'"
614 | ]
615 | },
616 | "execution_count": 44,
617 | "metadata": {},
618 | "output_type": "execute_result"
619 | }
620 | ],
621 | "source": [
622 | "cumle[::3] #en baştan en sona kadar 3şer aralıklarla yaz"
623 | ]
624 | },
625 | {
626 | "cell_type": "code",
627 | "execution_count": 45,
628 | "metadata": {},
629 | "outputs": [
630 | {
631 | "data": {
632 | "text/plain": [
633 | "'o ğ'"
634 | ]
635 | },
636 | "execution_count": 45,
637 | "metadata": {},
638 | "output_type": "execute_result"
639 | }
640 | ],
641 | "source": [
642 | "cumle[4:10:2]"
643 | ]
644 | },
645 | {
646 | "cell_type": "code",
647 | "execution_count": 61,
648 | "metadata": {},
649 | "outputs": [
650 | {
651 | "data": {
652 | "text/plain": [
653 | "'Pto ğei'"
654 | ]
655 | },
656 | "execution_count": 61,
657 | "metadata": {},
658 | "output_type": "execute_result"
659 | }
660 | ],
661 | "source": [
662 | "#en baştan en sondan 5.ye kadar 2şer aralıklarla yaz ?\n",
663 | "cumle[:-5:2]"
664 | ]
665 | },
666 | {
667 | "cell_type": "code",
668 | "execution_count": 51,
669 | "metadata": {},
670 | "outputs": [
671 | {
672 | "ename": "TypeError",
673 | "evalue": "'str' object does not support item assignment",
674 | "output_type": "error",
675 | "traceback": [
676 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
677 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
678 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m#Stringde Karakterleri DEĞİŞTİREMEYİZ\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mcumle\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'H'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3\u001b[0m \u001b[0mcumle\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
679 | "\u001b[1;31mTypeError\u001b[0m: 'str' object does not support item assignment"
680 | ]
681 | }
682 | ],
683 | "source": [
684 | "#Stringde İndekslerdeki Karakterleri DEĞİŞTİREMEYİZ !!!!!\n",
685 | "cumle [0] = 'H'\n",
686 | "cumle"
687 | ]
688 | },
689 | {
690 | "cell_type": "markdown",
691 | "metadata": {},
692 | "source": [
693 | "### Stringleri Birbirine Ekleme\n",
694 | "\n",
695 | "Stringler birbirine + işareti ile eklenebilir.\n"
696 | ]
697 | },
698 | {
699 | "cell_type": "code",
700 | "execution_count": 62,
701 | "metadata": {},
702 | "outputs": [
703 | {
704 | "name": "stdout",
705 | "output_type": "stream",
706 | "text": [
707 | "Python ile kodlamayı öğreniyorum\n"
708 | ]
709 | }
710 | ],
711 | "source": [
712 | "kelime1= \"Python \"\n",
713 | "kelime2= \"ile \"\n",
714 | "kelime3 = \"kodlamayı \"\n",
715 | "kelime4= \"öğreniyorum\"\n",
716 | "\n",
717 | "cumle = kelime1 + kelime2 + kelime3 + kelime4\n",
718 | "print(cumle)"
719 | ]
720 | },
721 | {
722 | "cell_type": "code",
723 | "execution_count": 63,
724 | "metadata": {},
725 | "outputs": [
726 | {
727 | "data": {
728 | "text/plain": [
729 | "32"
730 | ]
731 | },
732 | "execution_count": 63,
733 | "metadata": {},
734 | "output_type": "execute_result"
735 | }
736 | ],
737 | "source": [
738 | "len(cumle)"
739 | ]
740 | },
741 | {
742 | "cell_type": "code",
743 | "execution_count": 64,
744 | "metadata": {},
745 | "outputs": [
746 | {
747 | "data": {
748 | "text/plain": [
749 | "'Python Python Python '"
750 | ]
751 | },
752 | "execution_count": 64,
753 | "metadata": {},
754 | "output_type": "execute_result"
755 | }
756 | ],
757 | "source": [
758 | "kelime1 * 3"
759 | ]
760 | },
761 | {
762 | "cell_type": "code",
763 | "execution_count": 66,
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "int"
770 | ]
771 | },
772 | "execution_count": 66,
773 | "metadata": {},
774 | "output_type": "execute_result"
775 | }
776 | ],
777 | "source": [
778 | "sayi = \"5\"\n",
779 | "type(sayi)\n",
780 | "sayi = int(sayi)\n",
781 | "type(sayi)"
782 | ]
783 | },
784 | {
785 | "cell_type": "code",
786 | "execution_count": 69,
787 | "metadata": {},
788 | "outputs": [
789 | {
790 | "data": {
791 | "text/plain": [
792 | "float"
793 | ]
794 | },
795 | "execution_count": 69,
796 | "metadata": {},
797 | "output_type": "execute_result"
798 | }
799 | ],
800 | "source": [
801 | "yenisayi=\"6.9\"\n",
802 | "yenisayi=float(yenisayi)\n",
803 | "type(yenisayi)"
804 | ]
805 | },
806 | {
807 | "cell_type": "code",
808 | "execution_count": null,
809 | "metadata": {},
810 | "outputs": [],
811 | "source": []
812 | },
813 | {
814 | "cell_type": "code",
815 | "execution_count": null,
816 | "metadata": {},
817 | "outputs": [],
818 | "source": []
819 | },
820 | {
821 | "cell_type": "markdown",
822 | "metadata": {},
823 | "source": [
824 | "# STRINGLERDE METHODLAR \n",
825 | "\n",
826 | "- upper() : Karakterlerin hepsini büyük harfe çevirir\n",
827 | "- lower() : Karakterlerin hepsini küçük harfe çevirir\n",
828 | "- capitalize () : Baş harfi büyük harfe çeviri\n",
829 | "- count (): içerisine yazılan karakterin string içinde kaç adet olduğunu bulur\n",
830 | "- find () : İçerisine yazılan karakterin string içindeki indeks sayısını bulur\n",
831 | "- index() : İçine yazılan karakterin indeks sayısını bulur\n",
832 | "- replace(değiştirilmek istenen, yeni karakter) : String içindeki bir karakter dizisini değiştirmeye yarar.\n",
833 | "- format ()"
834 | ]
835 | },
836 | {
837 | "cell_type": "code",
838 | "execution_count": 71,
839 | "metadata": {},
840 | "outputs": [
841 | {
842 | "name": "stdout",
843 | "output_type": "stream",
844 | "text": [
845 | "TEKIRDAĞ\n"
846 | ]
847 | }
848 | ],
849 | "source": [
850 | "city = \"tekirdağ\" #upper methodu karakterleri büyük harf yapar\n",
851 | "yeni = city.upper()\n",
852 | "print(yeni)"
853 | ]
854 | },
855 | {
856 | "cell_type": "code",
857 | "execution_count": 73,
858 | "metadata": {},
859 | "outputs": [
860 | {
861 | "name": "stdout",
862 | "output_type": "stream",
863 | "text": [
864 | "tekirdağ\n"
865 | ]
866 | }
867 | ],
868 | "source": [
869 | "yeni = yeni.lower() #lower methodu karakterleri küçük yapar\n",
870 | "print(yeni)"
871 | ]
872 | },
873 | {
874 | "cell_type": "code",
875 | "execution_count": 74,
876 | "metadata": {},
877 | "outputs": [
878 | {
879 | "name": "stdout",
880 | "output_type": "stream",
881 | "text": [
882 | "Tekirdağ\n"
883 | ]
884 | }
885 | ],
886 | "source": [
887 | "ilk = city.capitalize() #ilk harfi büyük yapar\n",
888 | "print(ilk)"
889 | ]
890 | },
891 | {
892 | "cell_type": "code",
893 | "execution_count": 76,
894 | "metadata": {},
895 | "outputs": [
896 | {
897 | "name": "stdout",
898 | "output_type": "stream",
899 | "text": [
900 | "2\n"
901 | ]
902 | },
903 | {
904 | "data": {
905 | "text/plain": [
906 | "16"
907 | ]
908 | },
909 | "execution_count": 76,
910 | "metadata": {},
911 | "output_type": "execute_result"
912 | }
913 | ],
914 | "source": [
915 | "cumle = \"Dışarıda kuşlar uçar\" #count karakterin kaç adet olduğunu bulur\n",
916 | "sayi =cumle.count(\"u\")\n",
917 | "print(sayi)\n",
918 | "indeks=cumle.find(\"uçar\") #find hangi indekste olduğunu bulur\n",
919 | "indeks"
920 | ]
921 | },
922 | {
923 | "cell_type": "code",
924 | "execution_count": 77,
925 | "metadata": {},
926 | "outputs": [
927 | {
928 | "name": "stdout",
929 | "output_type": "stream",
930 | "text": [
931 | "2\n"
932 | ]
933 | }
934 | ],
935 | "source": [
936 | "a = cumle.index(\"ş\") #index karakterin hangi indekste olduğunu bulur.\n",
937 | "print(a)"
938 | ]
939 | },
940 | {
941 | "cell_type": "code",
942 | "execution_count": 78,
943 | "metadata": {},
944 | "outputs": [
945 | {
946 | "name": "stdout",
947 | "output_type": "stream",
948 | "text": [
949 | "Dışarıda martılar uçar\n"
950 | ]
951 | }
952 | ],
953 | "source": [
954 | "yenicumle=cumle.replace(\"kuşlar\",\"martılar\")\n",
955 | "print(yenicumle)"
956 | ]
957 | },
958 | {
959 | "cell_type": "code",
960 | "execution_count": null,
961 | "metadata": {},
962 | "outputs": [],
963 | "source": []
964 | },
965 | {
966 | "cell_type": "code",
967 | "execution_count": null,
968 | "metadata": {},
969 | "outputs": [],
970 | "source": []
971 | },
972 | {
973 | "cell_type": "markdown",
974 | "metadata": {},
975 | "source": [
976 | "# ÖDEV 4 "
977 | ]
978 | },
979 | {
980 | "cell_type": "code",
981 | "execution_count": null,
982 | "metadata": {},
983 | "outputs": [],
984 | "source": [
985 | "1) Kullanıcıdan ismini ve 2 adet sayı isteyerek bu sayıların ortalamasını ekrana yazdıran programı yazınız. \n",
986 | "ortalama = (sayi1 + sayi2)/2\n",
987 | "Program çıktısı şu şekilde olmalıdır : \n",
988 | "\" Merhaba Hatice, girmiş olduğun 12 ve 15.6 sayılarının ortalaması 13.8'dir.\" "
989 | ]
990 | },
991 | {
992 | "cell_type": "code",
993 | "execution_count": null,
994 | "metadata": {},
995 | "outputs": [],
996 | "source": [
997 | "2) Kullanıcıdan 2 adet sayı isteyerek Sayıların çarpımlarını toplamlarına bölüp sonucu ekrana yazdıran programı yazınız. \n",
998 | "\n",
999 | " islem = (sayi1*sayi2) / (sayi1 + sayi2)\n",
1000 | "\n",
1001 | "Program çıktısı şu şekilde olmalıdır : \n",
1002 | "\" Merhaba girmiş olduğun 12 ve 15.6 sayılarının islem sonucu çıktısı 6.782608695652173'dir.\" "
1003 | ]
1004 | },
1005 | {
1006 | "cell_type": "code",
1007 | "execution_count": null,
1008 | "metadata": {},
1009 | "outputs": [],
1010 | "source": [
1011 | "3) cumle = \"Hayvanların hepsini seviyorum fakat en sevdiğim hayvan kedidir.\"\n",
1012 | "\n",
1013 | "- 7.indeksten başlayıp en sona kadar giden kod satırı ve çıktısı\n",
1014 | "- en baştan 23. satıra kadar giden kod satırı ve çıktısı\n",
1015 | "- 6. indeks ile başlayıp en sona 2 adım atlayarak giden kod satırı ve çıktısı\n",
1016 | "- Cümlenin uzunluğunu bulan kod satırı ve çıktısı\n",
1017 | "- Cümledeki \"kedidir\" kısmını kedi dışında en sevdiğiniz hayvan ile değiştiriniz. \n",
1018 | "- Cümledeki \"e\" harfinin sayısını bulan kod satırı ve çıktısı\n",
1019 | "- Cümledeki boşluk '' karakterini bulan kod satırı ve çıktısı"
1020 | ]
1021 | }
1022 | ],
1023 | "metadata": {
1024 | "kernelspec": {
1025 | "display_name": "Python 3",
1026 | "language": "python",
1027 | "name": "python3"
1028 | },
1029 | "language_info": {
1030 | "codemirror_mode": {
1031 | "name": "ipython",
1032 | "version": 3
1033 | },
1034 | "file_extension": ".py",
1035 | "mimetype": "text/x-python",
1036 | "name": "python",
1037 | "nbconvert_exporter": "python",
1038 | "pygments_lexer": "ipython3",
1039 | "version": "3.7.3"
1040 | }
1041 | },
1042 | "nbformat": 4,
1043 | "nbformat_minor": 2
1044 | }
1045 |
--------------------------------------------------------------------------------
/Ders-5.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 5 "
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# Formatlama\n",
15 | "\n",
16 | "Formatlama işlemi için format() methodu kullanılır. {} kullanılır. \n",
17 | "\n",
18 | "Programlama yaparken bazı yerlerde bir stringin içinde daha önceden tanımlı string,float, int vs. değerleri yerleştirmek isteyebiliriz. Böyle durumlar için Pythonda *format()* fonksiyonu bulunmaktadır."
19 | ]
20 | },
21 | {
22 | "cell_type": "code",
23 | "execution_count": 1,
24 | "metadata": {},
25 | "outputs": [
26 | {
27 | "data": {
28 | "text/plain": [
29 | "'3.1423 5.324 7.324324'"
30 | ]
31 | },
32 | "execution_count": 1,
33 | "metadata": {},
34 | "output_type": "execute_result"
35 | }
36 | ],
37 | "source": [
38 | "# Burada 3 tane süslü parantezimiz ({}) var ve bunların yerine sırasıyla format fonksiyonun içindeki değerler geçiyor.\n",
39 | "\"{} {} {}\".format(3.1423,5.324,7.324324)"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 2,
45 | "metadata": {
46 | "scrolled": true
47 | },
48 | "outputs": [
49 | {
50 | "name": "stdout",
51 | "output_type": "stream",
52 | "text": [
53 | "3 + 4 'nin toplamı 7 'dır\n"
54 | ]
55 | }
56 | ],
57 | "source": [
58 | "a = 3\n",
59 | "b = 4\n",
60 | "print(\"{} + {} 'nin toplamı {} 'dır\".format(a,b,a+b))"
61 | ]
62 | },
63 | {
64 | "cell_type": "code",
65 | "execution_count": 3,
66 | "metadata": {},
67 | "outputs": [
68 | {
69 | "data": {
70 | "text/plain": [
71 | "'Hatice 30 4'"
72 | ]
73 | },
74 | "execution_count": 3,
75 | "metadata": {},
76 | "output_type": "execute_result"
77 | }
78 | ],
79 | "source": [
80 | "# Süslü parantezlerin içindeki sayılar format fonksiyonun içinden hangi sıradaki değerin geleceğini söylüyor.\n",
81 | "\"{1} {0} {2}\".format(30,\"Hatice\",4)"
82 | ]
83 | },
84 | {
85 | "cell_type": "code",
86 | "execution_count": 4,
87 | "metadata": {},
88 | "outputs": [
89 | {
90 | "data": {
91 | "text/plain": [
92 | "'3.15 5.32 7.324'"
93 | ]
94 | },
95 | "execution_count": 4,
96 | "metadata": {},
97 | "output_type": "execute_result"
98 | }
99 | ],
100 | "source": [
101 | "# ondalıklı kısmın sadece 2 basamağına kadar almak istediğimiz söylüyor.\n",
102 | "\"{:.2f} {:.2f} {:.3f}\".format(3.1463,5.324,7.324324)"
103 | ]
104 | },
105 | {
106 | "cell_type": "markdown",
107 | "metadata": {
108 | "collapsed": true
109 | },
110 | "source": [
111 | "## 3 ) Boolean Veri Tipi (True False)"
112 | ]
113 | },
114 | {
115 | "cell_type": "code",
116 | "execution_count": 5,
117 | "metadata": {},
118 | "outputs": [
119 | {
120 | "data": {
121 | "text/plain": [
122 | "True"
123 | ]
124 | },
125 | "execution_count": 5,
126 | "metadata": {},
127 | "output_type": "execute_result"
128 | }
129 | ],
130 | "source": [
131 | "5 > 4"
132 | ]
133 | },
134 | {
135 | "cell_type": "code",
136 | "execution_count": 6,
137 | "metadata": {},
138 | "outputs": [
139 | {
140 | "data": {
141 | "text/plain": [
142 | "False"
143 | ]
144 | },
145 | "execution_count": 6,
146 | "metadata": {},
147 | "output_type": "execute_result"
148 | }
149 | ],
150 | "source": [
151 | "2 > 5"
152 | ]
153 | },
154 | {
155 | "cell_type": "code",
156 | "execution_count": 7,
157 | "metadata": {},
158 | "outputs": [
159 | {
160 | "data": {
161 | "text/plain": [
162 | "True"
163 | ]
164 | },
165 | "execution_count": 7,
166 | "metadata": {},
167 | "output_type": "execute_result"
168 | }
169 | ],
170 | "source": [
171 | "5==5 #eşitlikler == ile gösterilir"
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": 8,
177 | "metadata": {},
178 | "outputs": [
179 | {
180 | "data": {
181 | "text/plain": [
182 | "False"
183 | ]
184 | },
185 | "execution_count": 8,
186 | "metadata": {},
187 | "output_type": "execute_result"
188 | }
189 | ],
190 | "source": [
191 | "5==6"
192 | ]
193 | },
194 | {
195 | "cell_type": "code",
196 | "execution_count": 9,
197 | "metadata": {},
198 | "outputs": [
199 | {
200 | "data": {
201 | "text/plain": [
202 | "True"
203 | ]
204 | },
205 | "execution_count": 9,
206 | "metadata": {},
207 | "output_type": "execute_result"
208 | }
209 | ],
210 | "source": [
211 | "5>=3"
212 | ]
213 | },
214 | {
215 | "cell_type": "code",
216 | "execution_count": 10,
217 | "metadata": {},
218 | "outputs": [
219 | {
220 | "data": {
221 | "text/plain": [
222 | "False"
223 | ]
224 | },
225 | "execution_count": 10,
226 | "metadata": {},
227 | "output_type": "execute_result"
228 | }
229 | ],
230 | "source": [
231 | "8>=10 #çıktı ne olur?"
232 | ]
233 | },
234 | {
235 | "cell_type": "markdown",
236 | "metadata": {},
237 | "source": [
238 | "# 4) Listeler"
239 | ]
240 | },
241 | {
242 | "cell_type": "markdown",
243 | "metadata": {},
244 | "source": [
245 | "Şimdi de yeni bir veritipimiz olan **listeleri** öğrenmeye çalışalım. Listeler yapıları gereği stringlere oldukça benzerler. Tıpkı stringler gibi ,indekslenirler,parçalanırlar ve üzerinde değişik işlemler yapabildiğimiz metodlar bulunur. Ancak stringler konusundan bildiğimiz kadarıyla stringler değiştirilemezken listeler değiştirilebilir.\n",
246 | "\n",
247 | "\n",
248 | " \n",
249 | "### Liste Oluşturma\n",
250 | "\n",
251 | "Listeler bir *[]* köşeli parantez içine veriler veya değerler konarak oluşturulabilir."
252 | ]
253 | },
254 | {
255 | "cell_type": "code",
256 | "execution_count": 11,
257 | "metadata": {},
258 | "outputs": [
259 | {
260 | "name": "stdout",
261 | "output_type": "stream",
262 | "text": [
263 | "[3, 4, 5, 6, 'Elma', 3.14, 5.324]\n"
264 | ]
265 | },
266 | {
267 | "data": {
268 | "text/plain": [
269 | "list"
270 | ]
271 | },
272 | "execution_count": 11,
273 | "metadata": {},
274 | "output_type": "execute_result"
275 | }
276 | ],
277 | "source": [
278 | "# liste değişkeni. Değişik veri tiplerinden değerleri saklayabiliyoruz.\n",
279 | "liste = [3,4,5,6,\"Elma\",3.14,5.324]\n",
280 | "print(liste)\n",
281 | "type(liste)"
282 | ]
283 | },
284 | {
285 | "cell_type": "code",
286 | "execution_count": 12,
287 | "metadata": {},
288 | "outputs": [
289 | {
290 | "data": {
291 | "text/plain": [
292 | "[3, 4, 5, 6, 7, 8, 9]"
293 | ]
294 | },
295 | "execution_count": 12,
296 | "metadata": {},
297 | "output_type": "execute_result"
298 | }
299 | ],
300 | "source": [
301 | "liste2 = [3,4,5,6,7,8,9]\n",
302 | "liste2"
303 | ]
304 | },
305 | {
306 | "cell_type": "code",
307 | "execution_count": 13,
308 | "metadata": {},
309 | "outputs": [
310 | {
311 | "data": {
312 | "text/plain": [
313 | "[]"
314 | ]
315 | },
316 | "execution_count": 13,
317 | "metadata": {},
318 | "output_type": "execute_result"
319 | }
320 | ],
321 | "source": [
322 | "# Boş liste\n",
323 | "bos_liste = []\n",
324 | "bos_liste"
325 | ]
326 | },
327 | {
328 | "cell_type": "code",
329 | "execution_count": 14,
330 | "metadata": {},
331 | "outputs": [
332 | {
333 | "data": {
334 | "text/plain": [
335 | "[]"
336 | ]
337 | },
338 | "execution_count": 14,
339 | "metadata": {},
340 | "output_type": "execute_result"
341 | }
342 | ],
343 | "source": [
344 | "# Boş liste . list() fonksiyonuyla da oluşturulabilir.\n",
345 | "bos_liste = list()\n",
346 | "bos_liste"
347 | ]
348 | },
349 | {
350 | "cell_type": "code",
351 | "execution_count": 15,
352 | "metadata": {},
353 | "outputs": [
354 | {
355 | "data": {
356 | "text/plain": [
357 | "11"
358 | ]
359 | },
360 | "execution_count": 15,
361 | "metadata": {},
362 | "output_type": "execute_result"
363 | }
364 | ],
365 | "source": [
366 | "# len fonksiyonu listeler üzerinde de kullanılabilir.\n",
367 | "liste3 = [3,4,5,6,6,7,8,9,0,0,0]\n",
368 | "len(liste3)"
369 | ]
370 | },
371 | {
372 | "cell_type": "code",
373 | "execution_count": 16,
374 | "metadata": {},
375 | "outputs": [
376 | {
377 | "name": "stdout",
378 | "output_type": "stream",
379 | "text": [
380 | "['M', 'e', 'r', 'h', 'a', 'b', 'a']\n"
381 | ]
382 | },
383 | {
384 | "data": {
385 | "text/plain": [
386 | "list"
387 | ]
388 | },
389 | "execution_count": 16,
390 | "metadata": {},
391 | "output_type": "execute_result"
392 | }
393 | ],
394 | "source": [
395 | "#Bir string *list()* fonksiyonu yardımıyla listeye dönüştürülebilir.\n",
396 | "hello = \"Merhaba\"\n",
397 | "lst = list(hello)\n",
398 | "print(lst)\n",
399 | "type(lst)"
400 | ]
401 | },
402 | {
403 | "cell_type": "markdown",
404 | "metadata": {},
405 | "source": [
406 | "### Listeleri Indeksleme ve Parçalama\n",
407 | "\n",
408 | "Listeleri indeksleme ve parçalama stringlerle birebir olarak aynıdır."
409 | ]
410 | },
411 | {
412 | "cell_type": "code",
413 | "execution_count": 17,
414 | "metadata": {},
415 | "outputs": [
416 | {
417 | "name": "stdout",
418 | "output_type": "stream",
419 | "text": [
420 | "[10, 9, 8, 7, 6, 5, 4, 3]\n"
421 | ]
422 | }
423 | ],
424 | "source": [
425 | "liste = [3,4,5,6,7,8,9,10]\n",
426 | "print(liste[::-1]) # listeyi tam tersine çevirir"
427 | ]
428 | },
429 | {
430 | "cell_type": "code",
431 | "execution_count": 18,
432 | "metadata": {},
433 | "outputs": [
434 | {
435 | "data": {
436 | "text/plain": [
437 | "3"
438 | ]
439 | },
440 | "execution_count": 18,
441 | "metadata": {},
442 | "output_type": "execute_result"
443 | }
444 | ],
445 | "source": [
446 | "# 0. eleman \n",
447 | "liste[0]"
448 | ]
449 | },
450 | {
451 | "cell_type": "code",
452 | "execution_count": 19,
453 | "metadata": {},
454 | "outputs": [
455 | {
456 | "data": {
457 | "text/plain": [
458 | "10"
459 | ]
460 | },
461 | "execution_count": 19,
462 | "metadata": {},
463 | "output_type": "execute_result"
464 | }
465 | ],
466 | "source": [
467 | "# Sonuncu Eleman\n",
468 | "liste[-1]"
469 | ]
470 | },
471 | {
472 | "cell_type": "code",
473 | "execution_count": 21,
474 | "metadata": {},
475 | "outputs": [
476 | {
477 | "data": {
478 | "text/plain": [
479 | "[3, 4, 5, 6, 7]"
480 | ]
481 | },
482 | "execution_count": 21,
483 | "metadata": {},
484 | "output_type": "execute_result"
485 | }
486 | ],
487 | "source": [
488 | "# Baştan 5. indekse kadar (dahil değil)\n",
489 | "liste[:5]"
490 | ]
491 | },
492 | {
493 | "cell_type": "code",
494 | "execution_count": 22,
495 | "metadata": {},
496 | "outputs": [
497 | {
498 | "data": {
499 | "text/plain": [
500 | "[4, 5, 6]"
501 | ]
502 | },
503 | "execution_count": 22,
504 | "metadata": {},
505 | "output_type": "execute_result"
506 | }
507 | ],
508 | "source": [
509 | "# 1.indeksten 4.indekse kadar\n",
510 | "liste[1:4]"
511 | ]
512 | },
513 | {
514 | "cell_type": "code",
515 | "execution_count": 23,
516 | "metadata": {},
517 | "outputs": [
518 | {
519 | "data": {
520 | "text/plain": [
521 | "[8, 9, 10]"
522 | ]
523 | },
524 | "execution_count": 23,
525 | "metadata": {},
526 | "output_type": "execute_result"
527 | }
528 | ],
529 | "source": [
530 | "liste[5:]"
531 | ]
532 | },
533 | {
534 | "cell_type": "code",
535 | "execution_count": 24,
536 | "metadata": {},
537 | "outputs": [
538 | {
539 | "data": {
540 | "text/plain": [
541 | "[3, 5, 7, 9]"
542 | ]
543 | },
544 | "execution_count": 24,
545 | "metadata": {},
546 | "output_type": "execute_result"
547 | }
548 | ],
549 | "source": [
550 | "liste[::2]"
551 | ]
552 | },
553 | {
554 | "cell_type": "code",
555 | "execution_count": null,
556 | "metadata": {},
557 | "outputs": [],
558 | "source": []
559 | },
560 | {
561 | "cell_type": "code",
562 | "execution_count": null,
563 | "metadata": {},
564 | "outputs": [],
565 | "source": []
566 | },
567 | {
568 | "cell_type": "markdown",
569 | "metadata": {},
570 | "source": [
571 | "## ÖDEV 5: \n",
572 | "\n",
573 | "**Kullanıcının girdiği 3 basamaklı bir sayının elemanlarının toplamını ekrana yazdıran programı kodlayınız. Hem önceden öğrendiğimiz şekilde print ile hem de format() fonksiyonu ile ekrana yazdırınız. \n",
574 | "\n",
575 | "**İpucu**:Kullanıcıdan sayıyı string türünde alacağınızı unutmayınız. String türünde girilen sayının birinci basamağını bir değişkene, ikinci basamağını başka bir değişkene ve üçüncü basamağını da başka bir değişkene atayıp bu değişkenleri integer (Tam sayı) yapmanız gerekmektedir. Ardından 3 sayıyı toplayıp ekrana yazdırabilirsiniz. \n",
576 | "\n",
577 | "\n",
578 | "**Örnek Program Çıktısı**\n",
579 | "\n",
580 | "Sayı Giriniz : 123\n",
581 | "\n",
582 | "\"Girmiş olduğunuz 123 sayısının basamaklarının toplamı 6'dır\"."
583 | ]
584 | }
585 | ],
586 | "metadata": {
587 | "kernelspec": {
588 | "display_name": "Python 3",
589 | "language": "python",
590 | "name": "python3"
591 | },
592 | "language_info": {
593 | "codemirror_mode": {
594 | "name": "ipython",
595 | "version": 3
596 | },
597 | "file_extension": ".py",
598 | "mimetype": "text/x-python",
599 | "name": "python",
600 | "nbconvert_exporter": "python",
601 | "pygments_lexer": "ipython3",
602 | "version": "3.7.3"
603 | }
604 | },
605 | "nbformat": 4,
606 | "nbformat_minor": 2
607 | }
608 |
--------------------------------------------------------------------------------
/Ders-6.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# DERS 6"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "## ÖDEV 5 CEVABI"
15 | ]
16 | },
17 | {
18 | "cell_type": "code",
19 | "execution_count": 56,
20 | "metadata": {
21 | "scrolled": true
22 | },
23 | "outputs": [
24 | {
25 | "name": "stdout",
26 | "output_type": "stream",
27 | "text": [
28 | "Sayi giriniz : 123\n"
29 | ]
30 | },
31 | {
32 | "data": {
33 | "text/plain": [
34 | "str"
35 | ]
36 | },
37 | "execution_count": 56,
38 | "metadata": {},
39 | "output_type": "execute_result"
40 | }
41 | ],
42 | "source": [
43 | "sayi=input(\"Sayi giriniz : \")"
44 | ]
45 | },
46 | {
47 | "cell_type": "code",
48 | "execution_count": 58,
49 | "metadata": {},
50 | "outputs": [
51 | {
52 | "data": {
53 | "text/plain": [
54 | "int"
55 | ]
56 | },
57 | "execution_count": 58,
58 | "metadata": {},
59 | "output_type": "execute_result"
60 | }
61 | ],
62 | "source": [
63 | "ilk=int(sayi[0])"
64 | ]
65 | },
66 | {
67 | "cell_type": "code",
68 | "execution_count": 60,
69 | "metadata": {},
70 | "outputs": [
71 | {
72 | "data": {
73 | "text/plain": [
74 | "int"
75 | ]
76 | },
77 | "execution_count": 60,
78 | "metadata": {},
79 | "output_type": "execute_result"
80 | }
81 | ],
82 | "source": [
83 | "iki=int(sayi[1]) "
84 | ]
85 | },
86 | {
87 | "cell_type": "code",
88 | "execution_count": 62,
89 | "metadata": {},
90 | "outputs": [
91 | {
92 | "data": {
93 | "text/plain": [
94 | "int"
95 | ]
96 | },
97 | "execution_count": 62,
98 | "metadata": {},
99 | "output_type": "execute_result"
100 | }
101 | ],
102 | "source": [
103 | "uc=int(sayi[2])"
104 | ]
105 | },
106 | {
107 | "cell_type": "code",
108 | "execution_count": 63,
109 | "metadata": {},
110 | "outputs": [
111 | {
112 | "data": {
113 | "text/plain": [
114 | "6"
115 | ]
116 | },
117 | "execution_count": 63,
118 | "metadata": {},
119 | "output_type": "execute_result"
120 | }
121 | ],
122 | "source": [
123 | "toplam = ilk + iki + uc"
124 | ]
125 | },
126 | {
127 | "cell_type": "code",
128 | "execution_count": 64,
129 | "metadata": {},
130 | "outputs": [
131 | {
132 | "name": "stdout",
133 | "output_type": "stream",
134 | "text": [
135 | "Girmiş olduğunuz 123 sayısının basamakları toplamı 6 'dır.'\n",
136 | "Girmiş olduğunuz 123 sayısının basamakları toplamı 6'dır.'\n"
137 | ]
138 | }
139 | ],
140 | "source": [
141 | "print(\"Girmiş olduğunuz \", sayi,\"sayısının basamakları toplamı\",toplam,\"'dır.'\")\n",
142 | "print(\"Girmiş olduğunuz {} sayısının basamakları toplamı {}'dır.'\".format(sayi,toplam))"
143 | ]
144 | },
145 | {
146 | "cell_type": "markdown",
147 | "metadata": {},
148 | "source": []
149 | },
150 | {
151 | "cell_type": "markdown",
152 | "metadata": {},
153 | "source": [
154 | "### Temel Liste Metodları ve İşlemleri\n",
155 | "\n",
156 | "\n",
157 | "Bir listeyi birbirine toplama işlemini stringlerdeki gibi yapabiliriz.\n"
158 | ]
159 | },
160 | {
161 | "cell_type": "code",
162 | "execution_count": 13,
163 | "metadata": {},
164 | "outputs": [
165 | {
166 | "data": {
167 | "text/plain": [
168 | "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
169 | ]
170 | },
171 | "execution_count": 13,
172 | "metadata": {},
173 | "output_type": "execute_result"
174 | }
175 | ],
176 | "source": [
177 | "liste1 = [1,2,3,4,5]\n",
178 | "liste2 = [6,7,8,9,10]\n",
179 | "liste3 = liste1 + liste2\n",
180 | "liste3"
181 | ]
182 | },
183 | {
184 | "cell_type": "code",
185 | "execution_count": 1,
186 | "metadata": {},
187 | "outputs": [
188 | {
189 | "data": {
190 | "text/plain": [
191 | "[1, 2, 3, 4, 'Hatice']"
192 | ]
193 | },
194 | "execution_count": 1,
195 | "metadata": {},
196 | "output_type": "execute_result"
197 | }
198 | ],
199 | "source": [
200 | "#Bir listeye bir tane eleman eklemek için\n",
201 | "liste = [1,2,3,4]\n",
202 | "liste = liste + [\"Hatice\"]\n",
203 | "liste"
204 | ]
205 | },
206 | {
207 | "cell_type": "code",
208 | "execution_count": 2,
209 | "metadata": {},
210 | "outputs": [
211 | {
212 | "data": {
213 | "text/plain": [
214 | "[10, 2, 3, 4, 'Hatice']"
215 | ]
216 | },
217 | "execution_count": 2,
218 | "metadata": {},
219 | "output_type": "execute_result"
220 | }
221 | ],
222 | "source": [
223 | "# Listeler direkt olarak değiştirilebilirler.\n",
224 | "liste[0] = 10\n",
225 | "liste"
226 | ]
227 | },
228 | {
229 | "cell_type": "code",
230 | "execution_count": 3,
231 | "metadata": {},
232 | "outputs": [
233 | {
234 | "data": {
235 | "text/plain": [
236 | "[40, 50, 3, 4, 'Hatice']"
237 | ]
238 | },
239 | "execution_count": 3,
240 | "metadata": {},
241 | "output_type": "execute_result"
242 | }
243 | ],
244 | "source": [
245 | "# Şöyle bir kullanım da doğrudur.\n",
246 | "liste[:2] = [40,50]\n",
247 | "liste"
248 | ]
249 | },
250 | {
251 | "cell_type": "code",
252 | "execution_count": 4,
253 | "metadata": {},
254 | "outputs": [
255 | {
256 | "data": {
257 | "text/plain": [
258 | "[40, 50, 3, 4, 'Hatice']"
259 | ]
260 | },
261 | "execution_count": 4,
262 | "metadata": {},
263 | "output_type": "execute_result"
264 | }
265 | ],
266 | "source": [
267 | "liste"
268 | ]
269 | },
270 | {
271 | "cell_type": "code",
272 | "execution_count": 5,
273 | "metadata": {},
274 | "outputs": [
275 | {
276 | "data": {
277 | "text/plain": [
278 | "[1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]"
279 | ]
280 | },
281 | "execution_count": 5,
282 | "metadata": {},
283 | "output_type": "execute_result"
284 | }
285 | ],
286 | "source": [
287 | "#Bir listeyi bir tamsayıyla da çarpabiliriz.\n",
288 | "liste = [1,2,3,4,5]\n",
289 | "liste * 3"
290 | ]
291 | },
292 | {
293 | "cell_type": "code",
294 | "execution_count": 6,
295 | "metadata": {},
296 | "outputs": [
297 | {
298 | "data": {
299 | "text/plain": [
300 | "[1, 2, 3, 4, 5]"
301 | ]
302 | },
303 | "execution_count": 6,
304 | "metadata": {},
305 | "output_type": "execute_result"
306 | }
307 | ],
308 | "source": [
309 | "liste # Ama liste değişmiyor.Bir atama yapmadık çünkü"
310 | ]
311 | },
312 | {
313 | "cell_type": "code",
314 | "execution_count": 7,
315 | "metadata": {},
316 | "outputs": [
317 | {
318 | "data": {
319 | "text/plain": [
320 | "[1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]"
321 | ]
322 | },
323 | "execution_count": 7,
324 | "metadata": {},
325 | "output_type": "execute_result"
326 | }
327 | ],
328 | "source": [
329 | "liste = liste * 3 \n",
330 | "liste # Eşitleme yaptığımız için liste değişti."
331 | ]
332 | },
333 | {
334 | "cell_type": "markdown",
335 | "metadata": {},
336 | "source": [
337 | "\n",
338 | "\n",
339 | "#### append metodu\n",
340 | "append metodu, verdiğimiz değeri listenin sonuna eklememizi sağlar."
341 | ]
342 | },
343 | {
344 | "cell_type": "code",
345 | "execution_count": 14,
346 | "metadata": {},
347 | "outputs": [
348 | {
349 | "data": {
350 | "text/plain": [
351 | "[3, 4, 5, 6, 7]"
352 | ]
353 | },
354 | "execution_count": 14,
355 | "metadata": {},
356 | "output_type": "execute_result"
357 | }
358 | ],
359 | "source": [
360 | "liste1 = [3,4,5,6]\n",
361 | "liste1.append(7)\n",
362 | "liste1"
363 | ]
364 | },
365 | {
366 | "cell_type": "code",
367 | "execution_count": 15,
368 | "metadata": {},
369 | "outputs": [],
370 | "source": [
371 | "liste1.append(\"Hatice\")"
372 | ]
373 | },
374 | {
375 | "cell_type": "code",
376 | "execution_count": 16,
377 | "metadata": {},
378 | "outputs": [
379 | {
380 | "data": {
381 | "text/plain": [
382 | "[3, 4, 5, 6, 7, 'Hatice']"
383 | ]
384 | },
385 | "execution_count": 16,
386 | "metadata": {},
387 | "output_type": "execute_result"
388 | }
389 | ],
390 | "source": [
391 | "liste1"
392 | ]
393 | },
394 | {
395 | "cell_type": "markdown",
396 | "metadata": {},
397 | "source": [
398 | "#### pop metodu\n",
399 | "Bu metod, içine değer vermezsek listenin son indeksindeki elemanı, değer verirsek verdiğimiz değere karşılık gelen indeksteki elemanı listeden atar. Ekrana attığı elemanı yazar.\n",
400 | "\n"
401 | ]
402 | },
403 | {
404 | "cell_type": "code",
405 | "execution_count": 17,
406 | "metadata": {},
407 | "outputs": [
408 | {
409 | "data": {
410 | "text/plain": [
411 | "5"
412 | ]
413 | },
414 | "execution_count": 17,
415 | "metadata": {},
416 | "output_type": "execute_result"
417 | }
418 | ],
419 | "source": [
420 | "liste2 = [1,2,3,4,5]\n",
421 | "liste2.pop() # atılan eleman ekrana yazılır"
422 | ]
423 | },
424 | {
425 | "cell_type": "code",
426 | "execution_count": 18,
427 | "metadata": {},
428 | "outputs": [
429 | {
430 | "data": {
431 | "text/plain": [
432 | "[1, 2, 3, 4]"
433 | ]
434 | },
435 | "execution_count": 18,
436 | "metadata": {},
437 | "output_type": "execute_result"
438 | }
439 | ],
440 | "source": [
441 | "liste2"
442 | ]
443 | },
444 | {
445 | "cell_type": "code",
446 | "execution_count": 19,
447 | "metadata": {},
448 | "outputs": [
449 | {
450 | "data": {
451 | "text/plain": [
452 | "3"
453 | ]
454 | },
455 | "execution_count": 19,
456 | "metadata": {},
457 | "output_type": "execute_result"
458 | }
459 | ],
460 | "source": [
461 | "eleman = liste2.pop(2)\n",
462 | "eleman"
463 | ]
464 | },
465 | {
466 | "cell_type": "code",
467 | "execution_count": 20,
468 | "metadata": {},
469 | "outputs": [
470 | {
471 | "data": {
472 | "text/plain": [
473 | "[1, 2, 4]"
474 | ]
475 | },
476 | "execution_count": 20,
477 | "metadata": {},
478 | "output_type": "execute_result"
479 | }
480 | ],
481 | "source": [
482 | "liste2"
483 | ]
484 | },
485 | {
486 | "cell_type": "code",
487 | "execution_count": 21,
488 | "metadata": {},
489 | "outputs": [
490 | {
491 | "data": {
492 | "text/plain": [
493 | "[1, 2, 4, 'Hatice']"
494 | ]
495 | },
496 | "execution_count": 21,
497 | "metadata": {},
498 | "output_type": "execute_result"
499 | }
500 | ],
501 | "source": [
502 | "liste2.append(\"Hatice\")\n",
503 | "liste2"
504 | ]
505 | },
506 | {
507 | "cell_type": "code",
508 | "execution_count": 22,
509 | "metadata": {},
510 | "outputs": [
511 | {
512 | "data": {
513 | "text/plain": [
514 | "'Hatice'"
515 | ]
516 | },
517 | "execution_count": 22,
518 | "metadata": {},
519 | "output_type": "execute_result"
520 | }
521 | ],
522 | "source": [
523 | "liste2.pop()"
524 | ]
525 | },
526 | {
527 | "cell_type": "code",
528 | "execution_count": 23,
529 | "metadata": {},
530 | "outputs": [
531 | {
532 | "data": {
533 | "text/plain": [
534 | "[1, 2, 4]"
535 | ]
536 | },
537 | "execution_count": 23,
538 | "metadata": {},
539 | "output_type": "execute_result"
540 | }
541 | ],
542 | "source": [
543 | "liste2"
544 | ]
545 | },
546 | {
547 | "cell_type": "code",
548 | "execution_count": 24,
549 | "metadata": {},
550 | "outputs": [
551 | {
552 | "data": {
553 | "text/plain": [
554 | "4"
555 | ]
556 | },
557 | "execution_count": 24,
558 | "metadata": {},
559 | "output_type": "execute_result"
560 | }
561 | ],
562 | "source": [
563 | "liste3 = [12,54,67,67]\n",
564 | "len(liste3)\n",
565 | "#liste elemanının boyunun 1 eksiği kadar indexi vardır. "
566 | ]
567 | },
568 | {
569 | "cell_type": "code",
570 | "execution_count": 25,
571 | "metadata": {},
572 | "outputs": [
573 | {
574 | "ename": "IndexError",
575 | "evalue": "list index out of range",
576 | "output_type": "error",
577 | "traceback": [
578 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
579 | "\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
580 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mliste3\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m50\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;31m#burada hata alırız çünkü listemizde 50.indeks yok\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
581 | "\u001b[1;31mIndexError\u001b[0m: list index out of range"
582 | ]
583 | }
584 | ],
585 | "source": [
586 | "liste3[50] #burada hata alırız çünkü listemizde 50.indeks yok"
587 | ]
588 | },
589 | {
590 | "cell_type": "markdown",
591 | "metadata": {},
592 | "source": [
593 | "#### sort metodu\n",
594 | "sort metodu listenin elemanlarını sıralamamızı sağlar.\n"
595 | ]
596 | },
597 | {
598 | "cell_type": "code",
599 | "execution_count": 26,
600 | "metadata": {},
601 | "outputs": [
602 | {
603 | "data": {
604 | "text/plain": [
605 | "[1, 2, 3, 19, 23, 34, 56, 334]"
606 | ]
607 | },
608 | "execution_count": 26,
609 | "metadata": {},
610 | "output_type": "execute_result"
611 | }
612 | ],
613 | "source": [
614 | "liste = [34,1,56,334,23,2,3,19]\n",
615 | "liste.sort() # Küçükten büyüğe sıralar.\n",
616 | "liste"
617 | ]
618 | },
619 | {
620 | "cell_type": "code",
621 | "execution_count": 27,
622 | "metadata": {},
623 | "outputs": [
624 | {
625 | "data": {
626 | "text/plain": [
627 | "[334, 56, 34, 23, 19, 3, 2, 1]"
628 | ]
629 | },
630 | "execution_count": 27,
631 | "metadata": {},
632 | "output_type": "execute_result"
633 | }
634 | ],
635 | "source": [
636 | "liste.sort(reverse = True) # Büyükten küçüğe sıralar.\n",
637 | "liste"
638 | ]
639 | },
640 | {
641 | "cell_type": "code",
642 | "execution_count": 28,
643 | "metadata": {},
644 | "outputs": [
645 | {
646 | "data": {
647 | "text/plain": [
648 | "['Armut', 'Elma', 'Kiraz', 'Muz']"
649 | ]
650 | },
651 | "execution_count": 28,
652 | "metadata": {},
653 | "output_type": "execute_result"
654 | }
655 | ],
656 | "source": [
657 | "liste = [\"Elma\",\"Armut\",\"Muz\",\"Kiraz\"]\n",
658 | "liste.sort() # Alfabetik olarak küçükten büyüğe\n",
659 | "liste"
660 | ]
661 | },
662 | {
663 | "cell_type": "code",
664 | "execution_count": 29,
665 | "metadata": {},
666 | "outputs": [
667 | {
668 | "data": {
669 | "text/plain": [
670 | "['Muz', 'Kiraz', 'Elma', 'Armut']"
671 | ]
672 | },
673 | "execution_count": 29,
674 | "metadata": {},
675 | "output_type": "execute_result"
676 | }
677 | ],
678 | "source": [
679 | "liste = [\"Elma\",\"Armut\",\"Muz\",\"Kiraz\"]\n",
680 | "liste.sort(reverse = True) # Alfabetik olarak büyükten küçüğe \n",
681 | "liste"
682 | ]
683 | },
684 | {
685 | "cell_type": "markdown",
686 | "metadata": {},
687 | "source": [
688 | "### İç içe Listeler\n"
689 | ]
690 | },
691 | {
692 | "cell_type": "code",
693 | "execution_count": 30,
694 | "metadata": {},
695 | "outputs": [
696 | {
697 | "data": {
698 | "text/plain": [
699 | "[[1, 2, 3], [4, 5, 6], [7, 8, 9]]"
700 | ]
701 | },
702 | "execution_count": 30,
703 | "metadata": {},
704 | "output_type": "execute_result"
705 | }
706 | ],
707 | "source": [
708 | "# Büyük bir liste içerisinde elemanları da liste olan yeni bir liste oluşturulur.\n",
709 | "\n",
710 | "#3 Tane liste oluşturalım.\n",
711 | "\n",
712 | "liste1 = [1,2,3]\n",
713 | "liste2 = [4,5,6]\n",
714 | "liste3 = [7,8,9]\n",
715 | "\n",
716 | "yeniliste = [liste1,liste2,liste3]\n",
717 | "yeniliste"
718 | ]
719 | },
720 | {
721 | "cell_type": "code",
722 | "execution_count": 31,
723 | "metadata": {},
724 | "outputs": [
725 | {
726 | "data": {
727 | "text/plain": [
728 | "3"
729 | ]
730 | },
731 | "execution_count": 31,
732 | "metadata": {},
733 | "output_type": "execute_result"
734 | }
735 | ],
736 | "source": [
737 | "len(yeniliste)"
738 | ]
739 | },
740 | {
741 | "cell_type": "code",
742 | "execution_count": 32,
743 | "metadata": {},
744 | "outputs": [
745 | {
746 | "data": {
747 | "text/plain": [
748 | "4"
749 | ]
750 | },
751 | "execution_count": 32,
752 | "metadata": {},
753 | "output_type": "execute_result"
754 | }
755 | ],
756 | "source": [
757 | "# 1.elemanın 0.elemanı\n",
758 | "yeniliste[1][0]"
759 | ]
760 | },
761 | {
762 | "cell_type": "code",
763 | "execution_count": 33,
764 | "metadata": {},
765 | "outputs": [
766 | {
767 | "data": {
768 | "text/plain": [
769 | "9"
770 | ]
771 | },
772 | "execution_count": 33,
773 | "metadata": {},
774 | "output_type": "execute_result"
775 | }
776 | ],
777 | "source": [
778 | "# 2.elemanın 2.elemanı\n",
779 | "yeniliste[2][2] "
780 | ]
781 | },
782 | {
783 | "cell_type": "code",
784 | "execution_count": 34,
785 | "metadata": {},
786 | "outputs": [
787 | {
788 | "data": {
789 | "text/plain": [
790 | "1"
791 | ]
792 | },
793 | "execution_count": 34,
794 | "metadata": {},
795 | "output_type": "execute_result"
796 | }
797 | ],
798 | "source": [
799 | "yeniliste[0][0] #çıktısı ne olur?"
800 | ]
801 | },
802 | {
803 | "cell_type": "markdown",
804 | "metadata": {},
805 | "source": [
806 | "## ÖDEV 6 \n",
807 | "\n",
808 | "**1) Kullanıcıdan alınan doğum yılı bilgisine göre kaç yaşında olduğunu hesaplayan programı yazınız.** \n",
809 | "\n",
810 | "**ÖRNEK PROGRAM ÇIKTISI**\n",
811 | "\n",
812 | "Lütfen doğum yılınızı giriniz : 2008\n",
813 | "\n",
814 | "Yaşınız : 14 "
815 | ]
816 | },
817 | {
818 | "cell_type": "markdown",
819 | "metadata": {},
820 | "source": [
821 | "**2)Kullanıcıdan metre (m) cinsinden uzunluk alıp aldığınız uzunluğu santimetreye (cm) çeviren programı yazınız.**\n",
822 | "\n",
823 | "Not : 1 metre = 100 santimetre olduğunu unutmayınız, dolayısıyla aldığınız metre uzunluğunu bu şekilde santimetreye çeviriniz.\n",
824 | "\n",
825 | "**ÖRNEK PROGRAM ÇIKTISI**\n",
826 | "\n",
827 | "Lütfen metre (m) cinsinden uzunluğu giriniz : 10 \n",
828 | "\n",
829 | "Girmiş olduğunuz 10 metre (m) uzunluk 1000 santimetreye (cm) karşılık gelmektedir. \n"
830 | ]
831 | },
832 | {
833 | "cell_type": "markdown",
834 | "metadata": {},
835 | "source": [
836 | "**3) Aşağıdaki listeleri birleştirip küçükten büyüğe sıralayan programı yazınız .** \n",
837 | "\n",
838 | "tek_sayilar = [1,3,5,7,9]\n",
839 | "\n",
840 | "cift_sayilar = [2,4,6,8]\n",
841 | "\n",
842 | "\n",
843 | "**İpucu : Listeleri toplayıp sort() ile sıralayabilirsiniz.** \n",
844 | "\n",
845 | "Oluşturulan liste şu şekilde olmalıdır : [1,2,3,4,5,6,7,8,9]\n",
846 | "\n",
847 | "\n",
848 | "/n\n",
849 | "\n",
850 | "**4) Oluşturduğunuz yeni listeden 9'u silip yerine 11 ekleyen programı yazınız.** \n",
851 | "\n",
852 | "*İpucu : Önce listeden 9'u atıp sonra 11'i ekleyebilirsiniz.*\n"
853 | ]
854 | },
855 | {
856 | "cell_type": "code",
857 | "execution_count": null,
858 | "metadata": {},
859 | "outputs": [],
860 | "source": []
861 | },
862 | {
863 | "cell_type": "code",
864 | "execution_count": null,
865 | "metadata": {},
866 | "outputs": [],
867 | "source": []
868 | }
869 | ],
870 | "metadata": {
871 | "kernelspec": {
872 | "display_name": "Python 3",
873 | "language": "python",
874 | "name": "python3"
875 | },
876 | "language_info": {
877 | "codemirror_mode": {
878 | "name": "ipython",
879 | "version": 3
880 | },
881 | "file_extension": ".py",
882 | "mimetype": "text/x-python",
883 | "name": "python",
884 | "nbconvert_exporter": "python",
885 | "pygments_lexer": "ipython3",
886 | "version": "3.7.3"
887 | }
888 | },
889 | "nbformat": 4,
890 | "nbformat_minor": 2
891 | }
892 |
--------------------------------------------------------------------------------
/DersNotu-1.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "# PYTHON PROGRAMLAMA DİLİ TEMELLERİ "
8 | ]
9 | },
10 | {
11 | "cell_type": "code",
12 | "execution_count": 1,
13 | "metadata": {},
14 | "outputs": [
15 | {
16 | "name": "stdout",
17 | "output_type": "stream",
18 | "text": [
19 | "Merhaba Dünya\n"
20 | ]
21 | }
22 | ],
23 | "source": [
24 | "print (\"Merhaba Dünya\")"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": 2,
30 | "metadata": {},
31 | "outputs": [
32 | {
33 | "name": "stdout",
34 | "output_type": "stream",
35 | "text": [
36 | "İsminizi Girin : hatice\n"
37 | ]
38 | },
39 | {
40 | "data": {
41 | "text/plain": [
42 | "'hatice'"
43 | ]
44 | },
45 | "execution_count": 2,
46 | "metadata": {},
47 | "output_type": "execute_result"
48 | }
49 | ],
50 | "source": [
51 | "input (\"İsminizi Girin : \")"
52 | ]
53 | },
54 | {
55 | "cell_type": "code",
56 | "execution_count": 3,
57 | "metadata": {},
58 | "outputs": [
59 | {
60 | "name": "stdout",
61 | "output_type": "stream",
62 | "text": [
63 | "Soy Adınızı Girin: Candan\n"
64 | ]
65 | },
66 | {
67 | "data": {
68 | "text/plain": [
69 | "'Candan'"
70 | ]
71 | },
72 | "execution_count": 3,
73 | "metadata": {},
74 | "output_type": "execute_result"
75 | }
76 | ],
77 | "source": [
78 | "input (\"Soy Adınızı Girin: \")"
79 | ]
80 | },
81 | {
82 | "cell_type": "markdown",
83 | "metadata": {},
84 | "source": [
85 | "### Değişkenler (Variables) ve Sabitler (Constants)\n",
86 | "\n",
87 | "Bu kısımda değişkenleri ve sabitleri öğreneceğiz.\n",
88 | "Değişkenlerin değerleri kodun içinde değiştirilebilmektedir. Yani aynı kodun farklı bölümlerinde farklı değerler alabilirler.\n",
89 | "Sonradan değerleri değiştirilebilir.\n",
90 | "\n",
91 | "değişken_adı = değişken_değeri\n",
92 | "\n",
93 | "\n",
94 | "Sabitlerin ise değeri daha sonradan değiştirilemez. \n",
95 | "\n",
96 | "sabit_adı = sabit_değeri\n"
97 | ]
98 | },
99 | {
100 | "cell_type": "markdown",
101 | "metadata": {},
102 | "source": [
103 | "### Pythonda Atama İşlemi\n",
104 | "\n",
105 | "Pythonda bir değeri bir değişkene atamak için eşittir işaretini \" = \" kullanırım."
106 | ]
107 | },
108 | {
109 | "cell_type": "code",
110 | "execution_count": null,
111 | "metadata": {},
112 | "outputs": [],
113 | "source": [
114 | "a = 2 # a, değişken ismidir. 2 sayısı da değişkenin değeri "
115 | ]
116 | },
117 | {
118 | "cell_type": "code",
119 | "execution_count": null,
120 | "metadata": {},
121 | "outputs": [],
122 | "source": [
123 | "bilgi = 20 # değişken ismi ? , değişken sayısı ? "
124 | ]
125 | },
126 | {
127 | "cell_type": "code",
128 | "execution_count": null,
129 | "metadata": {},
130 | "outputs": [],
131 | "source": []
132 | },
133 | {
134 | "cell_type": "code",
135 | "execution_count": null,
136 | "metadata": {},
137 | "outputs": [],
138 | "source": []
139 | },
140 | {
141 | "cell_type": "markdown",
142 | "metadata": {},
143 | "source": [
144 | "### Değişkenler (Variables) ve Sabitler (Constants)\n",
145 | "\n",
146 | "Bu kısımda değişkenleri ve sabitleri öğreneceğiz.\n",
147 | "Değişkenlerin değerleri kodun içinde değiştirilebilmektedir. Yani aynı kodun farklı bölümlerinde farklı değerler alabilirler.\n",
148 | "Sonradan değerleri değiştirilebilir.\n",
149 | "\n",
150 | "değişken_adı = değişken_değeri\n",
151 | "\n",
152 | "\n",
153 | "Sabitlerin ise değeri daha sonradan değiştirilemez. \n",
154 | "\n",
155 | "sabit_adı = sabit_değeri\n"
156 | ]
157 | },
158 | {
159 | "cell_type": "code",
160 | "execution_count": 7,
161 | "metadata": {},
162 | "outputs": [
163 | {
164 | "name": "stdout",
165 | "output_type": "stream",
166 | "text": [
167 | "hatice\n",
168 | "candan\n"
169 | ]
170 | }
171 | ],
172 | "source": [
173 | "ismim = \"hatice\"\n",
174 | "soyismim = \"candan\"\n",
175 | "\n",
176 | "print(ismim)\n",
177 | "print(soyismim)"
178 | ]
179 | },
180 | {
181 | "cell_type": "code",
182 | "execution_count": 8,
183 | "metadata": {},
184 | "outputs": [
185 | {
186 | "name": "stdout",
187 | "output_type": "stream",
188 | "text": [
189 | "büşra\n"
190 | ]
191 | }
192 | ],
193 | "source": [
194 | "ismim = \"büşra\"\n",
195 | "print(ismim)"
196 | ]
197 | },
198 | {
199 | "cell_type": "code",
200 | "execution_count": 9,
201 | "metadata": {},
202 | "outputs": [],
203 | "source": [
204 | "PI = 3.14 #sabittir"
205 | ]
206 | },
207 | {
208 | "cell_type": "markdown",
209 | "metadata": {},
210 | "source": [
211 | "### Değişken İsimlendirilirken Dikkat Edilmesi Gerekenler \n",
212 | "\n",
213 | "KURALLAR !\n",
214 | "\n",
215 | "1. Değişken isimleri bir sayı ile başlayamaz\n",
216 | "2. Değişken ismi kelimelerden oluşuyorsa aralarında boşluk olamaz\n",
217 | "3. :,\"\"<>/?[]\\()*$%!--- gibi semboller değişken ismi içinde kullanılamaz, yalnızca _ sembolü kullanılabilir.\n",
218 | "4. Pythonda tanımlı anahtar kelimeler de değişken isminde kullanılamaz"
219 | ]
220 | },
221 | {
222 | "cell_type": "code",
223 | "execution_count": 30,
224 | "metadata": {},
225 | "outputs": [
226 | {
227 | "ename": "SyntaxError",
228 | "evalue": "invalid syntax (, line 1)",
229 | "output_type": "error",
230 | "traceback": [
231 | "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m kullanici adı\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
232 | ]
233 | }
234 | ],
235 | "source": [
236 | "kullanici adı #Hatalı"
237 | ]
238 | },
239 | {
240 | "cell_type": "code",
241 | "execution_count": 33,
242 | "metadata": {},
243 | "outputs": [
244 | {
245 | "ename": "TypeError",
246 | "evalue": "'int' object is not callable",
247 | "output_type": "error",
248 | "traceback": [
249 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
250 | "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
251 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprint\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
252 | "\u001b[1;31mTypeError\u001b[0m: 'int' object is not callable"
253 | ]
254 | }
255 | ],
256 | "source": [
257 | "print=5\n",
258 | "print(print)"
259 | ]
260 | },
261 | {
262 | "cell_type": "code",
263 | "execution_count": 29,
264 | "metadata": {},
265 | "outputs": [
266 | {
267 | "ename": "SyntaxError",
268 | "evalue": "invalid syntax (, line 1)",
269 | "output_type": "error",
270 | "traceback": [
271 | "\u001b[1;36m File \u001b[1;32m\"\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m 1a = 3 #Hatalı\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
272 | ]
273 | }
274 | ],
275 | "source": [
276 | "1a = 3 #Hatalı "
277 | ]
278 | },
279 | {
280 | "cell_type": "code",
281 | "execution_count": 13,
282 | "metadata": {},
283 | "outputs": [],
284 | "source": [
285 | "türk-ünlü= \"Hadise\" #Hatalı "
286 | ]
287 | },
288 | {
289 | "cell_type": "code",
290 | "execution_count": null,
291 | "metadata": {},
292 | "outputs": [],
293 | "source": [
294 | "türkünlü = \"Hadise\"\n",
295 | "türk_ünlü = \"Hadise\""
296 | ]
297 | },
298 | {
299 | "cell_type": "code",
300 | "execution_count": 17,
301 | "metadata": {},
302 | "outputs": [],
303 | "source": [
304 | "False = 3 #hatalı\n",
305 | "True = 5 #hatalı"
306 | ]
307 | },
308 | {
309 | "cell_type": "markdown",
310 | "metadata": {},
311 | "source": []
312 | },
313 | {
314 | "cell_type": "markdown",
315 | "metadata": {},
316 | "source": [
317 | "## Pythonda Sayılar\n"
318 | ]
319 | },
320 | {
321 | "cell_type": "markdown",
322 | "metadata": {},
323 | "source": [
324 | " "
325 | ]
326 | },
327 | {
328 | "cell_type": "markdown",
329 | "metadata": {},
330 | "source": [
331 | "### Tam Sayılar (Integer)\n",
332 | "\n",
333 | "Matematikte yer alan tüm sayılar Pyhtonda bir veridir. İngilizce de integer olarak bilinir.\n",
334 | "Örneğin : 5 , -25 , 2000, 695485, "
335 | ]
336 | },
337 | {
338 | "cell_type": "markdown",
339 | "metadata": {},
340 | "source": [
341 | "### Ondalıklı Sayılar (Float)\n",
342 | "\n",
343 | "Rasyonel sayılarda paydası 10 ve 10 sayısının kuvvetleri olan kesirlere ondalık sayı denmektedir. Pythonda da bu tanım geçerlidir. İngilizcesi Float olarak bilinir. Örneğin : 3.2 , 58.96 , 200.5 , -2.5"
344 | ]
345 | },
346 | {
347 | "cell_type": "code",
348 | "execution_count": 36,
349 | "metadata": {},
350 | "outputs": [
351 | {
352 | "data": {
353 | "text/plain": [
354 | "float"
355 | ]
356 | },
357 | "execution_count": 36,
358 | "metadata": {},
359 | "output_type": "execute_result"
360 | }
361 | ],
362 | "source": [
363 | "sayı1 = 5\n",
364 | "sayı2 = -56\n",
365 | "sayı3 = -2.5\n",
366 | "sayı4 = 23.8\n",
367 | "\n",
368 | "type(sayı3)"
369 | ]
370 | },
371 | {
372 | "cell_type": "markdown",
373 | "metadata": {},
374 | "source": [
375 | "### Matematiksel İşlemler \n",
376 | "\n",
377 | "Basit Dört işlemi Pythonda nasıl yaparız?\n",
378 | "\n",
379 | "Toplama = + \n",
380 | "\n",
381 | "Çıkarma = - \n",
382 | "\n",
383 | "Çarpma = * \n",
384 | "\n",
385 | "Bölme = / "
386 | ]
387 | },
388 | {
389 | "cell_type": "code",
390 | "execution_count": 23,
391 | "metadata": {},
392 | "outputs": [
393 | {
394 | "data": {
395 | "text/plain": [
396 | "18"
397 | ]
398 | },
399 | "execution_count": 23,
400 | "metadata": {},
401 | "output_type": "execute_result"
402 | }
403 | ],
404 | "source": [
405 | "15+3"
406 | ]
407 | },
408 | {
409 | "cell_type": "code",
410 | "execution_count": 24,
411 | "metadata": {},
412 | "outputs": [
413 | {
414 | "data": {
415 | "text/plain": [
416 | "12"
417 | ]
418 | },
419 | "execution_count": 24,
420 | "metadata": {},
421 | "output_type": "execute_result"
422 | }
423 | ],
424 | "source": [
425 | "15-3"
426 | ]
427 | },
428 | {
429 | "cell_type": "code",
430 | "execution_count": 25,
431 | "metadata": {},
432 | "outputs": [
433 | {
434 | "data": {
435 | "text/plain": [
436 | "45"
437 | ]
438 | },
439 | "execution_count": 25,
440 | "metadata": {},
441 | "output_type": "execute_result"
442 | }
443 | ],
444 | "source": [
445 | "15*3"
446 | ]
447 | },
448 | {
449 | "cell_type": "code",
450 | "execution_count": 26,
451 | "metadata": {},
452 | "outputs": [
453 | {
454 | "data": {
455 | "text/plain": [
456 | "5.0"
457 | ]
458 | },
459 | "execution_count": 26,
460 | "metadata": {},
461 | "output_type": "execute_result"
462 | }
463 | ],
464 | "source": [
465 | "15/3"
466 | ]
467 | },
468 | {
469 | "cell_type": "code",
470 | "execution_count": 47,
471 | "metadata": {},
472 | "outputs": [
473 | {
474 | "data": {
475 | "text/plain": [
476 | "30"
477 | ]
478 | },
479 | "execution_count": 47,
480 | "metadata": {},
481 | "output_type": "execute_result"
482 | }
483 | ],
484 | "source": [
485 | "a = 25 \n",
486 | "b = 5 \n",
487 | "toplam = a+b \n",
488 | "toplam"
489 | ]
490 | },
491 | {
492 | "cell_type": "code",
493 | "execution_count": 50,
494 | "metadata": {},
495 | "outputs": [
496 | {
497 | "data": {
498 | "text/plain": [
499 | "20"
500 | ]
501 | },
502 | "execution_count": 50,
503 | "metadata": {},
504 | "output_type": "execute_result"
505 | }
506 | ],
507 | "source": [
508 | "çıkarma = a-b\n",
509 | "çıkarma"
510 | ]
511 | },
512 | {
513 | "cell_type": "code",
514 | "execution_count": 51,
515 | "metadata": {},
516 | "outputs": [
517 | {
518 | "data": {
519 | "text/plain": [
520 | "25"
521 | ]
522 | },
523 | "execution_count": 51,
524 | "metadata": {},
525 | "output_type": "execute_result"
526 | }
527 | ],
528 | "source": [
529 | "yenisayı= çıkarma + b\n",
530 | "yenisayı"
531 | ]
532 | },
533 | {
534 | "cell_type": "code",
535 | "execution_count": 52,
536 | "metadata": {},
537 | "outputs": [
538 | {
539 | "data": {
540 | "text/plain": [
541 | "5.0"
542 | ]
543 | },
544 | "execution_count": 52,
545 | "metadata": {},
546 | "output_type": "execute_result"
547 | }
548 | ],
549 | "source": [
550 | "bölme = a / b\n",
551 | "bölme"
552 | ]
553 | },
554 | {
555 | "cell_type": "code",
556 | "execution_count": 53,
557 | "metadata": {},
558 | "outputs": [
559 | {
560 | "data": {
561 | "text/plain": [
562 | "125"
563 | ]
564 | },
565 | "execution_count": 53,
566 | "metadata": {},
567 | "output_type": "execute_result"
568 | }
569 | ],
570 | "source": [
571 | "çarpma = a*b\n",
572 | "çarpma"
573 | ]
574 | },
575 | {
576 | "cell_type": "code",
577 | "execution_count": 54,
578 | "metadata": {},
579 | "outputs": [
580 | {
581 | "data": {
582 | "text/plain": [
583 | "625"
584 | ]
585 | },
586 | "execution_count": 54,
587 | "metadata": {},
588 | "output_type": "execute_result"
589 | }
590 | ],
591 | "source": [
592 | "karesi = a*a\n",
593 | "karesi"
594 | ]
595 | },
596 | {
597 | "cell_type": "code",
598 | "execution_count": 56,
599 | "metadata": {},
600 | "outputs": [
601 | {
602 | "data": {
603 | "text/plain": [
604 | "625"
605 | ]
606 | },
607 | "execution_count": 56,
608 | "metadata": {},
609 | "output_type": "execute_result"
610 | }
611 | ],
612 | "source": [
613 | "karesi = a**2\n",
614 | "karesi"
615 | ]
616 | },
617 | {
618 | "cell_type": "code",
619 | "execution_count": null,
620 | "metadata": {},
621 | "outputs": [],
622 | "source": []
623 | },
624 | {
625 | "cell_type": "markdown",
626 | "metadata": {},
627 | "source": [
628 | "### ÖDEV - 1\n",
629 | "\n",
630 | "AŞAĞIDAKİ ADIMLARI TEK TEK UYGULAYINIZ.\n",
631 | "\n",
632 | "1) x değişkenine 6 değerini atayın\n",
633 | "\n",
634 | "2) y değişkenine 4 değerini atayın\n",
635 | "\n",
636 | "3) z değişkenine x ve y değişkenlerinin toplamını atayın\n",
637 | "\n",
638 | "4) z değişkeni ekrana yazdırın\n",
639 | "\n",
640 | "5) k değişkenine x ve y değişkenlerinin çarpımını atayın\n",
641 | "\n",
642 | "6) k değişkeni ekrana yazdırın\n",
643 | "\n",
644 | "\n",
645 | "AŞAĞIDAKİ DEĞİŞKEN İSİMLERİNDEN HATALIDIR ?\n",
646 | "\n",
647 | "1) \"kullanıcı?\" \n",
648 | "\n",
649 | "2) \"deger\"\n",
650 | "\n",
651 | "3) \"kullanıcı_adı\"\n",
652 | "\n",
653 | "4) \"3kişi\"\n",
654 | "\n",
655 | "5) \"kullanıcı%adı\"\n",
656 | "\n",
657 | "6) \"banka*hesabı+-/\" \n",
658 | "\n"
659 | ]
660 | },
661 | {
662 | "cell_type": "code",
663 | "execution_count": null,
664 | "metadata": {},
665 | "outputs": [],
666 | "source": []
667 | }
668 | ],
669 | "metadata": {
670 | "kernelspec": {
671 | "display_name": "Python 3",
672 | "language": "python",
673 | "name": "python3"
674 | },
675 | "language_info": {
676 | "codemirror_mode": {
677 | "name": "ipython",
678 | "version": 3
679 | },
680 | "file_extension": ".py",
681 | "mimetype": "text/x-python",
682 | "name": "python",
683 | "nbconvert_exporter": "python",
684 | "pygments_lexer": "ipython3",
685 | "version": "3.7.3"
686 | }
687 | },
688 | "nbformat": 4,
689 | "nbformat_minor": 2
690 | }
691 |
--------------------------------------------------------------------------------
/DersNotu-2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### ÖDEV-1\n",
8 | "AŞAĞIDAKİ ADIMLARI TEK TEK UYGULAYINIZ.\n",
9 | "\n",
10 | "1) x değişkenine 6 değerini atayın \n",
11 | "\n",
12 | "2) y değişkenine 4 değerini atayın\n",
13 | "\n",
14 | "3) z değişkenine x ve y değişkenlerinin toplamını atayın\n",
15 | "\n",
16 | "4) z değişkeni ekrana yazdırın\n",
17 | "\n",
18 | "5) k değişkenine x ve y değişkenlerinin çarpımını atayın\n",
19 | "\n",
20 | "6) k değişkeni ekrana yazdırın\n",
21 | "\n",
22 | "AŞAĞIDAKİ DEĞİŞKEN İSİMLERİNDEN HATALIDIR ?\n",
23 | "\n",
24 | "1) \"kullanıcı?\" HATALI\n",
25 | "\n",
26 | "2) \"deger\" DOĞRU\n",
27 | "\n",
28 | "3) \"kullanıcı_adı\" DOĞRU\n",
29 | "\n",
30 | "4) \"3kişi\" HATALI\n",
31 | "\n",
32 | "5) \"kullanıcı%adı\" HATALI\n",
33 | "\n",
34 | "6) \"banka*hesabı+-/\" HATALI"
35 | ]
36 | },
37 | {
38 | "cell_type": "code",
39 | "execution_count": 2,
40 | "metadata": {},
41 | "outputs": [
42 | {
43 | "name": "stdout",
44 | "output_type": "stream",
45 | "text": [
46 | "10\n"
47 | ]
48 | }
49 | ],
50 | "source": [
51 | "x=6\n",
52 | "y=4\n",
53 | "z=x+y\n",
54 | "print(z)"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": 3,
60 | "metadata": {},
61 | "outputs": [
62 | {
63 | "name": "stdout",
64 | "output_type": "stream",
65 | "text": [
66 | "24\n"
67 | ]
68 | }
69 | ],
70 | "source": [
71 | "k=x*y\n",
72 | "print(k)"
73 | ]
74 | },
75 | {
76 | "cell_type": "markdown",
77 | "metadata": {},
78 | "source": [
79 | "### DERS 2\n",
80 | "\n",
81 | "Sayılarla işlemlerden devam edeceğiz. \n"
82 | ]
83 | },
84 | {
85 | "cell_type": "code",
86 | "execution_count": 5,
87 | "metadata": {},
88 | "outputs": [
89 | {
90 | "name": "stdout",
91 | "output_type": "stream",
92 | "text": [
93 | "4\n"
94 | ]
95 | },
96 | {
97 | "data": {
98 | "text/plain": [
99 | "8"
100 | ]
101 | },
102 | "execution_count": 5,
103 | "metadata": {},
104 | "output_type": "execute_result"
105 | }
106 | ],
107 | "source": [
108 | "a=2 \n",
109 | "karesi = a**2\n",
110 | "print(karesi)\n",
111 | "kübü = a**3\n",
112 | "kübü"
113 | ]
114 | },
115 | {
116 | "cell_type": "code",
117 | "execution_count": 67,
118 | "metadata": {},
119 | "outputs": [
120 | {
121 | "name": "stdout",
122 | "output_type": "stream",
123 | "text": [
124 | "5.7\n"
125 | ]
126 | }
127 | ],
128 | "source": [
129 | "#Toplama İşlemi\n",
130 | "ilksayi=2.2\n",
131 | "ikincisayi= 3.5\n",
132 | "toplam = ilksayi+ikincisayi\n",
133 | "print(toplam)"
134 | ]
135 | },
136 | {
137 | "cell_type": "code",
138 | "execution_count": 7,
139 | "metadata": {},
140 | "outputs": [
141 | {
142 | "data": {
143 | "text/plain": [
144 | "float"
145 | ]
146 | },
147 | "execution_count": 7,
148 | "metadata": {},
149 | "output_type": "execute_result"
150 | }
151 | ],
152 | "source": [
153 | "type(toplam) #type fonksiyonu sayının hangi tip olduğunu gösterir"
154 | ]
155 | },
156 | {
157 | "cell_type": "code",
158 | "execution_count": 8,
159 | "metadata": {},
160 | "outputs": [
161 | {
162 | "name": "stdout",
163 | "output_type": "stream",
164 | "text": [
165 | "5.500000000000001\n"
166 | ]
167 | }
168 | ],
169 | "source": [
170 | "#Çıkarma İşlemi\n",
171 | "ilksayi=8.8\n",
172 | "ikincisayi= 3.3\n",
173 | "çıkar = ilksayi - ikincisayi\n",
174 | "print(çıkar)"
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": 9,
180 | "metadata": {},
181 | "outputs": [
182 | {
183 | "name": "stdout",
184 | "output_type": "stream",
185 | "text": [
186 | "3.5\n"
187 | ]
188 | }
189 | ],
190 | "source": [
191 | "#Çarpma İşlemi\n",
192 | "sayi_bir = 2.5\n",
193 | "sayi_iki = 1.4\n",
194 | "çarpma = sayi_bir * sayi_iki\n",
195 | "print(çarpma)"
196 | ]
197 | },
198 | {
199 | "cell_type": "code",
200 | "execution_count": 13,
201 | "metadata": {
202 | "scrolled": true
203 | },
204 | "outputs": [
205 | {
206 | "name": "stdout",
207 | "output_type": "stream",
208 | "text": [
209 | "4.5\n"
210 | ]
211 | }
212 | ],
213 | "source": [
214 | "#Bölme İşlemi\n",
215 | "sayi_bir = 7.2\n",
216 | "sayi_iki = 1.6\n",
217 | "bolme = sayi_bir /sayi_iki\n",
218 | "print(bolme)"
219 | ]
220 | },
221 | {
222 | "cell_type": "markdown",
223 | "metadata": {},
224 | "source": [
225 | "### UYGULAMA 1 : DAİRENİN ÇEVRESİNİ HESAPLAYALIM\n",
226 | "\n",
227 | "İlk olarak algoritmayı düşünelim. Dairenin çevresi için bize neler lazım. \n",
228 | "\n",
229 | "Daire çevresi = 2*pi*r formülünden bulunuyor. \n",
230 | "\n",
231 | "Burada pi sayısı ve dairenin yarıçapı (r) gereklidir. \n",
232 | "\n",
233 | "Pi sayısı ile dairenin çapını ve 2 sayısını çarpnınca dairenin çevresi bulunmaktadır. "
234 | ]
235 | },
236 | {
237 | "cell_type": "code",
238 | "execution_count": 14,
239 | "metadata": {},
240 | "outputs": [
241 | {
242 | "name": "stdout",
243 | "output_type": "stream",
244 | "text": [
245 | "24\n"
246 | ]
247 | }
248 | ],
249 | "source": [
250 | "pi_sayısı = 3\n",
251 | "yarıçap = 4 \n",
252 | "çevre = 2*pi_sayısı*yarıçap\n",
253 | "print(çevre)\n"
254 | ]
255 | },
256 | {
257 | "cell_type": "markdown",
258 | "metadata": {},
259 | "source": [
260 | "#### Şimdi ise daire yarıçapını kullanıcıdan isteyelim . Burada input fonksiyonu kullanmamız gerekmektedir "
261 | ]
262 | },
263 | {
264 | "cell_type": "code",
265 | "execution_count": 20,
266 | "metadata": {},
267 | "outputs": [
268 | {
269 | "name": "stdout",
270 | "output_type": "stream",
271 | "text": [
272 | "Dairenin yarıçapını giriniz : 2\n",
273 | "12\n"
274 | ]
275 | }
276 | ],
277 | "source": [
278 | "yarıçap=int(input(\"Dairenin yarıçapını giriniz : \"))\n",
279 | "çevre =2*pi_sayısı*yarıçap\n",
280 | "print(çevre)"
281 | ]
282 | },
283 | {
284 | "cell_type": "markdown",
285 | "metadata": {},
286 | "source": [
287 | "### UYGULAMA 2 : DAİRENİN ALANINI HESAPLAYALIM\n",
288 | "\n",
289 | "İlk olarak algoritmayı düşünelim. Dairenin alanı için bize neler lazım. \n",
290 | "\n",
291 | "Daire alanı = pi*r**2 formülünden bulunuyor. \n",
292 | "\n",
293 | "Burada pi sayısı ve dairenin yarıçapı (r) gereklidir. \n",
294 | "\n",
295 | "Pi sayısı ile dairenin yarıçapının karesini çarpınca dairenin alanı bulunmaktadır. "
296 | ]
297 | },
298 | {
299 | "cell_type": "code",
300 | "execution_count": 21,
301 | "metadata": {},
302 | "outputs": [
303 | {
304 | "name": "stdout",
305 | "output_type": "stream",
306 | "text": [
307 | "12\n"
308 | ]
309 | }
310 | ],
311 | "source": [
312 | "pi_sayısı = 3\n",
313 | "yarıçap = 2\n",
314 | "alan=pi_sayısı *yarıçap**2\n",
315 | "print(alan)"
316 | ]
317 | },
318 | {
319 | "cell_type": "markdown",
320 | "metadata": {},
321 | "source": [
322 | "#### Şimdi ise daire yarıçapını kullanıcıdan isteyelim . Burada input fonksiyonu kullanmamız gerekmektedir "
323 | ]
324 | },
325 | {
326 | "cell_type": "code",
327 | "execution_count": 51,
328 | "metadata": {},
329 | "outputs": [
330 | {
331 | "name": "stdout",
332 | "output_type": "stream",
333 | "text": [
334 | "Dairenin yarıçapını giriniz : 5\n",
335 | "75\n",
336 | "Dairenin alanı = 75\n",
337 | "Yarıçapı 5 olan dairenin alanı 75 metrekaredir.\n"
338 | ]
339 | }
340 | ],
341 | "source": [
342 | "yarıçap=int(input(\"Dairenin yarıçapını giriniz : \"))\n",
343 | "alan=pi_sayısı *yarıçap**2\n",
344 | "print(alan)\n",
345 | "print(\"Dairenin alanı = \", alan)\n",
346 | "print(\"Yarıçapı \", yarıçap, \"olan dairenin alanı \", alan, \"metrekaredir.\")"
347 | ]
348 | },
349 | {
350 | "cell_type": "markdown",
351 | "metadata": {},
352 | "source": [
353 | "### UYGULAMA 3 : ÜÇGENİN ÇEVRESİNİ HESAPLAYALIM\n",
354 | "\n",
355 | "İlk olarak algoritmayı düşünelim. Üçgenin çevresi için bize neler lazım. \n",
356 | "\n",
357 | "Üçgenin çevresi = kenar1 + kenar2 +kenar3 formülünden bulunuyor. \n",
358 | "\n",
359 | "Burada bize üçgenin 3 kenarının da uzunluğu gereklidir. "
360 | ]
361 | },
362 | {
363 | "cell_type": "code",
364 | "execution_count": 62,
365 | "metadata": {},
366 | "outputs": [
367 | {
368 | "name": "stdout",
369 | "output_type": "stream",
370 | "text": [
371 | "Üçgenin kenarlarını giriniz : 523\n"
372 | ]
373 | },
374 | {
375 | "data": {
376 | "text/plain": [
377 | "10"
378 | ]
379 | },
380 | "execution_count": 62,
381 | "metadata": {},
382 | "output_type": "execute_result"
383 | }
384 | ],
385 | "source": [
386 | "kenar1,kenar2,kenar3=input(\"Üçgenin kenarlarını giriniz : \")\n",
387 | "kenar1 = int(kenar1)\n",
388 | "kenar2 = int(kenar2)\n",
389 | "kenar3 = int(kenar3)\n",
390 | "çevre = kenar1+ kenar2 +kenar3\n"
391 | ]
392 | },
393 | {
394 | "cell_type": "markdown",
395 | "metadata": {},
396 | "source": [
397 | "### ÖDEV 2 : BİR DİKDÖRTGENİN ALANINI VE ÇEVRESİNİ HESAPLAYAN PROGRAMI YAZINIZ\n",
398 | "\n",
399 | "- Dikdörtgenin kenar uzunluklarını kısa kenar ve uzun kenar olarak kullanıcıdan tek tek alınız. \n",
400 | "- Dİkdörtgenin karşılıklı kenarlarının birbirine eşit olduğunu unutmayınız.\n",
401 | "- Dikdörtgenin alanı için formülümüz = kısa kenar x uzun kenar\n",
402 | "- Dikdörtgenin çevresi için formülümüz = 2 x (kısa kenar + uzun kenar)\n",
403 | "- Çevre ve alan değerlerini ekrana yazdırınız. \n",
404 | "\n",
405 | "Örneğin;\n",
406 | "\n",
407 | "\"Kısa kenarı 3, uzun kenarı 5 olan dikdörtgenin çevresi 16\"\n",
408 | "\n",
409 | "\"Kısa kenarı 3, uzun kenarı 5 olan dikdörtgenin alanı 15\""
410 | ]
411 | },
412 | {
413 | "cell_type": "markdown",
414 | "metadata": {},
415 | "source": [
416 | "### Yorum Satırı (Comment Line)\n",
417 | "\n",
418 | "Programımıza açıklama olarak eklediğimiz satırlardır. \n",
419 | "Bu satırlar Pyhton tarafından görülmez ve çalıştırılmazlar fakat kodumuzu açıklamak için kullanılırlar\n",
420 | "kare, diyez, şarp # işareti konulur\n",
421 | "\n"
422 | ]
423 | },
424 | {
425 | "cell_type": "code",
426 | "execution_count": 35,
427 | "metadata": {},
428 | "outputs": [
429 | {
430 | "name": "stdout",
431 | "output_type": "stream",
432 | "text": [
433 | "11\n"
434 | ]
435 | }
436 | ],
437 | "source": [
438 | "# Yorum satırı\n",
439 | "print(5+6)"
440 | ]
441 | },
442 | {
443 | "cell_type": "code",
444 | "execution_count": null,
445 | "metadata": {},
446 | "outputs": [],
447 | "source": []
448 | }
449 | ],
450 | "metadata": {
451 | "kernelspec": {
452 | "display_name": "Python 3",
453 | "language": "python",
454 | "name": "python3"
455 | },
456 | "language_info": {
457 | "codemirror_mode": {
458 | "name": "ipython",
459 | "version": 3
460 | },
461 | "file_extension": ".py",
462 | "mimetype": "text/x-python",
463 | "name": "python",
464 | "nbconvert_exporter": "python",
465 | "pygments_lexer": "ipython3",
466 | "version": "3.7.3"
467 | }
468 | },
469 | "nbformat": 4,
470 | "nbformat_minor": 2
471 | }
472 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # pythoncourse-101-Türkçe
2 | From zero to hero Python Course
3 |
4 | Burada Python ile ilgili sıfır başlangıç seviyesinden ileri seviyeye kadar adım adım notları bulabileceksiniz.
5 |
--------------------------------------------------------------------------------