├── 01-07-2020(Day-9).ipynb
├── 01-07-2020(Day-9)
├── Modules_Packages.ipynb
├── module.py
└── package
│ └── mobile.py
├── 02-07-2020
└── 02-07-2020.ipynb
├── 03-07-2020(Day-11).ipynb
├── 04-07-2020(Day-12)
├── File_handling.ipynb
├── book.txt
├── img.jpg
├── mail.txt
└── phone.txt
├── 06-07-2020(Day-13).ipynb
├── 06-07-2020
└── 06-07-2020.ipynb
├── 07-07-2020(Day-15)
├── Pandas_7July2020.ipynb
├── birds.csv
└── data_Concat.csv
├── 08-07-2020(Day-16)
├── Matplotlib.ipynb
└── logo.png
├── 09-07-2020(Day-17)
├── Oops_basics.ipynb
└── download.png
├── 10-07-2020(Day-18)
├── OOPS_Inheritance.ipynb
├── inheritence.jpg
├── multi.png
├── multilevel.jpg
└── single.png
├── 10-7-2020(matplotlib)aftrnun.ipynb
├── 1st July 2020.ipynb
├── 22-06-2020(Day-1).ipynb
├── 22-06-2020
└── 22-06-2020(Day-1).ipynb
├── 23-06-2020(Day-2).ipynb
├── 24-06-2020(Day-3).ipynb
├── 24-06-2020.ipynb
├── 24th june.ipynb
├── 25-06-2020(Day-4).ipynb
├── 26-06-2020(Day-5).ipynb
├── 27-06-2020(DAY-6).ipynb
├── 29-06-2020
└── 29-06-2020.ipynb
├── 2nd July 2020.ipynb
├── 30-06-2020(Day-8).ipynb
├── 6th July 2020.ipynb
├── 9th July 2020.ipynb
├── Datafiles
├── data.txt
├── data1.txt
├── demo.txt
├── demo1.txt
├── info.txt
├── marks.txt
└── task.txt
├── July 10th 2020(Pandas cont..).ipynb
├── June 4,2020(afternun).ipynb
├── Python-Programming-Content.md
├── Resources.md
├── data.csv
├── june27,2020 (DAY-6)aftrnun.ipynb
├── june3,2020(aftrnun) .ipynb
└── package
└── mobile.py
/01-07-2020(Day-9)/module.py:
--------------------------------------------------------------------------------
1 | def isleap(year):
2 | if year%400 == 0 or (year%4 == 0 and year%100 != 0):
3 | return True
4 | return False
5 |
6 |
7 | def hello(name):
8 | return "Hello "+name+" How do you do.. !"
--------------------------------------------------------------------------------
/01-07-2020(Day-9)/package/mobile.py:
--------------------------------------------------------------------------------
1 | def vivo():
2 | print("Features :")
3 | print("Battery : 5000mhg \n RAM : 6GB \n cost : 12000rs ")
4 |
5 | def realme():
6 | print("Features :")
7 | print("Battery : 5500mhg \n RAM : 32GB \n cost : 10000rs ")
--------------------------------------------------------------------------------
/02-07-2020/02-07-2020.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Comprehensions:\n"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "* Comprehension is nothing but Inclusive(within itself).\n",
15 | "* In python we use these comprehensions for simplying for code and reducing the programming lines.
\n",
16 | "\n",
17 | "#### Types of comprehensions:\n",
18 | "\n",
19 | "* List Comprehension\n",
20 | "* Dictionary Comprehension\n",
21 | "* Set Comprehension\n",
22 | "* Generator Comprehension.\n"
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {},
28 | "source": [
29 | "#### List Comprehension:\n",
30 | "\n",
31 | "If we write our code within a list to create the output in the format of list,then that is named as List comprehension.\n"
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": 1,
37 | "metadata": {},
38 | "outputs": [
39 | {
40 | "name": "stdout",
41 | "output_type": "stream",
42 | "text": [
43 | "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"
44 | ]
45 | }
46 | ],
47 | "source": [
48 | "### Display the numbers from 1 to 10 in list format.\n",
49 | "\n",
50 | "l = []\n",
51 | "for i in range(1,11):\n",
52 | " l.append(i)\n",
53 | "print(l)"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": 2,
59 | "metadata": {},
60 | "outputs": [
61 | {
62 | "name": "stdout",
63 | "output_type": "stream",
64 | "text": [
65 | "List comprehension [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"
66 | ]
67 | }
68 | ],
69 | "source": [
70 | "### List comprehension:\n",
71 | "## first at the starting of list output variable should be defined.\n",
72 | "### Loop should be defined after the output variable\n",
73 | "### conditions sholud be defined after loop.\n",
74 | "\n",
75 | "l = [i for i in range(1,11)]\n",
76 | "print(\"List comprehension\",l)"
77 | ]
78 | },
79 | {
80 | "cell_type": "code",
81 | "execution_count": 3,
82 | "metadata": {},
83 | "outputs": [
84 | {
85 | "name": "stdout",
86 | "output_type": "stream",
87 | "text": [
88 | "[12, 14, 10, 6]\n"
89 | ]
90 | }
91 | ],
92 | "source": [
93 | "### Print even numbers from a given list in list format:\n",
94 | "\n",
95 | "li = [12,14,3,1,7,10,6]\n",
96 | "l = []\n",
97 | "for i in li:\n",
98 | " if i%2 == 0:\n",
99 | " l.append(i)\n",
100 | "print(l)"
101 | ]
102 | },
103 | {
104 | "cell_type": "code",
105 | "execution_count": 4,
106 | "metadata": {},
107 | "outputs": [
108 | {
109 | "name": "stdout",
110 | "output_type": "stream",
111 | "text": [
112 | "[12, 14, 10, 6]\n"
113 | ]
114 | }
115 | ],
116 | "source": [
117 | "### list comprehension:\n",
118 | "\n",
119 | "l = [i for i in li if i%2 == 0]\n",
120 | "print(l)"
121 | ]
122 | },
123 | {
124 | "cell_type": "code",
125 | "execution_count": 7,
126 | "metadata": {},
127 | "outputs": [
128 | {
129 | "name": "stdout",
130 | "output_type": "stream",
131 | "text": [
132 | "[12, 14, 'Odd', 'Odd', 'Odd', 10, 6]\n"
133 | ]
134 | }
135 | ],
136 | "source": [
137 | "#### Print the even numbers in a list and in place of odd numbers replace it with \"odd\"\n",
138 | "\n",
139 | "li = [12,14,3,1,7,10,6]\n",
140 | "l = []\n",
141 | "for i in li:\n",
142 | " if i%2 == 0:\n",
143 | " l.append(i)\n",
144 | " else:\n",
145 | " l.append(\"Odd\")\n",
146 | "print(l)"
147 | ]
148 | },
149 | {
150 | "cell_type": "code",
151 | "execution_count": 8,
152 | "metadata": {},
153 | "outputs": [
154 | {
155 | "name": "stdout",
156 | "output_type": "stream",
157 | "text": [
158 | "[12, 14, 'Odd', 'Odd', 'Odd', 10, 6]\n"
159 | ]
160 | }
161 | ],
162 | "source": [
163 | "###List comprehension:\n",
164 | "### If we use if and else condition at a time ,then condition should be defined \n",
165 | "## first later loop should be defined.\n",
166 | "\n",
167 | "l =[i if i % 2 == 0 else \"Odd\" for i in li]\n",
168 | "print(l)"
169 | ]
170 | },
171 | {
172 | "cell_type": "code",
173 | "execution_count": 11,
174 | "metadata": {},
175 | "outputs": [
176 | {
177 | "name": "stdout",
178 | "output_type": "stream",
179 | "text": [
180 | "['python', 'programming', 'summer', 'online', 'training']\n"
181 | ]
182 | }
183 | ],
184 | "source": [
185 | "### task\n",
186 | "### a = [\"python programming\",\"summer online training\"]\n",
187 | "### separate each word with comma and print the output in list format.\n",
188 | "\n",
189 | "a = [\"python programming\",\"summer online training\"]\n",
190 | "li = []\n",
191 | "for i in a :\n",
192 | " for j in i.split():\n",
193 | " li.append(j)\n",
194 | "print(li)\n",
195 | " \n",
196 | " "
197 | ]
198 | },
199 | {
200 | "cell_type": "code",
201 | "execution_count": 12,
202 | "metadata": {},
203 | "outputs": [
204 | {
205 | "name": "stdout",
206 | "output_type": "stream",
207 | "text": [
208 | "['python', 'programming', 'summer', 'online', 'training']\n"
209 | ]
210 | }
211 | ],
212 | "source": [
213 | "### list comprehension:\n",
214 | "\n",
215 | "a = [\"python programming\",\"summer online training\"]\n",
216 | "\n",
217 | "list_sep = [j for i in a for j in i.split()]\n",
218 | "print(list_sep)"
219 | ]
220 | },
221 | {
222 | "cell_type": "markdown",
223 | "metadata": {},
224 | "source": [
225 | "### Dictionary Comprehension:\n",
226 | "\n",
227 | "If we use our code in a Dictionary and the output is printed in the format of dictonary then that will be Dictionary comprehension.\n"
228 | ]
229 | },
230 | {
231 | "cell_type": "code",
232 | "execution_count": 13,
233 | "metadata": {},
234 | "outputs": [
235 | {
236 | "name": "stdout",
237 | "output_type": "stream",
238 | "text": [
239 | "{'Andhra': 'Amaravathi', 'Telangana': 'Hyderabad', 'TamilNadu': 'Chennai'}\n"
240 | ]
241 | }
242 | ],
243 | "source": [
244 | "state = [\"Andhra\",\"Telangana\",\"TamilNadu\"]\n",
245 | "capital = [\"Amaravathi\",\"Hyderabad\",\"Chennai\"]\n",
246 | "\n",
247 | "c = {}\n",
248 | "for (key,value) in zip(state,capital):\n",
249 | " c[key] = value\n",
250 | "print(c)"
251 | ]
252 | },
253 | {
254 | "cell_type": "code",
255 | "execution_count": 14,
256 | "metadata": {},
257 | "outputs": [
258 | {
259 | "name": "stdout",
260 | "output_type": "stream",
261 | "text": [
262 | "{'Andhra': 'Amaravathi', 'Telangana': 'Hyderabad', 'TamilNadu': 'Chennai'}\n"
263 | ]
264 | }
265 | ],
266 | "source": [
267 | "### Dictionary Comprehension:\n",
268 | "\n",
269 | "output = {key:value for (key,value) in zip(state,capital)}\n",
270 | "print(output)"
271 | ]
272 | },
273 | {
274 | "cell_type": "code",
275 | "execution_count": 17,
276 | "metadata": {},
277 | "outputs": [
278 | {
279 | "name": "stdout",
280 | "output_type": "stream",
281 | "text": [
282 | "{1: 1, 2: 4, 6: 36, 9: 81, 10: 100}\n"
283 | ]
284 | }
285 | ],
286 | "source": [
287 | "#### li = [1,2,6,9,10]\n",
288 | "### d = {1:1,2:4,6:36,9:81,10:100}\n",
289 | "li = [1,2,6,9,10]\n",
290 | "d ={i:i**2 for i in li}\n",
291 | "print(d)"
292 | ]
293 | },
294 | {
295 | "cell_type": "markdown",
296 | "metadata": {},
297 | "source": [
298 | "### Set Comprehension:\n",
299 | "\n",
300 | "* Set comprehension is also as same as list comprehension but the main difference is set accepts unique elements.\n"
301 | ]
302 | },
303 | {
304 | "cell_type": "code",
305 | "execution_count": 18,
306 | "metadata": {},
307 | "outputs": [
308 | {
309 | "name": "stdout",
310 | "output_type": "stream",
311 | "text": [
312 | "{89, 1, 3, 5}\n"
313 | ]
314 | }
315 | ],
316 | "source": [
317 | "li =[1,2,3,3,6,89,5,5]\n",
318 | "s = set()\n",
319 | "for i in li:\n",
320 | " if i % 2 !=0:\n",
321 | " s.add(i)\n",
322 | "print(s)"
323 | ]
324 | },
325 | {
326 | "cell_type": "code",
327 | "execution_count": 19,
328 | "metadata": {},
329 | "outputs": [
330 | {
331 | "name": "stdout",
332 | "output_type": "stream",
333 | "text": [
334 | "{89, 1, 3, 5}\n"
335 | ]
336 | }
337 | ],
338 | "source": [
339 | "### Set comprehension:\n",
340 | "\n",
341 | "s = {i for i in li if i%2!=0}\n",
342 | "print(s)"
343 | ]
344 | },
345 | {
346 | "cell_type": "markdown",
347 | "metadata": {},
348 | "source": [
349 | "### Generator Comprehension:\n"
350 | ]
351 | },
352 | {
353 | "cell_type": "markdown",
354 | "metadata": {},
355 | "source": [
356 | "### Iterators and Generators:\n",
357 | "\n",
358 | "\n",
359 | "#### Iterator:\n",
360 | "\n"
361 | ]
362 | },
363 | {
364 | "cell_type": "markdown",
365 | "metadata": {},
366 | "source": [
367 | "* Iterator is as same as For loop but the difference the output can be accessed as per requirement.\n",
368 | "* In iterator we have 2 main keywords.\n",
369 | " * iter: to make the value into iteartor\n",
370 | " * Next: for getting the output \n",
371 | " \n",
372 | " "
373 | ]
374 | },
375 | {
376 | "cell_type": "code",
377 | "execution_count": 20,
378 | "metadata": {},
379 | "outputs": [
380 | {
381 | "name": "stdout",
382 | "output_type": "stream",
383 | "text": [
384 | "1\n",
385 | "2\n",
386 | "3\n",
387 | "4\n",
388 | "5\n",
389 | "6\n",
390 | "7\n",
391 | "8\n",
392 | "9\n",
393 | "10\n"
394 | ]
395 | }
396 | ],
397 | "source": [
398 | "### print 1 to 10 numbers.\n",
399 | "\n",
400 | "for i in range(1,11):\n",
401 | " print(i)"
402 | ]
403 | },
404 | {
405 | "cell_type": "code",
406 | "execution_count": 21,
407 | "metadata": {},
408 | "outputs": [],
409 | "source": [
410 | "### iterator.\n",
411 | "\n",
412 | "l = [i for i in range(1,11)]\n",
413 | "l_iter = iter(l)\n"
414 | ]
415 | },
416 | {
417 | "cell_type": "code",
418 | "execution_count": 22,
419 | "metadata": {},
420 | "outputs": [
421 | {
422 | "data": {
423 | "text/plain": [
424 | "1"
425 | ]
426 | },
427 | "execution_count": 22,
428 | "metadata": {},
429 | "output_type": "execute_result"
430 | }
431 | ],
432 | "source": [
433 | "next(l_iter)"
434 | ]
435 | },
436 | {
437 | "cell_type": "code",
438 | "execution_count": 23,
439 | "metadata": {},
440 | "outputs": [
441 | {
442 | "data": {
443 | "text/plain": [
444 | "2"
445 | ]
446 | },
447 | "execution_count": 23,
448 | "metadata": {},
449 | "output_type": "execute_result"
450 | }
451 | ],
452 | "source": [
453 | "next(l_iter)"
454 | ]
455 | },
456 | {
457 | "cell_type": "code",
458 | "execution_count": 32,
459 | "metadata": {},
460 | "outputs": [
461 | {
462 | "ename": "StopIteration",
463 | "evalue": "",
464 | "output_type": "error",
465 | "traceback": [
466 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
467 | "\u001b[1;31mStopIteration\u001b[0m Traceback (most recent call last)",
468 | "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnext\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ml_iter\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
469 | "\u001b[1;31mStopIteration\u001b[0m: "
470 | ]
471 | }
472 | ],
473 | "source": [
474 | "next(l_iter)"
475 | ]
476 | },
477 | {
478 | "cell_type": "code",
479 | "execution_count": 35,
480 | "metadata": {},
481 | "outputs": [
482 | {
483 | "name": "stdout",
484 | "output_type": "stream",
485 | "text": [
486 | "1\n",
487 | "2\n",
488 | "3\n",
489 | "4\n",
490 | "5\n",
491 | "6\n",
492 | "7\n",
493 | "8\n",
494 | "9\n",
495 | "10\n"
496 | ]
497 | }
498 | ],
499 | "source": [
500 | "a_iter = iter(l)\n",
501 | "while True:\n",
502 | " try : \n",
503 | " item = next(a_iter)\n",
504 | " print(item)\n",
505 | " except StopIteration:\n",
506 | " break\n",
507 | " \n"
508 | ]
509 | },
510 | {
511 | "cell_type": "markdown",
512 | "metadata": {},
513 | "source": [
514 | "#### Generator:\n",
515 | "\n",
516 | "* Generator is also like function but in place of return we use yield.\n",
517 | "* Generators are always used in combination with an iterator.\n",
518 | "\n"
519 | ]
520 | },
521 | {
522 | "cell_type": "code",
523 | "execution_count": 36,
524 | "metadata": {},
525 | "outputs": [
526 | {
527 | "data": {
528 | "text/plain": [
529 | "4"
530 | ]
531 | },
532 | "execution_count": 36,
533 | "metadata": {},
534 | "output_type": "execute_result"
535 | }
536 | ],
537 | "source": [
538 | "# n = 2 --4\n",
539 | "# n = 4 -- 16\n",
540 | "# n =16 -- 256\n",
541 | "\n",
542 | "def gen(n = 2):\n",
543 | " while True:\n",
544 | " n **= 2\n",
545 | " yield n\n",
546 | "a = gen() \n",
547 | "next(a)"
548 | ]
549 | },
550 | {
551 | "cell_type": "code",
552 | "execution_count": 37,
553 | "metadata": {},
554 | "outputs": [
555 | {
556 | "data": {
557 | "text/plain": [
558 | "16"
559 | ]
560 | },
561 | "execution_count": 37,
562 | "metadata": {},
563 | "output_type": "execute_result"
564 | }
565 | ],
566 | "source": [
567 | "next(a)"
568 | ]
569 | },
570 | {
571 | "cell_type": "code",
572 | "execution_count": 42,
573 | "metadata": {},
574 | "outputs": [
575 | {
576 | "data": {
577 | "text/plain": [
578 | "340282366920938463463374607431768211456"
579 | ]
580 | },
581 | "execution_count": 42,
582 | "metadata": {},
583 | "output_type": "execute_result"
584 | }
585 | ],
586 | "source": [
587 | "next(a)"
588 | ]
589 | },
590 | {
591 | "cell_type": "code",
592 | "execution_count": 46,
593 | "metadata": {},
594 | "outputs": [
595 | {
596 | "data": {
597 | "text/plain": [
598 | "4"
599 | ]
600 | },
601 | "execution_count": 46,
602 | "metadata": {},
603 | "output_type": "execute_result"
604 | }
605 | ],
606 | "source": [
607 | "def gen(n = 2):\n",
608 | " while True:\n",
609 | " n **= 2\n",
610 | " return n\n",
611 | "gen()"
612 | ]
613 | },
614 | {
615 | "cell_type": "markdown",
616 | "metadata": {},
617 | "source": [
618 | "#### Generator Comprehension:\n",
619 | "\n"
620 | ]
621 | },
622 | {
623 | "cell_type": "code",
624 | "execution_count": 49,
625 | "metadata": {},
626 | "outputs": [
627 | {
628 | "name": "stdout",
629 | "output_type": "stream",
630 | "text": [
631 | "1\n",
632 | "35937\n",
633 | "64\n",
634 | "175616\n",
635 | "474552\n",
636 | "729000\n"
637 | ]
638 | }
639 | ],
640 | "source": [
641 | "li = [1,33,4,56,78,90]\n",
642 | "c = (i**3 for i in li)\n",
643 | "for i in c:\n",
644 | " print(i)"
645 | ]
646 | },
647 | {
648 | "cell_type": "code",
649 | "execution_count": 53,
650 | "metadata": {},
651 | "outputs": [
652 | {
653 | "data": {
654 | "text/plain": [
655 | "4"
656 | ]
657 | },
658 | "execution_count": 53,
659 | "metadata": {},
660 | "output_type": "execute_result"
661 | }
662 | ],
663 | "source": [
664 | "def gen(n = 2):\n",
665 | " while True:\n",
666 | " n **= 2\n",
667 | " yield n\n",
668 | "a = gen()\n",
669 | "next(a)"
670 | ]
671 | },
672 | {
673 | "cell_type": "code",
674 | "execution_count": 54,
675 | "metadata": {},
676 | "outputs": [
677 | {
678 | "name": "stdout",
679 | "output_type": "stream",
680 | "text": [
681 | "1\n",
682 | "35937\n",
683 | "39304\n",
684 | "175616\n",
685 | "343\n",
686 | "512\n"
687 | ]
688 | }
689 | ],
690 | "source": [
691 | "li=[1,33,34,56,7,8]\n",
692 | "c=(i**3 for i in li)\n",
693 | "for i in c:\n",
694 | " print(i)"
695 | ]
696 | },
697 | {
698 | "cell_type": "code",
699 | "execution_count": null,
700 | "metadata": {},
701 | "outputs": [],
702 | "source": []
703 | }
704 | ],
705 | "metadata": {
706 | "kernelspec": {
707 | "display_name": "Python 3",
708 | "language": "python",
709 | "name": "python3"
710 | },
711 | "language_info": {
712 | "codemirror_mode": {
713 | "name": "ipython",
714 | "version": 3
715 | },
716 | "file_extension": ".py",
717 | "mimetype": "text/x-python",
718 | "name": "python",
719 | "nbconvert_exporter": "python",
720 | "pygments_lexer": "ipython3",
721 | "version": "3.7.3"
722 | }
723 | },
724 | "nbformat": 4,
725 | "nbformat_minor": 2
726 | }
727 |
--------------------------------------------------------------------------------
/03-07-2020(Day-11).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "## Functional Programming\n",
8 | "### lambda\n",
9 | "- Anonymous function\n",
10 | "- Creating a small function\n",
11 | " - syntax: lambda arg1,arg2 : expression"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": 1,
17 | "metadata": {},
18 | "outputs": [
19 | {
20 | "data": {
21 | "text/plain": [
22 | "30"
23 | ]
24 | },
25 | "execution_count": 1,
26 | "metadata": {},
27 | "output_type": "execute_result"
28 | }
29 | ],
30 | "source": [
31 | "10 + 20"
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": 2,
37 | "metadata": {},
38 | "outputs": [
39 | {
40 | "data": {
41 | "text/plain": [
42 | "30"
43 | ]
44 | },
45 | "execution_count": 2,
46 | "metadata": {},
47 | "output_type": "execute_result"
48 | }
49 | ],
50 | "source": [
51 | "def add1(a,b):\n",
52 | " return a + b\n",
53 | "add1(10,20)"
54 | ]
55 | },
56 | {
57 | "cell_type": "code",
58 | "execution_count": 3,
59 | "metadata": {},
60 | "outputs": [],
61 | "source": [
62 | "add2 = lambda a,b : a + b"
63 | ]
64 | },
65 | {
66 | "cell_type": "code",
67 | "execution_count": 4,
68 | "metadata": {},
69 | "outputs": [
70 | {
71 | "data": {
72 | "text/plain": [
73 | "30"
74 | ]
75 | },
76 | "execution_count": 4,
77 | "metadata": {},
78 | "output_type": "execute_result"
79 | }
80 | ],
81 | "source": [
82 | "add2(10,20)"
83 | ]
84 | },
85 | {
86 | "cell_type": "code",
87 | "execution_count": 5,
88 | "metadata": {},
89 | "outputs": [
90 | {
91 | "data": {
92 | "text/plain": [
93 | "function"
94 | ]
95 | },
96 | "execution_count": 5,
97 | "metadata": {},
98 | "output_type": "execute_result"
99 | }
100 | ],
101 | "source": [
102 | "type(add1)"
103 | ]
104 | },
105 | {
106 | "cell_type": "code",
107 | "execution_count": 6,
108 | "metadata": {},
109 | "outputs": [
110 | {
111 | "data": {
112 | "text/plain": [
113 | "function"
114 | ]
115 | },
116 | "execution_count": 6,
117 | "metadata": {},
118 | "output_type": "execute_result"
119 | }
120 | ],
121 | "source": [
122 | "type(add2)"
123 | ]
124 | },
125 | {
126 | "cell_type": "code",
127 | "execution_count": 7,
128 | "metadata": {},
129 | "outputs": [
130 | {
131 | "data": {
132 | "text/plain": [
133 | "(a, b)>"
134 | ]
135 | },
136 | "execution_count": 7,
137 | "metadata": {},
138 | "output_type": "execute_result"
139 | }
140 | ],
141 | "source": [
142 | "lambda a,b : a + b"
143 | ]
144 | },
145 | {
146 | "cell_type": "markdown",
147 | "metadata": {},
148 | "source": [
149 | "- Lambda itself returns a function object"
150 | ]
151 | },
152 | {
153 | "cell_type": "code",
154 | "execution_count": 8,
155 | "metadata": {},
156 | "outputs": [
157 | {
158 | "data": {
159 | "text/plain": [
160 | "64"
161 | ]
162 | },
163 | "execution_count": 8,
164 | "metadata": {},
165 | "output_type": "execute_result"
166 | }
167 | ],
168 | "source": [
169 | "4 ** 3"
170 | ]
171 | },
172 | {
173 | "cell_type": "code",
174 | "execution_count": 9,
175 | "metadata": {},
176 | "outputs": [],
177 | "source": [
178 | "cube = lambda a1,b1:a1**b1"
179 | ]
180 | },
181 | {
182 | "cell_type": "code",
183 | "execution_count": 10,
184 | "metadata": {},
185 | "outputs": [
186 | {
187 | "data": {
188 | "text/plain": [
189 | "64"
190 | ]
191 | },
192 | "execution_count": 10,
193 | "metadata": {},
194 | "output_type": "execute_result"
195 | }
196 | ],
197 | "source": [
198 | "cube(4,3)"
199 | ]
200 | },
201 | {
202 | "cell_type": "markdown",
203 | "metadata": {},
204 | "source": [
205 | "## 'if else' in lambda function"
206 | ]
207 | },
208 | {
209 | "cell_type": "code",
210 | "execution_count": 11,
211 | "metadata": {},
212 | "outputs": [
213 | {
214 | "data": {
215 | "text/plain": [
216 | "True"
217 | ]
218 | },
219 | "execution_count": 11,
220 | "metadata": {},
221 | "output_type": "execute_result"
222 | }
223 | ],
224 | "source": [
225 | "def great(a3):\n",
226 | " if a3 > 10 and a3 < 20:\n",
227 | " return True\n",
228 | " else:\n",
229 | " return False\n",
230 | "great(15)"
231 | ]
232 | },
233 | {
234 | "cell_type": "code",
235 | "execution_count": 12,
236 | "metadata": {},
237 | "outputs": [
238 | {
239 | "data": {
240 | "text/plain": [
241 | "False"
242 | ]
243 | },
244 | "execution_count": 12,
245 | "metadata": {},
246 | "output_type": "execute_result"
247 | }
248 | ],
249 | "source": [
250 | "great(25)"
251 | ]
252 | },
253 | {
254 | "cell_type": "code",
255 | "execution_count": 13,
256 | "metadata": {},
257 | "outputs": [],
258 | "source": [
259 | "g = lambda a4 : True if(a4 > 10 and a4 < 20) else False"
260 | ]
261 | },
262 | {
263 | "cell_type": "code",
264 | "execution_count": 14,
265 | "metadata": {},
266 | "outputs": [
267 | {
268 | "data": {
269 | "text/plain": [
270 | "False"
271 | ]
272 | },
273 | "execution_count": 14,
274 | "metadata": {},
275 | "output_type": "execute_result"
276 | }
277 | ],
278 | "source": [
279 | "g(5)"
280 | ]
281 | },
282 | {
283 | "cell_type": "code",
284 | "execution_count": 15,
285 | "metadata": {},
286 | "outputs": [
287 | {
288 | "data": {
289 | "text/plain": [
290 | "True"
291 | ]
292 | },
293 | "execution_count": 15,
294 | "metadata": {},
295 | "output_type": "execute_result"
296 | }
297 | ],
298 | "source": [
299 | "g(18)"
300 | ]
301 | },
302 | {
303 | "cell_type": "code",
304 | "execution_count": 16,
305 | "metadata": {},
306 | "outputs": [],
307 | "source": [
308 | "n = 10"
309 | ]
310 | },
311 | {
312 | "cell_type": "code",
313 | "execution_count": 17,
314 | "metadata": {},
315 | "outputs": [
316 | {
317 | "data": {
318 | "text/plain": [
319 | "int"
320 | ]
321 | },
322 | "execution_count": 17,
323 | "metadata": {},
324 | "output_type": "execute_result"
325 | }
326 | ],
327 | "source": [
328 | "type(n)"
329 | ]
330 | },
331 | {
332 | "cell_type": "code",
333 | "execution_count": 18,
334 | "metadata": {},
335 | "outputs": [
336 | {
337 | "name": "stdout",
338 | "output_type": "stream",
339 | "text": [
340 | "10\n"
341 | ]
342 | }
343 | ],
344 | "source": [
345 | "n1 = input()"
346 | ]
347 | },
348 | {
349 | "cell_type": "code",
350 | "execution_count": 19,
351 | "metadata": {},
352 | "outputs": [
353 | {
354 | "data": {
355 | "text/plain": [
356 | "str"
357 | ]
358 | },
359 | "execution_count": 19,
360 | "metadata": {},
361 | "output_type": "execute_result"
362 | }
363 | ],
364 | "source": [
365 | "type(n1)"
366 | ]
367 | },
368 | {
369 | "cell_type": "code",
370 | "execution_count": 20,
371 | "metadata": {},
372 | "outputs": [
373 | {
374 | "name": "stdout",
375 | "output_type": "stream",
376 | "text": [
377 | "11\n"
378 | ]
379 | }
380 | ],
381 | "source": [
382 | "n2 = int(input())"
383 | ]
384 | },
385 | {
386 | "cell_type": "code",
387 | "execution_count": 21,
388 | "metadata": {},
389 | "outputs": [
390 | {
391 | "data": {
392 | "text/plain": [
393 | "int"
394 | ]
395 | },
396 | "execution_count": 21,
397 | "metadata": {},
398 | "output_type": "execute_result"
399 | }
400 | ],
401 | "source": [
402 | "type(n2)"
403 | ]
404 | },
405 | {
406 | "cell_type": "markdown",
407 | "metadata": {},
408 | "source": [
409 | "## Without 'if else' keyword"
410 | ]
411 | },
412 | {
413 | "cell_type": "code",
414 | "execution_count": 22,
415 | "metadata": {},
416 | "outputs": [],
417 | "source": [
418 | "g2 = lambda a5 : (a5 > 10 and a5 < 20)"
419 | ]
420 | },
421 | {
422 | "cell_type": "code",
423 | "execution_count": 23,
424 | "metadata": {},
425 | "outputs": [
426 | {
427 | "data": {
428 | "text/plain": [
429 | "True"
430 | ]
431 | },
432 | "execution_count": 23,
433 | "metadata": {},
434 | "output_type": "execute_result"
435 | }
436 | ],
437 | "source": [
438 | "g2(16)"
439 | ]
440 | },
441 | {
442 | "cell_type": "markdown",
443 | "metadata": {},
444 | "source": [
445 | "## map()\n",
446 | "- map() function can take user_defined function as a parameter\n",
447 | " - syntax: map(function, iterable1,iterable2,iterable3....)"
448 | ]
449 | },
450 | {
451 | "cell_type": "code",
452 | "execution_count": 25,
453 | "metadata": {},
454 | "outputs": [
455 | {
456 | "name": "stdout",
457 | "output_type": "stream",
458 | "text": [
459 | "