├── Python_Part1.ipynb
├── Python_Part2.ipynb
└── README.md
/Python_Part1.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "name": "PG1926-Day1.ipynb",
7 | "provenance": [],
8 | "collapsed_sections": [
9 | "IdTKuqyFmCN9"
10 | ],
11 | "include_colab_link": true
12 | },
13 | "kernelspec": {
14 | "display_name": "Python 3",
15 | "language": "python",
16 | "name": "python3"
17 | },
18 | "language_info": {
19 | "codemirror_mode": {
20 | "name": "ipython",
21 | "version": 3
22 | },
23 | "file_extension": ".py",
24 | "mimetype": "text/x-python",
25 | "name": "python",
26 | "nbconvert_exporter": "python",
27 | "pygments_lexer": "ipython3",
28 | "version": "3.7.4"
29 | }
30 | },
31 |
32 | "cells": [
33 | {
34 | "cell_type": "markdown",
35 | "metadata": {
36 | "id": "view-in-github",
37 | "colab_type": "text"
38 | },
39 | "source": [
40 | "
"
41 | ]
42 | },
43 | {
44 | "cell_type": "markdown",
45 | "metadata": {
46 | "id": "2Q1wEAMJhAcV"
47 | },
48 | "source": [
49 | "### Versiyon Kontrolü\r\n"
50 | ]
51 | },
52 | {
53 | "cell_type": "code",
54 | "metadata": {
55 | "id": "pHxZk2qOhAcV"
56 | },
57 | "source": [
58 | "!python --version"
59 | ],
60 | "execution_count": null,
61 | "outputs": []
62 | },
63 | {
64 | "cell_type": "markdown",
65 | "metadata": {
66 | "id": "iWHzxrdvXU0-"
67 | },
68 | "source": [
69 | " ### Her yazılım dilinin ilk adımı \"Hello World!\"\r\n",
70 | " "
71 | ]
72 | },
73 | {
74 | "cell_type": "code",
75 | "metadata": {
76 | "id": "NGB3j3LcdcbR",
77 | "scrolled": true
78 | },
79 | "source": [
80 | "print(\"Hello World!\")"
81 | ],
82 | "execution_count": null,
83 | "outputs": []
84 | },
85 | {
86 | "cell_type": "code",
87 | "metadata": {
88 | "id": "luSgefSQgFrV"
89 | },
90 | "source": [
91 | "print('Hello World')"
92 | ],
93 | "execution_count": null,
94 | "outputs": []
95 | },
96 | {
97 | "cell_type": "code",
98 | "metadata": {
99 | "id": "g_52IrQIgcPv"
100 | },
101 | "source": [
102 | "print(\"Hello1\")\n",
103 | "print(\"Hello2\")\n",
104 | "print(\"Hello3\")\n",
105 | "print(\"Welcome to PG1926\")"
106 | ],
107 | "execution_count": null,
108 | "outputs": []
109 | },
110 | {
111 | "cell_type": "code",
112 | "metadata": {
113 | "id": "2ualX2qpg3Hy"
114 | },
115 | "source": [
116 | "print \"Hello World\""
117 | ],
118 | "execution_count": null,
119 | "outputs": []
120 | },
121 | {
122 | "cell_type": "code",
123 | "metadata": {
124 | "id": "0BOHOWOdhcgp"
125 | },
126 | "source": [
127 | "print(Hello)"
128 | ],
129 | "execution_count": null,
130 | "outputs": []
131 | },
132 | {
133 | "cell_type": "code",
134 | "metadata": {
135 | "id": "G69sCzFUhi5j"
136 | },
137 | "source": [
138 | "print(\"Hello')"
139 | ],
140 | "execution_count": null,
141 | "outputs": []
142 | },
143 | {
144 | "cell_type": "markdown",
145 | "metadata": {
146 | "id": "aWYakJiQhAcV"
147 | },
148 | "source": [
149 | "### Yorum Satırı\r\n"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "metadata": {
155 | "id": "JsFmw9IuFSKR"
156 | },
157 | "source": [
158 | "#taking some notes \n",
159 | "#taking some notes\n",
160 | "#take a note"
161 | ],
162 | "execution_count": null,
163 | "outputs": []
164 | },
165 | {
166 | "cell_type": "code",
167 | "metadata": {
168 | "id": "llzXRK61FadN"
169 | },
170 | "source": [
171 | "\n",
172 | "'''Michael Irwin Jordan is an American scientist, professor at the University of California, \n",
173 | "Berkeley and researcher in machine learning, statistics, and artificial intelligence.\n",
174 | "He is one of the leading figures in machine learning, \n",
175 | "and in 2016 Science reported him as the world's most influential computer scientist.\n",
176 | "'''.replace(\"\\n\",\" \")\n"
177 | ],
178 | "execution_count": null,
179 | "outputs": []
180 | },
181 | {
182 | "cell_type": "code",
183 | "metadata": {
184 | "id": "gs7XpZNIhAcW"
185 | },
186 | "source": [
187 | "\n",
188 | "\"\"\"\n",
189 | "write something\n",
190 | "\"\"\"\n"
191 | ],
192 | "execution_count": null,
193 | "outputs": []
194 | },
195 | {
196 | "cell_type": "markdown",
197 | "metadata": {
198 | "id": "TwLBhEjAhAcW"
199 | },
200 | "source": [
201 | "### Değişken Tanımlama\n",
202 | "\n",
203 | "* variable = value\n",
204 | "\n",
205 | "* n = 5"
206 | ]
207 | },
208 | {
209 | "cell_type": "code",
210 | "metadata": {
211 | "id": "Sb178VuUloLP",
212 | "scrolled": true
213 | },
214 | "source": [
215 | "n = 1 \n",
216 | "print(n)"
217 | ],
218 | "execution_count": null,
219 | "outputs": []
220 | },
221 | {
222 | "cell_type": "code",
223 | "metadata": {
224 | "id": "18yuPbb5m9GG"
225 | },
226 | "source": [
227 | "p = n\n",
228 | "print(p)"
229 | ],
230 | "execution_count": null,
231 | "outputs": []
232 | },
233 | {
234 | "cell_type": "markdown",
235 | "metadata": {
236 | "id": "WG8myBdPhAcX"
237 | },
238 | "source": [
239 | "### Veri Tipleri\n",
240 | "* Integer (Tam sayı)\n",
241 | "* Float (Kayar noktalı sayı)\n",
242 | "* String (Karakter dizisi)\n",
243 | "* Boolean\n",
244 | "* Complex (Karmaşık sayılar)\n",
245 | "* List (Liste)\n",
246 | "* Dictionary (Sözlük)\n",
247 | "* Tuple (Demet)\n",
248 | "* Set (Küme)\n"
249 | ]
250 | },
251 | {
252 | "cell_type": "code",
253 | "metadata": {
254 | "id": "GO6WONnhnVjB"
255 | },
256 | "source": [
257 | "#String\n",
258 | "hello = \"World\""
259 | ],
260 | "execution_count": null,
261 | "outputs": []
262 | },
263 | {
264 | "cell_type": "code",
265 | "metadata": {
266 | "id": "2YZLBCcinyfx"
267 | },
268 | "source": [
269 | "print(hello) #print variable\n",
270 | "print(\"World\") #print value\n",
271 | "print(n)"
272 | ],
273 | "execution_count": null,
274 | "outputs": []
275 | },
276 | {
277 | "cell_type": "code",
278 | "metadata": {
279 | "id": "SUUJq6chhAcY"
280 | },
281 | "source": [
282 | "#type() \n",
283 | "type(hello)"
284 | ],
285 | "execution_count": null,
286 | "outputs": []
287 | },
288 | {
289 | "cell_type": "code",
290 | "metadata": {
291 | "id": "letAfxW_oHH-"
292 | },
293 | "source": [
294 | "print(type(hello)) #print data type"
295 | ],
296 | "execution_count": null,
297 | "outputs": []
298 | },
299 | {
300 | "cell_type": "code",
301 | "metadata": {
302 | "id": "o6zYYebwhAcY"
303 | },
304 | "source": [
305 | "#Integer\n",
306 | "int_value = 5\n",
307 | "int_value"
308 | ],
309 | "execution_count": null,
310 | "outputs": []
311 | },
312 | {
313 | "cell_type": "code",
314 | "metadata": {
315 | "id": "lQcQh8oMomlP"
316 | },
317 | "source": [
318 | "print(type(int_value))"
319 | ],
320 | "execution_count": null,
321 | "outputs": []
322 | },
323 | {
324 | "cell_type": "code",
325 | "metadata": {
326 | "id": "FMM4y1JXMjsL"
327 | },
328 | "source": [
329 | "t = 3.19\n",
330 | "print(type(t))"
331 | ],
332 | "execution_count": null,
333 | "outputs": []
334 | },
335 | {
336 | "cell_type": "code",
337 | "metadata": {
338 | "id": "hfJLQQPihAcZ"
339 | },
340 | "source": [
341 | "type('x')"
342 | ],
343 | "execution_count": null,
344 | "outputs": []
345 | },
346 | {
347 | "cell_type": "code",
348 | "metadata": {
349 | "id": "7DtsrxEHyHUH"
350 | },
351 | "source": [
352 | "#Boolean\n",
353 | "t, f = True, False\n",
354 | "print(type(t))\n",
355 | "print(t)\n",
356 | "print(f)"
357 | ],
358 | "execution_count": null,
359 | "outputs": []
360 | },
361 | {
362 | "cell_type": "code",
363 | "metadata": {
364 | "id": "VOFssaJZhAcZ"
365 | },
366 | "source": [
367 | "#swapping\n",
368 | "data1 = 7 \n",
369 | "data2 = 12\n",
370 | "data3 = 23\n",
371 | "data4 = 33\n",
372 | "\n",
373 | "data1, data2, data3 , data4 = data2 , data1, data4, data3\n",
374 | "print(data1, data2, data3, data4)"
375 | ],
376 | "execution_count": null,
377 | "outputs": []
378 | },
379 | {
380 | "cell_type": "code",
381 | "metadata": {
382 | "id": "KDP17P0zhAcZ"
383 | },
384 | "source": [
385 | "print(\"data1:\", data1, \"data:\", data2)"
386 | ],
387 | "execution_count": null,
388 | "outputs": []
389 | },
390 | {
391 | "cell_type": "code",
392 | "metadata": {
393 | "id": "vRQDCHxLhAca"
394 | },
395 | "source": [
396 | "metin = \"\"\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"\n",
397 | "\n",
398 | "Section 1.10.32 of \"de Finibus Bonorum et Malorum\", written by Cicero in 45 BC\n",
399 | "\"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?\"\n",
400 | "\n",
401 | "1914 translation by H. Rackham\n",
402 | "\"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?\"\"\""
403 | ],
404 | "execution_count": null,
405 | "outputs": []
406 | },
407 | {
408 | "cell_type": "code",
409 | "metadata": {
410 | "id": "h1UFC3ARhAca"
411 | },
412 | "source": [
413 | "len(metin)"
414 | ],
415 | "execution_count": null,
416 | "outputs": []
417 | },
418 | {
419 | "cell_type": "code",
420 | "metadata": {
421 | "id": "UleuXLMVwCgG"
422 | },
423 | "source": [
424 | "print(len(metin)) #print data length "
425 | ],
426 | "execution_count": null,
427 | "outputs": []
428 | },
429 | {
430 | "cell_type": "code",
431 | "metadata": {
432 | "id": "8JIXMfUVhAcb"
433 | },
434 | "source": [
435 | "len(5)"
436 | ],
437 | "execution_count": null,
438 | "outputs": []
439 | },
440 | {
441 | "cell_type": "code",
442 | "metadata": {
443 | "id": "xD-DL1OUhAcb"
444 | },
445 | "source": [
446 | "len(15.6)"
447 | ],
448 | "execution_count": null,
449 | "outputs": []
450 | },
451 | {
452 | "cell_type": "code",
453 | "metadata": {
454 | "id": "EjtEb3GDhAcc"
455 | },
456 | "source": [
457 | "a = 15\n",
458 | "b = 23\n",
459 | "\n",
460 | "a, b = b, a\n",
461 | "print(a)\n",
462 | "print(b)"
463 | ],
464 | "execution_count": null,
465 | "outputs": []
466 | },
467 | {
468 | "cell_type": "code",
469 | "metadata": {
470 | "id": "cD0F7XrOhAcc"
471 | },
472 | "source": [
473 | "data12 = 5\n",
474 | "data13 = 90\n",
475 | "print(\"My value:{} and Your value:{}\".format(data12, data13))"
476 | ],
477 | "execution_count": null,
478 | "outputs": []
479 | },
480 | {
481 | "cell_type": "markdown",
482 | "metadata": {
483 | "id": "rOEAqInQGFVu"
484 | },
485 | "source": [
486 | "### Aritmetik Operatörler"
487 | ]
488 | },
489 | {
490 | "cell_type": "code",
491 | "metadata": {
492 | "id": "OQzlT59exPuY"
493 | },
494 | "source": [
495 | "#Üslü ifadeler\n",
496 | "5**2"
497 | ],
498 | "execution_count": null,
499 | "outputs": []
500 | },
501 | {
502 | "cell_type": "code",
503 | "metadata": {
504 | "id": "OyW_9a9fhAcf"
505 | },
506 | "source": [
507 | "5**3"
508 | ],
509 | "execution_count": null,
510 | "outputs": []
511 | },
512 | {
513 | "cell_type": "code",
514 | "metadata": {
515 | "id": "IT5uTIgBGRIz"
516 | },
517 | "source": [
518 | "35+67"
519 | ],
520 | "execution_count": null,
521 | "outputs": []
522 | },
523 | {
524 | "cell_type": "code",
525 | "metadata": {
526 | "id": "UIwXGkZqGVId"
527 | },
528 | "source": [
529 | "\"35\"+\"67\""
530 | ],
531 | "execution_count": null,
532 | "outputs": []
533 | },
534 | {
535 | "cell_type": "code",
536 | "metadata": {
537 | "id": "y0RFHDpZhAcf"
538 | },
539 | "source": [
540 | "\"PG\" + \"1926\""
541 | ],
542 | "execution_count": null,
543 | "outputs": []
544 | },
545 | {
546 | "cell_type": "code",
547 | "metadata": {
548 | "id": "Qx0vjBUmGZNk"
549 | },
550 | "source": [
551 | "\"35\" + 67 "
552 | ],
553 | "execution_count": null,
554 | "outputs": []
555 | },
556 | {
557 | "cell_type": "code",
558 | "metadata": {
559 | "id": "_EzMFsTMGbw5"
560 | },
561 | "source": [
562 | "\"35\"*3 "
563 | ],
564 | "execution_count": null,
565 | "outputs": []
566 | },
567 | {
568 | "cell_type": "code",
569 | "metadata": {
570 | "id": "X_FiEHA9GlUH"
571 | },
572 | "source": [
573 | "\"hello\"*4"
574 | ],
575 | "execution_count": null,
576 | "outputs": []
577 | },
578 | {
579 | "cell_type": "code",
580 | "metadata": {
581 | "id": "zVujz21ZhAcg"
582 | },
583 | "source": [
584 | "\"hello\" \"world\""
585 | ],
586 | "execution_count": null,
587 | "outputs": []
588 | },
589 | {
590 | "cell_type": "code",
591 | "metadata": {
592 | "id": "qCIBU4v8HH3Y"
593 | },
594 | "source": [
595 | "x = 10\n",
596 | "\n",
597 | "print(x+2)\n",
598 | "print(x-2)\n",
599 | "print(x*2)\n",
600 | "print(x**2)\n",
601 | "print(x**4)\n",
602 | "print(x/2)\n",
603 | "print(x//2) \n",
604 | "print(x%2) "
605 | ],
606 | "execution_count": null,
607 | "outputs": []
608 | },
609 | {
610 | "cell_type": "code",
611 | "metadata": {
612 | "id": "imzLVXBYLNhW"
613 | },
614 | "source": [
615 | "y = 13\n",
616 | "print(y/2)\n",
617 | "print(y//2)\n",
618 | "print(y % 2)"
619 | ],
620 | "execution_count": null,
621 | "outputs": []
622 | },
623 | {
624 | "cell_type": "code",
625 | "metadata": {
626 | "id": "nr-s8OwrhAch"
627 | },
628 | "source": [
629 | "z= 5\n",
630 | "z +=2 #z = z + 2\n",
631 | "z"
632 | ],
633 | "execution_count": null,
634 | "outputs": []
635 | },
636 | {
637 | "cell_type": "code",
638 | "metadata": {
639 | "id": "2HOE_xOGL3WQ"
640 | },
641 | "source": [
642 | "z*=2 # z = z * 2\n",
643 | "z"
644 | ],
645 | "execution_count": null,
646 | "outputs": []
647 | },
648 | {
649 | "cell_type": "markdown",
650 | "metadata": {
651 | "id": "IdTKuqyFmCN9"
652 | },
653 | "source": [
654 | "### Tür Dönüşümleri\n",
655 | "* str() \n",
656 | "* float() \n",
657 | "* int()"
658 | ]
659 | },
660 | {
661 | "cell_type": "code",
662 | "metadata": {
663 | "id": "sYFsQbIamCN-"
664 | },
665 | "source": [
666 | "str(\"Python\")"
667 | ],
668 | "execution_count": null,
669 | "outputs": []
670 | },
671 | {
672 | "cell_type": "code",
673 | "metadata": {
674 | "id": "zBJuLanemCN-"
675 | },
676 | "source": [
677 | "float(5)"
678 | ],
679 | "execution_count": null,
680 | "outputs": []
681 | },
682 | {
683 | "cell_type": "code",
684 | "metadata": {
685 | "id": "Exznao8bmCN-"
686 | },
687 | "source": [
688 | "type(5.0)"
689 | ],
690 | "execution_count": null,
691 | "outputs": []
692 | },
693 | {
694 | "cell_type": "code",
695 | "metadata": {
696 | "id": "XVv7MCTVmCN-"
697 | },
698 | "source": [
699 | "int(float(5.7))"
700 | ],
701 | "execution_count": null,
702 | "outputs": []
703 | },
704 | {
705 | "cell_type": "code",
706 | "metadata": {
707 | "id": "AZm-mbcmmCN_"
708 | },
709 | "source": [
710 | "float(\"6.2\")"
711 | ],
712 | "execution_count": null,
713 | "outputs": []
714 | },
715 | {
716 | "cell_type": "code",
717 | "metadata": {
718 | "id": "yZRZLgscmCN_"
719 | },
720 | "source": [
721 | "float(\"Hello\")"
722 | ],
723 | "execution_count": null,
724 | "outputs": []
725 | },
726 | {
727 | "cell_type": "code",
728 | "metadata": {
729 | "id": "QNftrnEfmCN_"
730 | },
731 | "source": [
732 | "int(5.5)"
733 | ],
734 | "execution_count": null,
735 | "outputs": []
736 | },
737 | {
738 | "cell_type": "markdown",
739 | "metadata": {
740 | "id": "0txXkvbamCN_"
741 | },
742 | "source": [
743 | "### İndexleme ve Dilimleme"
744 | ]
745 | },
746 | {
747 | "cell_type": "code",
748 | "metadata": {
749 | "id": "vZjNAoLVR5U0"
750 | },
751 | "source": [
752 | "hello = \"Hello\"\n",
753 | "print(hello)\n",
754 | "print(hello[0])\n",
755 | "print(hello[1])\n",
756 | "print(hello[2])\n",
757 | "print(hello[3])\n",
758 | "print(hello[4])"
759 | ],
760 | "execution_count": null,
761 | "outputs": []
762 | },
763 | {
764 | "cell_type": "code",
765 | "metadata": {
766 | "id": "HQoj_jsUmCOA"
767 | },
768 | "source": [
769 | "hello2 = \" Hello\"\n",
770 | "hello2[0]"
771 | ],
772 | "execution_count": null,
773 | "outputs": []
774 | },
775 | {
776 | "cell_type": "code",
777 | "metadata": {
778 | "id": "3CUMwNM_mCOA"
779 | },
780 | "source": [
781 | "print(hello[5])"
782 | ],
783 | "execution_count": null,
784 | "outputs": []
785 | },
786 | {
787 | "cell_type": "code",
788 | "metadata": {
789 | "id": "0zG_UBbW_SFu"
790 | },
791 | "source": [
792 | "job = \" Engineering\"\n",
793 | "\n",
794 | "print(job[-5])"
795 | ],
796 | "execution_count": null,
797 | "outputs": []
798 | },
799 | {
800 | "cell_type": "code",
801 | "metadata": {
802 | "id": "Scvqz7-FmCOB"
803 | },
804 | "source": [
805 | "print(hello)"
806 | ],
807 | "execution_count": null,
808 | "outputs": []
809 | },
810 | {
811 | "cell_type": "code",
812 | "metadata": {
813 | "id": "uTZeixoumCOB"
814 | },
815 | "source": [
816 | "hello"
817 | ],
818 | "execution_count": null,
819 | "outputs": []
820 | },
821 | {
822 | "cell_type": "code",
823 | "metadata": {
824 | "id": "1gW2be5tWek7"
825 | },
826 | "source": [
827 | "hello[2:4] # [x:y] --> x elemanını dahil eder fakat y elemanını dahil etmez."
828 | ],
829 | "execution_count": null,
830 | "outputs": []
831 | },
832 | {
833 | "cell_type": "code",
834 | "metadata": {
835 | "id": "4d12Mq3n03zL"
836 | },
837 | "source": [
838 | "hello[::-1] "
839 | ],
840 | "execution_count": null,
841 | "outputs": []
842 | },
843 | {
844 | "cell_type": "code",
845 | "metadata": {
846 | "id": "XxKt6pqvmCOC"
847 | },
848 | "source": [
849 | "world"
850 | ],
851 | "execution_count": null,
852 | "outputs": []
853 | },
854 | {
855 | "cell_type": "code",
856 | "metadata": {
857 | "id": "3hrKJQS2a6A5"
858 | },
859 | "source": [
860 | "world[2:4:1] # [start:end:step]"
861 | ],
862 | "execution_count": null,
863 | "outputs": []
864 | },
865 | {
866 | "cell_type": "code",
867 | "metadata": {
868 | "id": "1Kgd14H_bNAj"
869 | },
870 | "source": [
871 | "city = \"istanbul\"\n",
872 | "city[0:6:2]"
873 | ],
874 | "execution_count": null,
875 | "outputs": []
876 | },
877 | {
878 | "cell_type": "code",
879 | "metadata": {
880 | "id": "az6ygCGue2sY"
881 | },
882 | "source": [
883 | "word = 'machine learning'\n",
884 | "print(word.capitalize())"
885 | ],
886 | "execution_count": null,
887 | "outputs": []
888 | },
889 | {
890 | "cell_type": "code",
891 | "metadata": {
892 | "id": "3nF1ST9UfCGu"
893 | },
894 | "source": [
895 | "print(word.upper())"
896 | ],
897 | "execution_count": null,
898 | "outputs": []
899 | },
900 | {
901 | "cell_type": "code",
902 | "metadata": {
903 | "id": "9r6KvgMYfiVQ"
904 | },
905 | "source": [
906 | "print(word.replace('machine','artificial'))"
907 | ],
908 | "execution_count": null,
909 | "outputs": []
910 | },
911 | {
912 | "cell_type": "code",
913 | "metadata": {
914 | "id": "TjnWT_9Zfs2r"
915 | },
916 | "source": [
917 | "word"
918 | ],
919 | "execution_count": null,
920 | "outputs": []
921 | },
922 | {
923 | "cell_type": "code",
924 | "metadata": {
925 | "id": "H1WYJsidfw-G"
926 | },
927 | "source": [
928 | "word2 = \" artificial general intelligence\"\n",
929 | "print(word2.strip())"
930 | ],
931 | "execution_count": null,
932 | "outputs": []
933 | },
934 | {
935 | "cell_type": "code",
936 | "metadata": {
937 | "id": "Voc6zKLzhlmv"
938 | },
939 | "source": [
940 | "y = input(\"Please enter a city name: \") #input methodu değeri her zaman string ifadesi olarak tutar \n",
941 | "print(y)"
942 | ],
943 | "execution_count": null,
944 | "outputs": []
945 | },
946 | {
947 | "cell_type": "code",
948 | "metadata": {
949 | "id": "Wey_2y-3mCOG"
950 | },
951 | "source": [
952 | "type(y)"
953 | ],
954 | "execution_count": null,
955 | "outputs": []
956 | },
957 | {
958 | "cell_type": "code",
959 | "metadata": {
960 | "id": "3zyJI9oljhQi"
961 | },
962 | "source": [
963 | "x = int(input(\"Please enter an integer: \"))\n",
964 | "print(x)"
965 | ],
966 | "execution_count": null,
967 | "outputs": []
968 | },
969 | {
970 | "cell_type": "code",
971 | "metadata": {
972 | "id": "570NLil5mCOH"
973 | },
974 | "source": [
975 | "type(x)"
976 | ],
977 | "execution_count": null,
978 | "outputs": []
979 | },
980 | {
981 | "cell_type": "markdown",
982 | "metadata": {
983 | "id": "Uqstf6kg1CCT"
984 | },
985 | "source": [
986 | "### If/Else Durumları\n",
987 | "\n",
988 | "if \"condition\":\n",
989 | "\n",
990 | "\n",
991 | "> \"doing sth\"\n",
992 | "\n",
993 | "print()\n"
994 | ]
995 | },
996 | {
997 | "cell_type": "code",
998 | "metadata": {
999 | "id": "8E_cCL6adJSR"
1000 | },
1001 | "source": [
1002 | "ort = input('Ortalamanızı Girin : ')\r\n",
1003 | "if(int(ort)>=50):\r\n",
1004 | " print(\"Geçtiniz\")\r\n",
1005 | "else:\r\n",
1006 | " print(\"Kaldınız\")"
1007 | ],
1008 | "execution_count": null,
1009 | "outputs": []
1010 | },
1011 | {
1012 | "cell_type": "code",
1013 | "metadata": {
1014 | "id": "aQww_2VKeWbd"
1015 | },
1016 | "source": [
1017 | "sayi = input('Sayı : ')\r\n",
1018 | "if(int(sayi)%2==0):\r\n",
1019 | " print(\"Sayı Çift\")\r\n",
1020 | "else:\r\n",
1021 | " print(\"Sayı Tek\")"
1022 | ],
1023 | "execution_count": null,
1024 | "outputs": []
1025 | },
1026 | {
1027 | "cell_type": "code",
1028 | "metadata": {
1029 | "id": "1gdtAyGZ1MTD"
1030 | },
1031 | "source": [
1032 | "a = int(input(\"Bir sayı giriniz: \"))\n",
1033 | "\n",
1034 | "if a < 100:\n",
1035 | " print(\"verdiğiniz sayı 100'den küçüktür.\")\n",
1036 | "\n",
1037 | "elif a < 50:\n",
1038 | " print(\"verdiğiniz sayı 50'den küçüktür.\")\n",
1039 | "\n",
1040 | "elif a == 100:\n",
1041 | " print(\"verdiğiniz sayı 100'dür.\")\n",
1042 | "\n",
1043 | "elif a > 150:\n",
1044 | " print(\"verdiğiniz sayı 150'den büyüktür.\")\n",
1045 | "\n",
1046 | "elif a > 100:\n",
1047 | " print(\"verdiğiniz sayı 100'den büyüktür.\")"
1048 | ],
1049 | "execution_count": null,
1050 | "outputs": []
1051 | },
1052 | {
1053 | "cell_type": "code",
1054 | "metadata": {
1055 | "id": "3hmeanZ757dR"
1056 | },
1057 | "source": [
1058 | "kullanıcı_adı = input(\"Kullanıcı adınız: \")\n",
1059 | "parola = input(\"Parolanız : \")\n",
1060 | "\n",
1061 | "toplam_uzunluk = len(kullanıcı_adı) + len(parola)\n",
1062 | "\n",
1063 | "\n",
1064 | "if toplam_uzunluk > 40:\n",
1065 | " print(\"Kullanıcı adınız ile parolanızın \",\n",
1066 | " \"toplam uzunluğu 40 karakteri geçmemeli!\")\n",
1067 | "else:\n",
1068 | " print(\"Sisteme hoşgeldiniz!\")"
1069 | ],
1070 | "execution_count": null,
1071 | "outputs": []
1072 | },
1073 | {
1074 | "cell_type": "markdown",
1075 | "metadata": {
1076 | "id": "zvyKibr2vVNm"
1077 | },
1078 | "source": [
1079 | "### Liste (list)\r\n",
1080 | "Python list, yani liste, herhangi bir sayıda diğer objeleri içinde bulunduran bir sandık vazifesi görüyor. Diğer dillerdeki listelerden en önemli farkı ise, bir listede birden fazla tip öğenin yanyana bulunabilmesi. Diğer konteynır tarzı objelerden farkı ise, listeler değişebilir (mutable) olması ve sıralı olması diyebiliriz. Diğer konteynırlar nedir derseniz, kümeler (set) ve sözlükler (dict) bunlara örnek olarak gösterilebilir."
1081 | ]
1082 | },
1083 | {
1084 | "cell_type": "code",
1085 | "metadata": {
1086 | "id": "njA7EYZGv07w",
1087 | "scrolled": true
1088 | },
1089 | "source": [
1090 | " # creating a list\n",
1091 | "mylist = [3,5,6,7]\n",
1092 | "print(mylist) "
1093 | ],
1094 | "execution_count": null,
1095 | "outputs": []
1096 | },
1097 | {
1098 | "cell_type": "code",
1099 | "metadata": {
1100 | "id": "MxsQ4t8pmCOI"
1101 | },
1102 | "source": [
1103 | "type(mylist)"
1104 | ],
1105 | "execution_count": null,
1106 | "outputs": []
1107 | },
1108 | {
1109 | "cell_type": "code",
1110 | "metadata": {
1111 | "id": "hQhGEzmPwgQ2"
1112 | },
1113 | "source": [
1114 | "print(mylist[0])\n",
1115 | "print(mylist[2])\n",
1116 | "print(mylist[-1])\n",
1117 | "print(mylist[-3])"
1118 | ],
1119 | "execution_count": null,
1120 | "outputs": []
1121 | },
1122 | {
1123 | "cell_type": "code",
1124 | "metadata": {
1125 | "id": "VQ7gQ-2kmCOI"
1126 | },
1127 | "source": [
1128 | "a = 5\n",
1129 | "print(a)"
1130 | ],
1131 | "execution_count": null,
1132 | "outputs": []
1133 | },
1134 | {
1135 | "cell_type": "code",
1136 | "metadata": {
1137 | "id": "Z0v9ZqhNmCOI"
1138 | },
1139 | "source": [
1140 | "a = 3\n",
1141 | "print(a)"
1142 | ],
1143 | "execution_count": null,
1144 | "outputs": []
1145 | },
1146 | {
1147 | "cell_type": "code",
1148 | "metadata": {
1149 | "id": "ngPWrPA_w3gG"
1150 | },
1151 | "source": [
1152 | "mylist[2] = \"python\" # listeler farklı veri tiplerini bir arada bulundurabilir.\n",
1153 | "print(mylist)"
1154 | ],
1155 | "execution_count": null,
1156 | "outputs": []
1157 | },
1158 | {
1159 | "cell_type": "code",
1160 | "metadata": {
1161 | "id": "hI6Wz-NWxMuG"
1162 | },
1163 | "source": [
1164 | "mylist.append('course') # append(): listenin sonuna bir eleman ekler.\n",
1165 | "print(mylist)"
1166 | ],
1167 | "execution_count": null,
1168 | "outputs": []
1169 | },
1170 | {
1171 | "cell_type": "code",
1172 | "metadata": {
1173 | "id": "dqz8xPRgxdHU"
1174 | },
1175 | "source": [
1176 | "mylist = [3,4,5,6,7]\n",
1177 | "mylist.append('course')\n",
1178 | "mylist.append('course')\n",
1179 | "print(mylist)\n",
1180 | "\n",
1181 | "thelast = mylist.pop() # pop(): listenin sonundaki son elemanı siler.\n",
1182 | "print(thelast)\n",
1183 | "print(mylist)"
1184 | ],
1185 | "execution_count": null,
1186 | "outputs": []
1187 | },
1188 | {
1189 | "cell_type": "code",
1190 | "metadata": {
1191 | "id": "HpPBYsAzmCOJ"
1192 | },
1193 | "source": [
1194 | "mylist"
1195 | ],
1196 | "execution_count": null,
1197 | "outputs": []
1198 | },
1199 | {
1200 | "cell_type": "code",
1201 | "metadata": {
1202 | "id": "Dt0ef3SiyJng"
1203 | },
1204 | "source": [
1205 | "mylist.index(\"course\")"
1206 | ],
1207 | "execution_count": null,
1208 | "outputs": []
1209 | },
1210 | {
1211 | "cell_type": "code",
1212 | "metadata": {
1213 | "id": "r1A4DZ4syQtk"
1214 | },
1215 | "source": [
1216 | "mylist.index(4)"
1217 | ],
1218 | "execution_count": null,
1219 | "outputs": []
1220 | },
1221 | {
1222 | "cell_type": "code",
1223 | "metadata": {
1224 | "id": "iFn2-UYKyWCZ"
1225 | },
1226 | "source": [
1227 | "mylist.count(\"course\")"
1228 | ],
1229 | "execution_count": null,
1230 | "outputs": []
1231 | },
1232 | {
1233 | "cell_type": "code",
1234 | "metadata": {
1235 | "id": "PXBtBlAXmCOK"
1236 | },
1237 | "source": [
1238 | "list2 = [\"Python\",\"Java\",\"R\",\"JavaScript\",\"Ruby\",\"Python\",\"Python\"]\n",
1239 | "list2.count(\"Python\")\n"
1240 | ],
1241 | "execution_count": null,
1242 | "outputs": []
1243 | },
1244 | {
1245 | "cell_type": "code",
1246 | "metadata": {
1247 | "id": "58nCPJ27mCOK"
1248 | },
1249 | "source": [
1250 | "mylist"
1251 | ],
1252 | "execution_count": null,
1253 | "outputs": []
1254 | },
1255 | {
1256 | "cell_type": "code",
1257 | "metadata": {
1258 | "id": "46qXsaPbyowR"
1259 | },
1260 | "source": [
1261 | "mylist.remove(\"course\")\n",
1262 | "print(mylist)"
1263 | ],
1264 | "execution_count": null,
1265 | "outputs": []
1266 | },
1267 | {
1268 | "cell_type": "code",
1269 | "metadata": {
1270 | "id": "UlKtby-1zYVT"
1271 | },
1272 | "source": [
1273 | "mylist.sort()\n",
1274 | "mylist"
1275 | ],
1276 | "execution_count": null,
1277 | "outputs": []
1278 | },
1279 | {
1280 | "cell_type": "code",
1281 | "metadata": {
1282 | "id": "Kdqlr7yQmCOL"
1283 | },
1284 | "source": [
1285 | "list3 = [100,23,87,13,1000]"
1286 | ],
1287 | "execution_count": null,
1288 | "outputs": []
1289 | },
1290 | {
1291 | "cell_type": "code",
1292 | "metadata": {
1293 | "id": "ZECprhx7mCOL"
1294 | },
1295 | "source": [
1296 | "list3.sort()\n",
1297 | "list3"
1298 | ],
1299 | "execution_count": null,
1300 | "outputs": []
1301 | },
1302 | {
1303 | "cell_type": "code",
1304 | "metadata": {
1305 | "id": "cNauyviRmCOL"
1306 | },
1307 | "source": [
1308 | "list4 = [41,23,78,99,37,2.9,2.8]\n",
1309 | "list4.sort()\n",
1310 | "list4"
1311 | ],
1312 | "execution_count": null,
1313 | "outputs": []
1314 | },
1315 | {
1316 | "cell_type": "code",
1317 | "metadata": {
1318 | "id": "6E5ZHeormCOM"
1319 | },
1320 | "source": [
1321 | "list4.remove()\r\n"
1322 | ],
1323 | "execution_count": null,
1324 | "outputs": []
1325 | },
1326 | {
1327 | "cell_type": "code",
1328 | "metadata": {
1329 | "id": "Ks3NHMA_mCOM"
1330 | },
1331 | "source": [
1332 | "list5 = [41,23,78,99,37,'python']\n",
1333 | "list5.sort()\n",
1334 | "list5"
1335 | ],
1336 | "execution_count": null,
1337 | "outputs": []
1338 | },
1339 | {
1340 | "cell_type": "code",
1341 | "metadata": {
1342 | "id": "5lcp5UifmCOM"
1343 | },
1344 | "source": [
1345 | "mylist"
1346 | ],
1347 | "execution_count": null,
1348 | "outputs": []
1349 | },
1350 | {
1351 | "cell_type": "code",
1352 | "metadata": {
1353 | "id": "E26Vtqlyzfal"
1354 | },
1355 | "source": [
1356 | "mylist.remove(\"course\")\n",
1357 | "mylist.remove(\"python\")\n",
1358 | "print(mylist)"
1359 | ],
1360 | "execution_count": null,
1361 | "outputs": []
1362 | },
1363 | {
1364 | "cell_type": "code",
1365 | "metadata": {
1366 | "id": "aSsRxEvPowM-"
1367 | },
1368 | "source": [
1369 | "mylist.remove(\"course\")\n",
1370 | "print(mylist)"
1371 | ],
1372 | "execution_count": null,
1373 | "outputs": []
1374 | },
1375 | {
1376 | "cell_type": "code",
1377 | "metadata": {
1378 | "id": "2pnKy1t7znEH"
1379 | },
1380 | "source": [
1381 | "mylist.sort()\n",
1382 | "mylist"
1383 | ],
1384 | "execution_count": null,
1385 | "outputs": []
1386 | },
1387 | {
1388 | "cell_type": "code",
1389 | "metadata": {
1390 | "id": "06kYH0sqmCON"
1391 | },
1392 | "source": [
1393 | "mylist = [3,4,5,6,7]"
1394 | ],
1395 | "execution_count": null,
1396 | "outputs": []
1397 | },
1398 | {
1399 | "cell_type": "code",
1400 | "metadata": {
1401 | "id": "sjC4_sbzzt0n"
1402 | },
1403 | "source": [
1404 | "mylist.reverse()\n",
1405 | "mylist"
1406 | ],
1407 | "execution_count": null,
1408 | "outputs": []
1409 | },
1410 | {
1411 | "cell_type": "code",
1412 | "metadata": {
1413 | "id": "SDVAJpN3z4md"
1414 | },
1415 | "source": [
1416 | "mylist2 = [\"python\", \"course\", \"hello\"]\n",
1417 | "mylist2.sort()\n",
1418 | "mylist2"
1419 | ],
1420 | "execution_count": null,
1421 | "outputs": []
1422 | },
1423 | {
1424 | "cell_type": "code",
1425 | "metadata": {
1426 | "id": "HyQrtFNwmCON"
1427 | },
1428 | "source": [
1429 | "mylist"
1430 | ],
1431 | "execution_count": null,
1432 | "outputs": []
1433 | },
1434 | {
1435 | "cell_type": "code",
1436 | "metadata": {
1437 | "id": "t8fn5qremCOO"
1438 | },
1439 | "source": [
1440 | "list_in_list = [\"python\",\"Java\",3.2, 4, 11, [5,65,7,8,9]]\n",
1441 | "print(list_in_list[5])"
1442 | ],
1443 | "execution_count": null,
1444 | "outputs": []
1445 | },
1446 | {
1447 | "cell_type": "code",
1448 | "metadata": {
1449 | "id": "sENNgOgYmCOO"
1450 | },
1451 | "source": [
1452 | "list_in_list[-1]"
1453 | ],
1454 | "execution_count": null,
1455 | "outputs": []
1456 | },
1457 | {
1458 | "cell_type": "code",
1459 | "metadata": {
1460 | "id": "32M3RVubmCOO"
1461 | },
1462 | "source": [
1463 | "mylist = [2, 3, 4, 5, 6, 'python', 'flutter', 'Android', 'JavaScript', 'dart', 3.2, 5.0]"
1464 | ],
1465 | "execution_count": null,
1466 | "outputs": []
1467 | },
1468 | {
1469 | "cell_type": "code",
1470 | "metadata": {
1471 | "id": "TrlAuQrZmqPe"
1472 | },
1473 | "source": [
1474 | "numbers2 = list(range(2,15,3)) #range(start, stop, step)\n",
1475 | "print(numbers2)\n",
1476 | "numbers2.reverse()\n",
1477 | "print(numbers2)"
1478 | ],
1479 | "execution_count": null,
1480 | "outputs": []
1481 | },
1482 | {
1483 | "cell_type": "markdown",
1484 | "metadata": {
1485 | "id": "IdVXxCBHJ07g"
1486 | },
1487 | "source": [
1488 | "### Sözlük (dictionary)\n",
1489 | "Sözlükler de Tuple ve List veri türleri gibi farklı veri türleri bulunur fakat sözlükler biraz farklıdır. Sözlükler süslü parantezler ile ifade edilir ve iki kısımdan oluşur; keys(anahtar) ve value(değer), value kısmı bütün veri türünü içerebilir fakat keys kısmı sadece string ve int tipinde olabilir. Sözlüklerde değiştirilebilir veri türü olup ekleme,çıkarma vb. işlemler yapılabilir.\n",
1490 | "\n",
1491 | "\n"
1492 | ]
1493 | },
1494 | {
1495 | "cell_type": "code",
1496 | "metadata": {
1497 | "id": "-fo5_OkfcFz4"
1498 | },
1499 | "source": [
1500 | "d = {}\n",
1501 | "\n",
1502 | "print(d)\n",
1503 | "type(d)"
1504 | ],
1505 | "execution_count": null,
1506 | "outputs": []
1507 | },
1508 | {
1509 | "cell_type": "code",
1510 | "metadata": {
1511 | "id": "n5qcMd-GLsKa"
1512 | },
1513 | "source": [
1514 | "d = {\"python\":1, \"course\":2}\n",
1515 | "print(d)"
1516 | ],
1517 | "execution_count": null,
1518 | "outputs": []
1519 | },
1520 | {
1521 | "cell_type": "code",
1522 | "metadata": {
1523 | "id": "EX9oMWnHL7fq"
1524 | },
1525 | "source": [
1526 | "d2 = {\"machine\":\"learning\", \"artificial\":\"intelligence\" }\n",
1527 | "d2"
1528 | ],
1529 | "execution_count": null,
1530 | "outputs": []
1531 | },
1532 | {
1533 | "cell_type": "code",
1534 | "metadata": {
1535 | "id": "eckt9hWHMKyB"
1536 | },
1537 | "source": [
1538 | "d2[\"artificial\"]"
1539 | ],
1540 | "execution_count": null,
1541 | "outputs": []
1542 | },
1543 | {
1544 | "cell_type": "code",
1545 | "metadata": {
1546 | "id": "P07ODlUDcFz5"
1547 | },
1548 | "source": [
1549 | "d2[\"java\"] = \"programming\"\n",
1550 | "d2"
1551 | ],
1552 | "execution_count": null,
1553 | "outputs": []
1554 | },
1555 | {
1556 | "cell_type": "code",
1557 | "metadata": {
1558 | "id": "aGhqBey1cFz5"
1559 | },
1560 | "source": [
1561 | "d2[\"ruby\"] = \"programming\"\n",
1562 | "d2"
1563 | ],
1564 | "execution_count": null,
1565 | "outputs": []
1566 | },
1567 | {
1568 | "cell_type": "code",
1569 | "metadata": {
1570 | "id": "iwJO06pLcFz6"
1571 | },
1572 | "source": [
1573 | "d2[\"ruby\"] = \"language\"\n",
1574 | "d2"
1575 | ],
1576 | "execution_count": null,
1577 | "outputs": []
1578 | },
1579 | {
1580 | "cell_type": "code",
1581 | "metadata": {
1582 | "id": "V4-QRNaWcFz6"
1583 | },
1584 | "source": [
1585 | "d"
1586 | ],
1587 | "execution_count": null,
1588 | "outputs": []
1589 | },
1590 | {
1591 | "cell_type": "code",
1592 | "metadata": {
1593 | "id": "EtB2gyEmMWjy"
1594 | },
1595 | "source": [
1596 | "d[\"course\"]"
1597 | ],
1598 | "execution_count": null,
1599 | "outputs": []
1600 | },
1601 | {
1602 | "cell_type": "code",
1603 | "metadata": {
1604 | "id": "t2flZAV2NIIq"
1605 | },
1606 | "source": [
1607 | "d2[\"deep\"] = \"learning\"\n",
1608 | "d2"
1609 | ],
1610 | "execution_count": null,
1611 | "outputs": []
1612 | },
1613 | {
1614 | "cell_type": "code",
1615 | "metadata": {
1616 | "id": "ntLDke2enyh6"
1617 | },
1618 | "source": [
1619 | "print(d.keys())"
1620 | ],
1621 | "execution_count": null,
1622 | "outputs": []
1623 | },
1624 | {
1625 | "cell_type": "code",
1626 | "metadata": {
1627 | "id": "y9HV_zWLcFz7"
1628 | },
1629 | "source": [
1630 | "d2.keys()"
1631 | ],
1632 | "execution_count": null,
1633 | "outputs": []
1634 | },
1635 | {
1636 | "cell_type": "code",
1637 | "metadata": {
1638 | "id": "RRCll5K-oEW6"
1639 | },
1640 | "source": [
1641 | "d2.values()"
1642 | ],
1643 | "execution_count": null,
1644 | "outputs": []
1645 | },
1646 | {
1647 | "cell_type": "code",
1648 | "metadata": {
1649 | "id": "YYzF_DyGoHWm"
1650 | },
1651 | "source": [
1652 | "d2.items()"
1653 | ],
1654 | "execution_count": null,
1655 | "outputs": []
1656 | },
1657 | {
1658 | "cell_type": "code",
1659 | "metadata": {
1660 | "id": "fmxKFTs4pqwP"
1661 | },
1662 | "source": [
1663 | "d"
1664 | ],
1665 | "execution_count": null,
1666 | "outputs": []
1667 | },
1668 | {
1669 | "cell_type": "code",
1670 | "metadata": {
1671 | "id": "iy6FAQxHpt6Q"
1672 | },
1673 | "source": [
1674 | "d[\"a\"] = [3,4,5]\n",
1675 | "d"
1676 | ],
1677 | "execution_count": null,
1678 | "outputs": []
1679 | },
1680 | {
1681 | "cell_type": "code",
1682 | "metadata": {
1683 | "id": "AINo_32Upzyv"
1684 | },
1685 | "source": [
1686 | "d.pop(\"python\")\n",
1687 | "d"
1688 | ],
1689 | "execution_count": null,
1690 | "outputs": []
1691 | },
1692 | {
1693 | "cell_type": "code",
1694 | "metadata": {
1695 | "id": "QjErEFgGcFz9"
1696 | },
1697 | "source": [
1698 | "d.pop(\"python\")\n",
1699 | "d"
1700 | ],
1701 | "execution_count": null,
1702 | "outputs": []
1703 | },
1704 | {
1705 | "cell_type": "code",
1706 | "metadata": {
1707 | "id": "nsOgHRxScFz9"
1708 | },
1709 | "source": [
1710 | "d"
1711 | ],
1712 | "execution_count": null,
1713 | "outputs": []
1714 | },
1715 | {
1716 | "cell_type": "code",
1717 | "metadata": {
1718 | "id": "U8QBwgp0sSJi"
1719 | },
1720 | "source": [
1721 | "len(d)"
1722 | ],
1723 | "execution_count": null,
1724 | "outputs": []
1725 | },
1726 | {
1727 | "cell_type": "code",
1728 | "metadata": {
1729 | "id": "89k7tFi_sWJO"
1730 | },
1731 | "source": [
1732 | "\"a\" in d"
1733 | ],
1734 | "execution_count": null,
1735 | "outputs": []
1736 | },
1737 | {
1738 | "cell_type": "code",
1739 | "metadata": {
1740 | "id": "XdyIf0L1sYRM"
1741 | },
1742 | "source": [
1743 | "\"3\" in d #Soru"
1744 | ],
1745 | "execution_count": null,
1746 | "outputs": []
1747 | },
1748 | {
1749 | "cell_type": "code",
1750 | "metadata": {
1751 | "id": "oJvHWYyouN9w"
1752 | },
1753 | "source": [
1754 | "d2"
1755 | ],
1756 | "execution_count": null,
1757 | "outputs": []
1758 | },
1759 | {
1760 | "cell_type": "code",
1761 | "metadata": {
1762 | "id": "wamfJIWHcFz_"
1763 | },
1764 | "source": [
1765 | "d2"
1766 | ],
1767 | "execution_count": null,
1768 | "outputs": []
1769 | },
1770 | {
1771 | "cell_type": "code",
1772 | "metadata": {
1773 | "id": "nyH6npGYuhRD"
1774 | },
1775 | "source": [
1776 | "del d2[\"deep\"]\n",
1777 | "d2"
1778 | ],
1779 | "execution_count": null,
1780 | "outputs": []
1781 | },
1782 | {
1783 | "cell_type": "code",
1784 | "metadata": {
1785 | "id": "VJ1MoCoZcFz_"
1786 | },
1787 | "source": [
1788 | "d2"
1789 | ],
1790 | "execution_count": null,
1791 | "outputs": []
1792 | },
1793 | {
1794 | "cell_type": "code",
1795 | "metadata": {
1796 | "id": "xiSnYPJGcFz_"
1797 | },
1798 | "source": [
1799 | "d2['machine'] = \"Deep Learning\"\n",
1800 | "d2"
1801 | ],
1802 | "execution_count": null,
1803 | "outputs": []
1804 | },
1805 | {
1806 | "cell_type": "code",
1807 | "metadata": {
1808 | "id": "kyINE7YscF0A"
1809 | },
1810 | "source": [
1811 | "d2_copy = d2.copy()\n",
1812 | "d2_copy"
1813 | ],
1814 | "execution_count": null,
1815 | "outputs": []
1816 | },
1817 | {
1818 | "cell_type": "code",
1819 | "metadata": {
1820 | "id": "2YCOmkG8cF0A"
1821 | },
1822 | "source": [
1823 | "d2_copy['deep'] = 'AI'\n",
1824 | "d2_copy"
1825 | ],
1826 | "execution_count": null,
1827 | "outputs": []
1828 | },
1829 | {
1830 | "cell_type": "code",
1831 | "metadata": {
1832 | "id": "b9SRNEShcF0A"
1833 | },
1834 | "source": [
1835 | "d2"
1836 | ],
1837 | "execution_count": null,
1838 | "outputs": []
1839 | },
1840 | {
1841 | "cell_type": "markdown",
1842 | "metadata": {
1843 | "id": "Ak4uMk3pzHZI"
1844 | },
1845 | "source": [
1846 | "### Küme (set)\n",
1847 | "\n",
1848 | "Liste, sözlük ve demet veri türü gibi birden çok veri türünü birlikte barındıran veri tipidir. Kümeler ile ilgili yaptığınız her türlü işlevi(birleşme,kesişim vs.) bu veri tipi ile yapabilirsiniz.\n",
1849 | "\n",
1850 | "\n",
1851 | "\n",
1852 | "\n",
1853 | "\n"
1854 | ]
1855 | },
1856 | {
1857 | "cell_type": "code",
1858 | "metadata": {
1859 | "id": "QgZuDyx3yvn9"
1860 | },
1861 | "source": [
1862 | "s = {\"python\", 5,6,8,5,6,\"abc\", \"python\",\"python\",\"python\",\"python\",\"python\",\"python\",\"python\",\"python\",\"python\"}\n",
1863 | "s"
1864 | ],
1865 | "execution_count": null,
1866 | "outputs": []
1867 | },
1868 | {
1869 | "cell_type": "code",
1870 | "metadata": {
1871 | "id": "KmzyF9b--0Ci"
1872 | },
1873 | "source": [
1874 | "empty = set()\n",
1875 | "type(empty)"
1876 | ],
1877 | "execution_count": null,
1878 | "outputs": []
1879 | },
1880 | {
1881 | "cell_type": "code",
1882 | "metadata": {
1883 | "id": "8qLJrT9VAUvf"
1884 | },
1885 | "source": [
1886 | "empty2 = {}\n",
1887 | "type(empty2)"
1888 | ],
1889 | "execution_count": null,
1890 | "outputs": []
1891 | },
1892 | {
1893 | "cell_type": "code",
1894 | "metadata": {
1895 | "id": "TLu1Ec_bA__q"
1896 | },
1897 | "source": [
1898 | "ne = set(\"pineapple\")\n",
1899 | "print(ne)"
1900 | ],
1901 | "execution_count": null,
1902 | "outputs": []
1903 | },
1904 | {
1905 | "cell_type": "code",
1906 | "metadata": {
1907 | "id": "GUtmrwfhB2mj"
1908 | },
1909 | "source": [
1910 | "6 in s"
1911 | ],
1912 | "execution_count": null,
1913 | "outputs": []
1914 | },
1915 | {
1916 | "cell_type": "code",
1917 | "metadata": {
1918 | "id": "lPvxuypLB4Pg"
1919 | },
1920 | "source": [
1921 | "len(s)"
1922 | ],
1923 | "execution_count": null,
1924 | "outputs": []
1925 | },
1926 | {
1927 | "cell_type": "code",
1928 | "metadata": {
1929 | "id": "wCijI6-vCEj6"
1930 | },
1931 | "source": [
1932 | "s.add(\"ai\")\n",
1933 | "s"
1934 | ],
1935 | "execution_count": null,
1936 | "outputs": []
1937 | },
1938 | {
1939 | "cell_type": "code",
1940 | "metadata": {
1941 | "id": "tPq001PuCLO3"
1942 | },
1943 | "source": [
1944 | "s.add(\"ai\")\n",
1945 | "print(s)\n",
1946 | "len(s)"
1947 | ],
1948 | "execution_count": null,
1949 | "outputs": []
1950 | },
1951 | {
1952 | "cell_type": "code",
1953 | "metadata": {
1954 | "id": "EGZnvf9WCRYk"
1955 | },
1956 | "source": [
1957 | "s2.remove(\"ai\")\n",
1958 | "print(s2)"
1959 | ],
1960 | "execution_count": null,
1961 | "outputs": []
1962 | },
1963 | {
1964 | "cell_type": "markdown",
1965 | "metadata": {
1966 | "id": "sp_E8xAhG21y"
1967 | },
1968 | "source": [
1969 | "# Demet (Tuple)\n",
1970 | "\n",
1971 | "Demetler birden fazla veri türünü bir arada bulundurabilen virgüllerle veya parantez ile gösterilen immutable(değiştirilemeyen) veri tipleridir.\n",
1972 | "\n"
1973 | ]
1974 | },
1975 | {
1976 | "cell_type": "code",
1977 | "metadata": {
1978 | "id": "8Rui2302H8jD"
1979 | },
1980 | "source": [
1981 | "tupl = (1,2,3,4,5)\n",
1982 | "print(tupl)\n",
1983 | "print(type(tupl))"
1984 | ],
1985 | "execution_count": null,
1986 | "outputs": []
1987 | },
1988 | {
1989 | "cell_type": "code",
1990 | "metadata": {
1991 | "id": "wZffTxPsIqqI"
1992 | },
1993 | "source": [
1994 | "tuple2 = () \n",
1995 | "type(tuple2)"
1996 | ],
1997 | "execution_count": null,
1998 | "outputs": []
1999 | },
2000 | {
2001 | "cell_type": "code",
2002 | "metadata": {
2003 | "id": "IrvB1HzGLYBZ"
2004 | },
2005 | "source": [
2006 | "print(tupl[3])"
2007 | ],
2008 | "execution_count": null,
2009 | "outputs": []
2010 | },
2011 | {
2012 | "cell_type": "code",
2013 | "metadata": {
2014 | "id": "y_9FkBJORo5y"
2015 | },
2016 | "source": [
2017 | "tupl[-2]"
2018 | ],
2019 | "execution_count": null,
2020 | "outputs": []
2021 | },
2022 | {
2023 | "cell_type": "code",
2024 | "metadata": {
2025 | "id": "ZPMFZi-qRs4a"
2026 | },
2027 | "source": [
2028 | "tupl[:4]"
2029 | ],
2030 | "execution_count": null,
2031 | "outputs": []
2032 | },
2033 | {
2034 | "cell_type": "code",
2035 | "metadata": {
2036 | "id": "TeT5RXH1R6Gv"
2037 | },
2038 | "source": [
2039 | "dm3 = (\"asli\", 5, 8, \"september\")\n",
2040 | "dm3.index(\"september\")"
2041 | ],
2042 | "execution_count": null,
2043 | "outputs": []
2044 | },
2045 | {
2046 | "cell_type": "code",
2047 | "metadata": {
2048 | "id": "wRks9wXwSRhJ"
2049 | },
2050 | "source": [
2051 | "dm3.count(5)\n"
2052 | ],
2053 | "execution_count": null,
2054 | "outputs": []
2055 | },
2056 | {
2057 | "cell_type": "code",
2058 | "metadata": {
2059 | "id": "Bo_JC5jkSWMf"
2060 | },
2061 | "source": [
2062 | "dm4 = (\"apple\",\"pear\",\"strawberry\")\n",
2063 | "\n",
2064 | "dm4[0] = \"cherry\"\n",
2065 | "\n",
2066 | "print(dm4)"
2067 | ],
2068 | "execution_count": null,
2069 | "outputs": []
2070 | },
2071 | {
2072 | "cell_type": "code",
2073 | "metadata": {
2074 | "id": "twLyvUivSoBr"
2075 | },
2076 | "source": [
2077 | "dm4.remove(\"pear\")"
2078 | ],
2079 | "execution_count": null,
2080 | "outputs": []
2081 | }
2082 | ]
2083 | }
2084 |
--------------------------------------------------------------------------------
/Python_Part2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "name": "PG1926_Day2.ipynb",
7 | "provenance": [],
8 | "authorship_tag": "ABX9TyObKbz4unSObtc3eLc1zdRi",
9 | "include_colab_link": true
10 | },
11 | "kernelspec": {
12 | "name": "python3",
13 | "display_name": "Python 3"
14 | }
15 | },
16 | "cells": [
17 | {
18 | "cell_type": "markdown",
19 | "metadata": {
20 | "id": "view-in-github",
21 | "colab_type": "text"
22 | },
23 | "source": [
24 | "
"
25 | ]
26 | },
27 | {
28 | "cell_type": "markdown",
29 | "metadata": {
30 | "id": "9Z4YvI9fBkjW"
31 | },
32 | "source": [
33 | "### While Döngüsü"
34 | ]
35 | },
36 | {
37 | "cell_type": "code",
38 | "metadata": {
39 | "id": "W9hjvMARBjtE"
40 | },
41 | "source": [
42 | "a = 1\r\n",
43 | "\r\n",
44 | "while a == 1: #while -> iken, olduğu sürece\r\n",
45 | " "
46 | ],
47 | "execution_count": null,
48 | "outputs": []
49 | },
50 | {
51 | "cell_type": "code",
52 | "metadata": {
53 | "id": "9ursY-6qB3R0"
54 | },
55 | "source": [
56 | "a = 1\r\n",
57 | "\r\n",
58 | "while a < 6: #a’nın değeri 6’dan küçük olduğu müddetçe…\r\n",
59 | " a += 1\r\n",
60 | " print(\"5 kez yazdır\") "
61 | ],
62 | "execution_count": null,
63 | "outputs": []
64 | },
65 | {
66 | "cell_type": "code",
67 | "metadata": {
68 | "id": "UOYC-Ea6CXRQ"
69 | },
70 | "source": [
71 | "while True: #Aksi belirtilmediği sürece çalışmaya devam et!\r\n",
72 | " soru = input(\"Yapmak istediğiniz işlemin numarasını girin (Çıkmak için q): \")\r\n",
73 | "\r\n",
74 | " if soru == \"q\":\r\n",
75 | " print(\"çıkılıyor...\")\r\n",
76 | " break"
77 | ],
78 | "execution_count": null,
79 | "outputs": []
80 | },
81 | {
82 | "cell_type": "code",
83 | "metadata": {
84 | "id": "AgSlaT_zD6AX"
85 | },
86 | "source": [
87 | "#Aksi belirtilmediği sürece kullanıcıya\r\n",
88 | "#aşağıdaki soruyu sormaya devam et!\r\n",
89 | "while True:\r\n",
90 | " soru = input(\"Nasılsınız, iyi misiniz?\")\r\n",
91 | "\r\n",
92 | " #Eğer kullanıcı 'q' tuşuna basarsa...\r\n",
93 | " if soru == \"q\":\r\n",
94 | " break #döngüyü kır ve programdan çık."
95 | ],
96 | "execution_count": null,
97 | "outputs": []
98 | },
99 | {
100 | "cell_type": "code",
101 | "metadata": {
102 | "id": "-Lderx3XEDYg"
103 | },
104 | "source": [
105 | "a = 0\r\n",
106 | "\r\n",
107 | "while a < 100:\r\n",
108 | " a += 1\r\n",
109 | " if a % 2 == 0:\r\n",
110 | " print(a)\r\n"
111 | ],
112 | "execution_count": null,
113 | "outputs": []
114 | },
115 | {
116 | "cell_type": "markdown",
117 | "metadata": {
118 | "id": "AHjIgw_UEcpe"
119 | },
120 | "source": [
121 | "### For Döngüsü\r\n",
122 | "\r\n"
123 | ]
124 | },
125 | {
126 | "cell_type": "code",
127 | "metadata": {
128 | "id": "z_PfY4-eEevC"
129 | },
130 | "source": [
131 | "for değişken_adı in değişken:\r\n",
132 | " yapılacak_işlem"
133 | ],
134 | "execution_count": null,
135 | "outputs": []
136 | },
137 | {
138 | "cell_type": "code",
139 | "metadata": {
140 | "id": "6ulwH2lPEqKE"
141 | },
142 | "source": [
143 | "tr_harfler = \"şçöğüİı\"\r\n",
144 | "\r\n",
145 | "for harf in tr_harfler:\r\n",
146 | " print(harf)"
147 | ],
148 | "execution_count": null,
149 | "outputs": []
150 | },
151 | {
152 | "cell_type": "code",
153 | "metadata": {
154 | "id": "MyAfsmjzEwhB"
155 | },
156 | "source": [
157 | "sayılar = 123456789\r\n",
158 | "for sayı in sayılar: \r\n",
159 | " print(sayı)"
160 | ],
161 | "execution_count": null,
162 | "outputs": []
163 | },
164 | {
165 | "cell_type": "code",
166 | "metadata": {
167 | "id": "fst5IGaKE-wN"
168 | },
169 | "source": [
170 | "for gazi in \"PG1926\":\r\n",
171 | " print(gazi)"
172 | ],
173 | "execution_count": null,
174 | "outputs": []
175 | },
176 | {
177 | "cell_type": "code",
178 | "metadata": {
179 | "id": "oyCDi80dFMrs"
180 | },
181 | "source": [
182 | "tr_harfler = \"şçöğüİı\"\r\n",
183 | "\r\n",
184 | "parola = input(\"Parolanız: \")\r\n",
185 | "\r\n",
186 | "for karakter in parola:\r\n",
187 | " if karakter in tr_harfler:\r\n",
188 | " print(\"parolada Türkçe karakter kullanılamaz\")"
189 | ],
190 | "execution_count": null,
191 | "outputs": []
192 | },
193 | {
194 | "cell_type": "code",
195 | "metadata": {
196 | "id": "LjENM1PHFdk3"
197 | },
198 | "source": [
199 | "for i in range(0, 10): #range = aralık\r\n",
200 | " print(i) #range(ilk_sayı, son_sayı)"
201 | ],
202 | "execution_count": null,
203 | "outputs": []
204 | },
205 | {
206 | "cell_type": "code",
207 | "metadata": {
208 | "id": "RJn3v7kqF1sp"
209 | },
210 | "source": [
211 | "ilk_metin = \"asdasfddgdhfjfdgdşfkgjdfklgşjdfklgjdfkghdfjghjklsdhajlsdhjkjhkhjjhu9\"\r\n",
212 | "ikinci_metin = \"sdfsuıdoryeuıfsjkdfhdjklghjdfklruseldhfjlkdshfljskeeuf\"\r\n",
213 | "\r\n",
214 | "for s in ilk_metin:\r\n",
215 | " if not s in ikinci_metin:\r\n",
216 | " print(s)"
217 | ],
218 | "execution_count": null,
219 | "outputs": []
220 | },
221 | {
222 | "cell_type": "markdown",
223 | "metadata": {
224 | "id": "d7tuplGdGtp3"
225 | },
226 | "source": [
227 | "### Fonksiyonlar"
228 | ]
229 | },
230 | {
231 | "cell_type": "code",
232 | "metadata": {
233 | "id": "3oSzlmjYG2kV"
234 | },
235 | "source": [
236 | "def kayıt_oluştur(parametre1, parametre2, parametre3, parametre4): #Fonksiyon tanımı\r\n",
237 | " (...)\r\n",
238 | "\r\n",
239 | "kayıt_oluştur(parametre1, parametre2, parametre3, parametre4) #Fonksiyon çağrısı"
240 | ],
241 | "execution_count": null,
242 | "outputs": []
243 | },
244 | {
245 | "cell_type": "code",
246 | "metadata": {
247 | "id": "b-wfCRT4HDKD"
248 | },
249 | "source": [
250 | "def selamla():\r\n",
251 | " print(\"Selam PG1926!\")\r\n",
252 | "selamla()"
253 | ],
254 | "execution_count": null,
255 | "outputs": []
256 | },
257 | {
258 | "cell_type": "code",
259 | "metadata": {
260 | "id": "6yIguEhDH1XF"
261 | },
262 | "source": [
263 | "def selam(isim):\r\n",
264 | " print(\"Selam \" + isim)\r\n",
265 | " \r\n",
266 | " "
267 | ],
268 | "execution_count": null,
269 | "outputs": []
270 | },
271 | {
272 | "cell_type": "code",
273 | "metadata": {
274 | "id": "zUzEIFlcH8-7"
275 | },
276 | "source": [
277 | "selam('ahmet')"
278 | ],
279 | "execution_count": null,
280 | "outputs": []
281 | },
282 | {
283 | "cell_type": "code",
284 | "metadata": {
285 | "id": "aYQ40QkhIM81"
286 | },
287 | "source": [
288 | "def toplama(a,b):\r\n",
289 | " toplam = a + b\r\n",
290 | " print(toplam)\r\n"
291 | ],
292 | "execution_count": null,
293 | "outputs": []
294 | },
295 | {
296 | "cell_type": "code",
297 | "metadata": {
298 | "id": "3OsDQ4_yBd4L"
299 | },
300 | "source": [
301 | "toplama(4,5)"
302 | ],
303 | "execution_count": null,
304 | "outputs": []
305 | },
306 | {
307 | "cell_type": "code",
308 | "metadata": {
309 | "id": "l6VQPNS1Gu_I"
310 | },
311 | "source": [
312 | "def kayıt_oluştur(isim, soyisim, işsis, şehir):\r\n",
313 | " print(\"-\"*30)\r\n",
314 | "\r\n",
315 | " print(\"isim : \", isim)\r\n",
316 | " print(\"soyisim : \", soyisim)\r\n",
317 | " print(\"işletim sistemi: \", işsis)\r\n",
318 | " print(\"şehir : \", şehir)\r\n",
319 | "\r\n",
320 | " print(\"-\"*30)"
321 | ],
322 | "execution_count": null,
323 | "outputs": []
324 | },
325 | {
326 | "cell_type": "code",
327 | "metadata": {
328 | "id": "hQzFX6_OIkHJ"
329 | },
330 | "source": [
331 | "def ismin_ne():\r\n",
332 | " isim = input(\"ismin ne? \")\r\n",
333 | " print(isim) #return isim"
334 | ],
335 | "execution_count": null,
336 | "outputs": []
337 | },
338 | {
339 | "cell_type": "code",
340 | "metadata": {
341 | "id": "wq-9pVBnI37T"
342 | },
343 | "source": [
344 | "ismin_ne()"
345 | ],
346 | "execution_count": null,
347 | "outputs": []
348 | },
349 | {
350 | "cell_type": "markdown",
351 | "metadata": {
352 | "id": "NjEk5IAyJ5rc"
353 | },
354 | "source": [
355 | "### Modüller\r\n",
356 | "\r\n",
357 | "Modüller Python programcılarına büyük kolaylık sağlayan yapılardan biridir.Python modüller; içerisinde bir takım özellikleri,fonksiyonları barındıran yapılardır."
358 | ]
359 | },
360 | {
361 | "cell_type": "code",
362 | "metadata": {
363 | "id": "14xj7MMPJ6f7"
364 | },
365 | "source": [
366 | "import os"
367 | ],
368 | "execution_count": null,
369 | "outputs": []
370 | },
371 | {
372 | "cell_type": "code",
373 | "metadata": {
374 | "id": "95LANZWWMali"
375 | },
376 | "source": [
377 | "from os import name,getcwd\r\n",
378 | "print(name)\r\n",
379 | "print(getcwd())"
380 | ],
381 | "execution_count": null,
382 | "outputs": []
383 | },
384 | {
385 | "cell_type": "markdown",
386 | "metadata": {
387 | "id": "Mhw-s7NUdWZ1"
388 | },
389 | "source": [
390 | ""
391 | ]
392 | },
393 | {
394 | "cell_type": "code",
395 | "metadata": {
396 | "id": "odC9yV9VKDGa"
397 | },
398 | "source": [
399 | "dir(os) #dir -> directory"
400 | ],
401 | "execution_count": null,
402 | "outputs": []
403 | },
404 | {
405 | "cell_type": "code",
406 | "metadata": {
407 | "id": "CbVUen3VKDrR"
408 | },
409 | "source": [
410 | "if os.name != 'nt':\r\n",
411 | " print('Kusura bakmayın! Bu programı yalnızca',\r\n",
412 | " 'Windows\\'ta kullanabilirsiniz!')\r\n",
413 | "... else:\r\n",
414 | " print('Hoşgeldin Windows kullanıcısı!')"
415 | ],
416 | "execution_count": null,
417 | "outputs": []
418 | },
419 | {
420 | "cell_type": "code",
421 | "metadata": {
422 | "id": "aCPK6hp5K-KY"
423 | },
424 | "source": [
425 | "import subprocess as sb"
426 | ],
427 | "execution_count": null,
428 | "outputs": []
429 | },
430 | {
431 | "cell_type": "markdown",
432 | "metadata": {
433 | "id": "xCgDB0dadeYF"
434 | },
435 | "source": [
436 | "### Nesne Yönelik Programlama (OOP)"
437 | ]
438 | },
439 | {
440 | "cell_type": "markdown",
441 | "metadata": {
442 | "id": "QCzD4-KDdyOi"
443 | },
444 | "source": [
445 | "Nesne Yönelikli Programlamanın sağladığı kolaylıklar\r\n",
446 | "* Gerçek dünyadaki nesnelerin tasarımları sınıf içinde yapılır.\r\n",
447 | "* Sınıftan nesne üretilip değişiklik yapılmak istendiğinde tüm programda değişiklik yapmak gerekmez sadece oluşturulan nesnenın sınıf içinde değişiklik yapmak yeterlidir.\r\n",
448 | "* Oluşturulan nesneler birbirinden bağımsız olduğu için bilgi gizleme olanağı artar.\r\n",
449 | " Örneğin A nesnesi B nesnesinin özelliklerini kullanamaz ve erişemez.\r\n",
450 | "* Nesne oluşturma bir sınıf içerisinde gerçekleştirilir ve bu kodlar başka projelerde kullanılabilir.\r\n",
451 | " Örneğin bir A nesnesi oluşturduysak bunu birçok yerde kullanabiliriz.\r\n",
452 | "* Sınıflar oluşturarak daha az kod oluşturup daha fazla iş yapıp kod tekarı önlenir.\r\n",
453 | "* Örneğin insan sınıfında isim, soyisim, yaş… gibi özellikleri bir defa oluşturup istediğimiz kadar kullanabiliriz.\r\n",
454 | "* Kod tekrarı önlediği için geliştirme sürecinin verimliliğini artırır."
455 | ]
456 | },
457 | {
458 | "cell_type": "markdown",
459 | "metadata": {
460 | "id": "Ys6CXspMeBeq"
461 | },
462 | "source": [
463 | "### Sınıflar"
464 | ]
465 | },
466 | {
467 | "cell_type": "markdown",
468 | "metadata": {
469 | "id": "093fuuYKeI5h"
470 | },
471 | "source": [
472 | "Çok kaba ve oldukça soyut bir şekilde tanımlayacak olursak, sınıflar, nesne üretmemizi sağlayan veri tipleridir. İşte nesne tabanlı programlama, adından da anlaşılacağı gibi, nesneler (ve dolayısıyla sınıflar) temel alınarak gerçekleştirilen bir programlama faaliyetidir."
473 | ]
474 | },
475 | {
476 | "cell_type": "code",
477 | "metadata": {
478 | "id": "9ehrz366eGEW"
479 | },
480 | "source": [
481 | "class YeniSınıf(): #Sınıf tanımlama\r\n",
482 | " pass"
483 | ],
484 | "execution_count": null,
485 | "outputs": []
486 | },
487 | {
488 | "cell_type": "code",
489 | "metadata": {
490 | "id": "JnJJFUgYeKUH"
491 | },
492 | "source": [
493 | "def çalışan():\r\n",
494 | " kabiliyetleri = []\r\n",
495 | " unvanı = 'işçi'\r\n",
496 | "\r\n",
497 | " print(kabiliyetleri)\r\n",
498 | " print(unvanı)"
499 | ],
500 | "execution_count": null,
501 | "outputs": []
502 | },
503 | {
504 | "cell_type": "code",
505 | "metadata": {
506 | "id": "FkCe8sQEfNP0"
507 | },
508 | "source": [
509 | "class Çalışan():\r\n",
510 | " kabiliyetleri = []\r\n",
511 | " unvanı = 'işçi'\r\n",
512 | "\r\n",
513 | " print(kabiliyetleri)\r\n",
514 | " print(unvanı)"
515 | ],
516 | "execution_count": null,
517 | "outputs": []
518 | },
519 | {
520 | "cell_type": "code",
521 | "metadata": {
522 | "id": "RVbB8Z-2fb0p"
523 | },
524 | "source": [
525 | "class Çalışan():\r\n",
526 | " kabiliyetleri = []\r\n",
527 | " unvanı = 'işçi'\r\n",
528 | "\r\n",
529 | "print(Çalışan.kabiliyetleri)\r\n",
530 | "print(Çalışan.unvanı)"
531 | ],
532 | "execution_count": null,
533 | "outputs": []
534 | },
535 | {
536 | "cell_type": "code",
537 | "metadata": {
538 | "id": "-p3mXqYcfk6o"
539 | },
540 | "source": [
541 | "class Çalışan():\r\n",
542 | " kabiliyetleri = []\r\n",
543 | " unvanı = 'işçi'\r\n",
544 | " maaşı = 2500\r\n",
545 | " memleketi = ''\r\n",
546 | " doğum_tarihi = ''"
547 | ],
548 | "execution_count": null,
549 | "outputs": []
550 | },
551 | {
552 | "cell_type": "code",
553 | "metadata": {
554 | "id": "DWUBqI7AfoEh"
555 | },
556 | "source": [
557 | "print(Çalışan.maaşı)\r\n",
558 | "print(Çalışan.memleketi)\r\n",
559 | "print(Çalışan.doğum_tarihi)"
560 | ],
561 | "execution_count": null,
562 | "outputs": []
563 | },
564 | {
565 | "cell_type": "code",
566 | "metadata": {
567 | "id": "gimB_aKbfugP"
568 | },
569 | "source": [
570 | "Çalışan.isim = 'Ahmet','Mehmet'\r\n",
571 | "Çalışan.yaş = 40"
572 | ],
573 | "execution_count": null,
574 | "outputs": []
575 | },
576 | {
577 | "cell_type": "code",
578 | "metadata": {
579 | "id": "sghLsx2pfw8v"
580 | },
581 | "source": [
582 | "print(Çalışan.isim)"
583 | ],
584 | "execution_count": null,
585 | "outputs": []
586 | },
587 | {
588 | "cell_type": "code",
589 | "metadata": {
590 | "id": "uqxADVhVgDcu"
591 | },
592 | "source": [
593 | "class Asker():\r\n",
594 | " rütbesi = 'Er'\r\n",
595 | " standart_teçhizat = ['G3', 'kasatura', 'süngü', 'el bombası']\r\n",
596 | " gücü = 60\r\n",
597 | " birliği = ''"
598 | ],
599 | "execution_count": null,
600 | "outputs": []
601 | },
602 | {
603 | "cell_type": "code",
604 | "metadata": {
605 | "id": "L2cd-oNtgEJQ"
606 | },
607 | "source": [
608 | "Asker.gücü"
609 | ],
610 | "execution_count": null,
611 | "outputs": []
612 | },
613 | {
614 | "cell_type": "code",
615 | "metadata": {
616 | "id": "yJdHiLD-gSdu"
617 | },
618 | "source": [
619 | "ahmet = Asker() #Örnekleme (instance)"
620 | ],
621 | "execution_count": null,
622 | "outputs": []
623 | },
624 | {
625 | "cell_type": "code",
626 | "metadata": {
627 | "id": "9a7zjj5VgUAQ"
628 | },
629 | "source": [
630 | "ahmet.gücü = 70"
631 | ],
632 | "execution_count": null,
633 | "outputs": []
634 | },
635 | {
636 | "cell_type": "code",
637 | "metadata": {
638 | "id": "ZZxGaH71ghAM"
639 | },
640 | "source": [
641 | "print(ahmet.gücü)"
642 | ],
643 | "execution_count": null,
644 | "outputs": []
645 | },
646 | {
647 | "cell_type": "code",
648 | "metadata": {
649 | "id": "wonYDOtyg-Iy"
650 | },
651 | "source": [
652 | "ahmet.standart_teçhizat.append(\"Bıçak\")"
653 | ],
654 | "execution_count": null,
655 | "outputs": []
656 | },
657 | {
658 | "cell_type": "code",
659 | "metadata": {
660 | "id": "PsHt2yD0hB5L"
661 | },
662 | "source": [
663 | "print(ahmet.standart_teçhizat)"
664 | ],
665 | "execution_count": null,
666 | "outputs": []
667 | },
668 | {
669 | "cell_type": "code",
670 | "metadata": {
671 | "id": "OT4fsv9mhD4f"
672 | },
673 | "source": [
674 | "mehmet = Asker()"
675 | ],
676 | "execution_count": null,
677 | "outputs": []
678 | },
679 | {
680 | "cell_type": "code",
681 | "metadata": {
682 | "id": "8c-pqMuIhM40"
683 | },
684 | "source": [
685 | "print(mehmet.gücü)"
686 | ],
687 | "execution_count": null,
688 | "outputs": []
689 | },
690 | {
691 | "cell_type": "markdown",
692 | "metadata": {
693 | "id": "CSxi4yc2kDWq"
694 | },
695 | "source": [
696 | "### __init__ Fonksiyonu ve self"
697 | ]
698 | },
699 | {
700 | "cell_type": "markdown",
701 | "metadata": {
702 | "id": "c2fvw4q-l14h"
703 | },
704 | "source": [
705 | "İnit nedir?\r\n",
706 | "\r\n",
707 | "__init__ metodu initialize – ilklendirmek, initializer – başlatıcı kavramlarından gelmektedir. __init__ , OOP ile programlamada bir class’ın yapıcı (constructor) metodur. Eğer bir class’tan nesne türetecek isek __init__ ,class’ın ilk metodu olmak zorundadır. Class içinden türetilen nesnelere ait özellikler bu metot ile nesnelere atanır.\r\n",
708 | "Aşağıdaki örnekte Arabalar() adında bir class oluşturduk. Genel olarak her arabada bulunan fakat arabadan arabaya değişiklik gösteren marka, model, renk ve vites gibi ayırt edeci özellikleri class’ımıza atadık."
709 | ]
710 | },
711 | {
712 | "cell_type": "markdown",
713 | "metadata": {
714 | "id": "AAWcKMermElW"
715 | },
716 | "source": [
717 | "Self nedir?\r\n",
718 | "\r\n",
719 | "__init__ metodunun yapısına baktığımızda parantez içinde self kavramı dikkatimizi çekmektedir. self anahtar sözcüğü (keyword) __init__ metodu ile gelen ve class içinden türetmiş olduğumuz nesnelere ulaşmamızı sağlayan bir kavramdır. __init__ metodunu class’tan hemen sonra kullandığımızda gelen self keyword yerine biz kendi keyword’ümüzü de yazabiliriz ve daha sonra, çağırmak istediğimiz her özellik için oluşturduğumuz keyword’ü kullanabiliriz. Tavsiye olarak self sözcüğünü karışıklık olmaması adına değiştirmemenizi tavsiye ederim."
720 | ]
721 | },
722 | {
723 | "cell_type": "code",
724 | "metadata": {
725 | "id": "78f9mFIMmN-Y"
726 | },
727 | "source": [
728 | "class Arabalar():\r\n",
729 | " def __init__(self,marka,model,renk,vites):\r\n",
730 | " self.marka = marka\r\n",
731 | " self.model = model\r\n",
732 | " self.renk = renk\r\n",
733 | " self.vites = vites"
734 | ],
735 | "execution_count": null,
736 | "outputs": []
737 | },
738 | {
739 | "cell_type": "code",
740 | "metadata": {
741 | "id": "7jvOocaumb_W"
742 | },
743 | "source": [
744 | "araba_1 = Arabalar(\"Ford\", \"Mustang\", \"Siyah\", \"Manuel\") #nesne yaratmak.\r\n",
745 | "\r\n",
746 | "araba_2 = Arabalar(\"BMW\", \"X6\", \"Beyaz\", \"Otomatik\")\r\n",
747 | "\r\n",
748 | "araba_3 = Arabalar()\r\n",
749 | "\r\n"
750 | ],
751 | "execution_count": null,
752 | "outputs": []
753 | },
754 | {
755 | "cell_type": "code",
756 | "metadata": {
757 | "id": "XOkx4v-Nm_rA"
758 | },
759 | "source": [
760 | "print(araba_1.marka)\r\n",
761 | "print(araba_2.marka)"
762 | ],
763 | "execution_count": null,
764 | "outputs": []
765 | },
766 | {
767 | "cell_type": "code",
768 | "metadata": {
769 | "id": "wSurmHhnlW2e"
770 | },
771 | "source": [
772 | "class Çalışan():\r\n",
773 | " personel = []\r\n",
774 | "\r\n",
775 | " def __init__(self, isim):\r\n",
776 | " self.isim = isim\r\n",
777 | " self.kabiliyetleri = []\r\n",
778 | " self.personele_ekle()\r\n",
779 | "\r\n",
780 | " def personele_ekle(self):\r\n",
781 | " self.personel.append(self.isim)\r\n",
782 | " print('{} adlı kişi personele eklendi'.format(self.isim))\r\n",
783 | "\r\n",
784 | " def personeli_görüntüle(self):\r\n",
785 | " print('Personel listesi:')\r\n",
786 | " for kişi in self.personel:\r\n",
787 | " print(kişi)\r\n",
788 | "\r\n",
789 | " def kabiliyet_ekle(self, kabiliyet):\r\n",
790 | " self.kabiliyetleri.append(kabiliyet)\r\n",
791 | "\r\n",
792 | " def kabiliyetleri_görüntüle(self):\r\n",
793 | " print('{} adlı kişinin kabiliyetleri:'.format(self.isim))\r\n",
794 | " for kabiliyet in self.kabiliyetleri:\r\n",
795 | " print(kabiliyet)"
796 | ],
797 | "execution_count": null,
798 | "outputs": []
799 | },
800 | {
801 | "cell_type": "code",
802 | "metadata": {
803 | "id": "SsjueV3XlXnv"
804 | },
805 | "source": [
806 | "\r\n",
807 | "ç1 = çalışan.Çalışan('Ahmet')"
808 | ],
809 | "execution_count": null,
810 | "outputs": []
811 | },
812 | {
813 | "cell_type": "code",
814 | "metadata": {
815 | "id": "GpMGWD8PllD2"
816 | },
817 | "source": [
818 | ""
819 | ],
820 | "execution_count": null,
821 | "outputs": []
822 | },
823 | {
824 | "cell_type": "markdown",
825 | "metadata": {
826 | "id": "iimYMpWsoBrE"
827 | },
828 | "source": [
829 | "### Miras alma & verme"
830 | ]
831 | },
832 | {
833 | "cell_type": "code",
834 | "metadata": {
835 | "id": "MYS_Mj3coEIc"
836 | },
837 | "source": [
838 | "class Akademisyen:\r\n",
839 | " def __init__(self,adi,soyadi,numarasi):\r\n",
840 | " self.adi = adi\r\n",
841 | " self.soyadi = soyadi\r\n",
842 | " self.numarasi = numarasi\r\n",
843 | " \r\n",
844 | " \r\n",
845 | " def giris(self):\r\n",
846 | " print(\"Giriş Yapıldı\")\r\n",
847 | " \r\n",
848 | " def cikis(self):\r\n",
849 | " print(\"Çıkış yapıldı\")\r\n",
850 | " \r\n",
851 | " \r\n",
852 | "class Personel:\r\n",
853 | " def __init__(self, adi, soyadi, numarasi):\r\n",
854 | " self.adi = adi\r\n",
855 | " self.soyadi = soyadi\r\n",
856 | " self.numarasi = numarasi\r\n",
857 | " \r\n",
858 | " def giris(self):\r\n",
859 | " print(\"Giriş Yapıldı\")\r\n",
860 | " \r\n",
861 | " def cikis(self):\r\n",
862 | " print(\"Çıkış yapıldı\")\r\n",
863 | " \r\n",
864 | " \r\n",
865 | "class Ogrenci:\r\n",
866 | " def __init__(self, adi, soyadi, numarasi):\r\n",
867 | " self.adi = adi\r\n",
868 | " self.soyadi = soyadi\r\n",
869 | " self.numarasi = numarasi\r\n",
870 | " \r\n",
871 | " def giris(self):\r\n",
872 | " print(\"Giriş Yapıldı\")\r\n",
873 | " \r\n",
874 | " def cikis(self):\r\n",
875 | " print(\"Çıkış yapıldı\")"
876 | ],
877 | "execution_count": null,
878 | "outputs": []
879 | },
880 | {
881 | "cell_type": "code",
882 | "metadata": {
883 | "id": "53fFHB0xoFyf"
884 | },
885 | "source": [
886 | "class Kullanici:\r\n",
887 | " def __init__(self,adi,soyadi,numara):\r\n",
888 | " print(\"Kullanıcı sınıfı fonksiyonu\")\r\n",
889 | " self.adi = adi\r\n",
890 | " self.soyadi = soyadi\r\n",
891 | " self.numara = numara\r\n",
892 | " \r\n",
893 | " \r\n",
894 | " def giris(self):\r\n",
895 | " print(\"Giriş Yapıldı\")\r\n",
896 | " \r\n",
897 | " def cikis(self):\r\n",
898 | " print(\"Çıkış yapıldı\")\r\n",
899 | " \r\n",
900 | " \r\n",
901 | " \r\n",
902 | "class Akademisyen(Kullanici):\r\n",
903 | " pass\r\n",
904 | "class Personel(Kullanici):\r\n",
905 | " pass\r\n",
906 | "class Ogrenci(Kullanici):\r\n",
907 | " pass"
908 | ],
909 | "execution_count": null,
910 | "outputs": []
911 | },
912 | {
913 | "cell_type": "code",
914 | "metadata": {
915 | "id": "JS6xbgznoJ0g"
916 | },
917 | "source": [
918 | "ogr_ahmet = Kullanici(\"Ahmet\", \"Deniz\", \"123123\")"
919 | ],
920 | "execution_count": null,
921 | "outputs": []
922 | },
923 | {
924 | "cell_type": "code",
925 | "metadata": {
926 | "id": "vsof-64iocq2"
927 | },
928 | "source": [
929 | "prof_mehmet = Akademisyen(\"Mehmet\", \"Beyaz\", \"123123\")"
930 | ],
931 | "execution_count": null,
932 | "outputs": []
933 | },
934 | {
935 | "cell_type": "code",
936 | "metadata": {
937 | "id": "mFnsL2fyopCz"
938 | },
939 | "source": [
940 | "prof_mehmet.numara"
941 | ],
942 | "execution_count": null,
943 | "outputs": []
944 | },
945 | {
946 | "cell_type": "code",
947 | "metadata": {
948 | "id": "gSqMGm1VosmO"
949 | },
950 | "source": [
951 | ""
952 | ],
953 | "execution_count": null,
954 | "outputs": []
955 | }
956 | ]
957 | }
958 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Python for Beginners
2 | --
3 |
4 | Turkish version is below. ⬇️
5 |
6 | ---
7 |
8 | It is the source code of the content used in Youtube broadcasts on "Introduction to Python" given by me. The purpose of the tutorial is to assist people who are **new** learning the Python language. Therefore, the content of the program starts from the basic level.
9 |
10 | You don't need any compiler to run the .ipynb extension files in the repository, you can run it through the browser with the help of [Google Colab](https://colab.research.google.com/).
11 |
12 | Program content:
13 | 1. Chapter
14 | - Hello World
15 | - Comment Line
16 | - Variable Definition
17 | - Data Types
18 | - Arithmetic Operators
19 | - Type Conversions
20 | - Indexing and Slicing
21 | - If/Else Conditions
22 | - List, Dictionary, Set, Tuple
23 |
24 | 
25 |
26 | 2. Chapter
27 | - While Loop
28 | - For Loop
29 | - Functions
30 | - Modules
31 | - Object Oriented Programming (OOP)
32 | - Classes
33 | - init function, self
34 | - Inheritance
35 |
36 | 
37 |
38 | Live broadcasts where I teach Python:
39 |
40 | - [PG 1926 | Gazi University](https://www.youtube.com/watch?v=wdfGo-k6PxA)
41 | - [Python for Everybody | Yeditepe University](https://www.youtube.com/watch?v=C-IGJnBZvOc)
42 | - [Introduction to Python | Istinye University](https://www.youtube.com/watch?v=uO0OToMQ9tc)
43 | - [AI Logs Python Camp | GDG Cloud Bursa](https://www.youtube.com/watch?v=BYgQFGWQMPM)
44 |
45 |
46 | -----
47 |
48 | Tarafımca verilmiş "Python'a Giriş" konulu Youtube yayınlarında kullanılan içeriklerin kaynak kodudur. Eğitimin amacı, Python dilini **yeni** öğrenmeye başlamış kişilere yardımcı olmaktır. Bu yüzden program içeriği temel düzeyden başlamaktadır.
49 |
50 | Repository'de bulunan .ipynb uzantılı dosyaları çalıştırmak için herhangi bir derleyiciye ihtiyacınız yok, [Google Colab](https://colab.research.google.com/) yardımı ile tarayıcı üzerinden çalıştırabilirsiniz.
51 |
52 | Program içeriği:
53 | 1. Bölüm
54 | - Hello World
55 | - Yorum Satırı
56 | - Değişken Tanımlama
57 | - Veri Tipleri
58 | - Aritmetik Operatörler
59 | - Tür Dönüşümleri
60 | - Konumlama ve Dilimleme
61 | - If/Else Durumları
62 | - Liste, Sözlük, Küme, Demet
63 |
64 | 
65 |
66 | 2. Bölüm
67 | - While Döngüsü
68 | - For Döngüsü
69 | - Fonksiyonlar
70 | - Modüller
71 | - Nesne Yönelik Programlama (OOP)
72 | - Sınıflar
73 | - init fonksiyonu, self
74 | - Miras alma & verme
75 |
76 | 
77 |
78 | Python eğitimi verdiğim canlı yayınlar:
79 |
80 | - [PG 1926 | Gazi Üniversitesi](https://www.youtube.com/watch?v=wdfGo-k6PxA)
81 | - [Python for Everybody | Yeditepe Üniversitesi](https://www.youtube.com/watch?v=C-IGJnBZvOc)
82 | - [Introduction to Python | İstinye Üniversitesi](https://www.youtube.com/watch?v=uO0OToMQ9tc)
83 | - [AI Logs Python Kampı | GDG Cloud Bursa](https://www.youtube.com/watch?v=BYgQFGWQMPM)
84 |
--------------------------------------------------------------------------------