📦 Asabeneh / Python-for-Everyone

📄 python_for_everyone.ipynb · 3060 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"background-color:#306998;color:#FFD43B;font-size:64px;font-family:sans;padding:20px\">PYTHON FOR EVERYONE<h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">INTRODUCTION</h1>\n",
    "\n",
    "Python for Everyon is a step by step guide to learn Python and programming in general. ***Python For Everyone*** is a guide for both beginners and advanced Python developers. Welcome to *Python For Everyone*. \n",
    "\n",
    "***Congratulations*** for deciding to learn Python. Python is eating the world. It has been the choice for developers to use python for different puprpose specifically to deal with data.\n",
    "\n",
    "In this step by step guide, you will learn Pyton. Python is one of the most popular programming language. \n",
    "You use Python ***to develop web applicaton***, ***to develop mobile apps***, ***desktop applications, games*** and mostly Python is use for ***data Sciecne***, ***machine learning*** and ***AI***.\n",
    "***Python*** has increased in popularity in recent years and has been the leading\n",
    "programming language for data science and machine language."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">SET UP</h1>\n",
    "\n",
    "First install [Python](https://www.python.org/downloads/).\n",
    "To write python code, we need to have a code editor. Lets install text or code editor. There are many open source code editors which can help you to write python code. These are the most commonly used ones:\n",
    "- [Jupter Note book](https://www.anaconda.com/distribution/)\n",
    "- [vscode](https://code.visualstudio.com/)\n",
    "- [pycharm](https://www.jetbrains.com/pycharm/)\n",
    "- [atom](https://atom.io/)\n",
    "- [notepad++](https://notepad-plus-plus.org/) or others.\n",
    "\n",
    "Jupter Notebook is highly recommended. You can use jupter note book by installing [anaconda](https://www.anaconda.com/distribution/). Anaconda is the most popular Python/R platform which allow you to use different development tools and making package installing so simple.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">COMMENT</h1>\n",
    "\n",
    "Comment is essential to make code readable to ourselves or for others. Commented part of our code is not interperated by Python interperator."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "# This is a single line comment"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Exerciese:\n",
    "- Write your first python comment\n",
    "- Write an other more python comment\n",
    "- Write you third pyhon comment\n",
    "- Write a comment which says I am exited to learn Python Programming.\n",
    "- Write a comment which says It is recommended to add a comment at the beginning of a code\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\"> PRINTING USING PYTHON</h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello, World!\n",
      "Hello, World !\n",
      "Welcome to Python!\n",
      "Learn python in 2019\n",
      "Welcome to Python for Everyone\n",
      "Welcome to Python for Everyone\n"
     ]
    }
   ],
   "source": [
    "# Printing in Python\n",
    "print('Hello, World!')\n",
    "print('Hello,', \"World\", \"!\")\n",
    "print(\"Welcome to Python!\")\n",
    "print('Learn python in', 2019)\n",
    "print('Welcome to Python for Everyone')\n",
    "print('Welcome','to', 'Python','for','Everyone')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Exerciese:\n",
    "\n",
    "1. Writ a python comment saying 'How to print using print () at beginning of your code'\n",
    "2. Print your first name using ***print()***\n",
    "3. Print your last name using ***print ()***\n",
    "4. Print your full name using ***print ()***\n",
    "5. Print your country using ***print()***\n",
    "6. Print your city using ***print()***\n",
    "7. Print your age using ***print ()***\n",
    "8. Print the year using ***print()***\n",
    "9. Print your qualification or your job using I***print()***\n",
    "10. Are you single or married ? Answer should be True or False. Print the answer using ***print()***\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">VARIABLES</h1>\n",
    "\n",
    "Variables are containers or a means to store data in computer memory. pneumonic varialbes recommend to use in many programming langauges. \n",
    "\n",
    "Valid variable names\n",
    "```shell\n",
    "    firstname\n",
    "    lastname\n",
    "    age\n",
    "    country\n",
    "    city\n",
    "    first_name\n",
    "    last_name\n",
    "    capital_city\n",
    "    _if # if we want to use reservered word as a variable\n",
    "    first_name\n",
    "    year_2019\n",
    "    year2019\n",
    "    current_year_2019\n",
    "    num1\n",
    "    num2\n",
    "```\n",
    "\n",
    "Invalid varaible names\n",
    "- first-name\n",
    "- num-1\n",
    "- 1num\n",
    "\n",
    "In Pyton For Everyone, we will use standard python varible naming which has been adopted by many python developers. The example below is an example of standard naming of variables, underscore when the variable name is long. \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "First name: Asabeneh\n",
      "Last name:  Yetayeh\n",
      "Country:  Helsinki\n",
      "Age:  250\n",
      "Married:  True\n"
     ]
    }
   ],
   "source": [
    "# Variables in Python\n",
    "\n",
    "first_name = \"Asabeneh\"\n",
    "last_name = \"Yetayeh\"\n",
    "country = \"Helsinki\"\n",
    "age = 250\n",
    "is_married = True\n",
    "# Printing the values stored in the variables\n",
    "print('First name:', first_name)\n",
    "print('Last name: ', last_name)\n",
    "print('Country: ', country)\n",
    "print('Age: ', age)\n",
    "print('Married: ', is_married)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Variable can also be declared in one line:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabeneh Yetayeh Helsink 250 True\n",
      "First name: Asabeneh\n",
      "Last name:  Yetayeh\n",
      "Country:  Helsink\n",
      "Age:  250\n",
      "Married:  True\n"
     ]
    }
   ],
   "source": [
    "first_name, last_name, country, age, is_married = 'Asabeneh', 'Yetayeh', 'Helsink', 250, True\n",
    "print(first_name, last_name, country, age, is_married)\n",
    "print('First name:', first_name)\n",
    "print('Last name: ', last_name)\n",
    "print('Country: ', country)\n",
    "print('Age: ', age)\n",
    "print('Married: ', is_married)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Exerciese: Variables\n",
    "1. Writ a python comment saying 'Variables in python'\n",
    "2. Declare a first name variable and assign a value to it\n",
    "3. Declare a last name variable and assign a value to it\n",
    "4. Declare a full name variable and assign a value to it\n",
    "5. Declare a country variable and assign a value to it\n",
    "6. Declare a city variable and assign a value to it\n",
    "7. Declare an age varialbel and assign a value to it\n",
    "8. Declare a year varaible and assign  a value to it\n",
    "9. Declare a variable is_married and assign a value to it\n",
    "10. Declare a variable is_true and assign a value to it\n",
    "11. Declare a variable is_light_on and assign a value to it\n",
    "12. Declare multiple variable on one line"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Getting User Input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "What is your name ?Asabeneh\n",
      "How old are you ?100\n",
      "Asabeneh , you are old enough\n"
     ]
    }
   ],
   "source": [
    "name = input('What is your name ?')\n",
    "age = int(input('How old are you ?'))\n",
    "\n",
    "if age < 18:\n",
    "    print(name,' you are under age')\n",
    "else:\n",
    "    print(name, ', you are old enough')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">PYTHON DATA TYPES</h1>\n",
    "\n",
    "Different data types in python. There are different data type in python programming. To identify the data tpe we use the type method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n",
      "<class 'str'>\n",
      "<class 'int'>\n",
      "<class 'float'>\n",
      "<class 'complex'>\n",
      "<class 'bool'>\n",
      "<class 'list'>\n",
      "<class 'dict'>\n",
      "<class 'tuple'>\n",
      "<class 'zip'>\n"
     ]
    }
   ],
   "source": [
    "# Different python data types\n",
    "# Let's declare different data tyeps\n",
    "\n",
    "first_name = 'Asabeneh' # String\n",
    "last_name = 'Yetayeh' # String\n",
    "country = 'Finland' # String\n",
    "city= 'Helsinki'\n",
    "age = 250 # Number, it is not my real age, don't worry about it\n",
    "\n",
    "print(type('Asabeneh'))\n",
    "print(type(first_name))\n",
    "print(type(10))\n",
    "print(type(3.14))\n",
    "print(type(1 + 1j))\n",
    "print(type(True))\n",
    "print(type([1, 2,3,4]))\n",
    "print(type({\"name\":\"Asabeneh\",\"age\":250, \"is_married\":250}))\n",
    "print(type((1,2)))\n",
    "print(type(zip([1,2],[3,4])))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Exerciese: Data Types\n",
    "\n",
    "1. Writ a python comment saying 'Python Data types'\n",
    "2. Declare a first name variable and assign a value to it\n",
    "3. Declare a last name variable and assign a value to it\n",
    "4. Declare an age varialbel and assign a value to it\n",
    "5. Declare a full name variable and assign a value to it\n",
    "6. Declare a country variable and assign a value to it\n",
    "7. Declare a city variable and assign a value to it\n",
    "8. Declare a variable is_married and assign a value to it\n",
    "9. Declare a variable is_true and assign a value to it\n",
    "10. Declare a variable is_light_on and assign a value to it\n",
    "11. Check the data types of each variable using type()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Numbers\n",
    "1. Integers\n",
    "2. Floating Numbers\n",
    "3. Complex Numbers\n",
    "\n",
    "Numbers are python data types. \n",
    "Arthimetic Operators: +, -, *, /"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Additon:  3\n",
      "Substraction:  1\n",
      "Multiplication:  6\n",
      "Division:  2.0\n",
      "Division:  3.0\n",
      "Division:  3.5\n",
      "Division without the remainder:  3\n",
      "Modulous:  1\n",
      "Division without the remainder:  2\n",
      "Exponentation:  9\n",
      "Floating Number 3.14\n",
      "Complex number:  (1+1j)\n",
      "Multiplying complext number:  (2+0j)\n",
      "== Additon, Subtraction, Multipliation, Division, Modules ==\n",
      "sum:  7\n",
      "difference:  1\n",
      "product:  12\n",
      "division:  1.0\n",
      "remainder:  1\n",
      "735.75 N\n"
     ]
    }
   ],
   "source": [
    "# Arthimetic Operations in Python\n",
    "# Integers\n",
    "\n",
    "print('Additon: ', 1 + 2)\n",
    "print('Substraction: ', 2 - 1)\n",
    "print('Multiplication: ', 2 * 3)\n",
    "print ('Division: ', 4 / 2) # Division in python gives floating number\n",
    "print('Division: ', 6 / 2)\n",
    "print('Division: ', 7 / 2)\n",
    "print('Division without the remainder: ', 7 // 2) # gives without the floating number or without the remaining\n",
    "print('Modulous: ', 3 % 2)\n",
    "print ('Division without the remainder: ',7 // 3)\n",
    "print('Exponentation: ', 3 ** 2)\n",
    "# Floating numbers\n",
    "print('Floating Number', 3.14)\n",
    "# Complex numbers\n",
    "print('Complex number: ', 1+1j)\n",
    "print('Multiplying complext number: ',(1+1j) * (1-1j))\n",
    "\n",
    "\n",
    "print('== Additon, Subtraction, Multipliation, Division, Modules ==')\n",
    "\n",
    "num_one = 3\n",
    "num_two = 4\n",
    "\n",
    "total = num_one + num_two\n",
    "diff = num_two - num_one\n",
    "product = num_one * num_two\n",
    "div = num_two / num_two\n",
    "remainder = num_two % num_one\n",
    "\n",
    "\n",
    "print('sum: ', total)\n",
    "print('difference: ', diff)\n",
    "print('product: ', product)\n",
    "print('division: ', div)\n",
    "print('remainder: ', remainder)\n",
    "\n",
    "mass = 75\n",
    "gravity = 9.81\n",
    "# Calcualte the wieght of the object on planet earth\n",
    "weight = mass * gravity\n",
    "\n",
    "print(weight, 'N')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Exerciese: Numbers\n",
    "\n",
    "1. Declare your age as integer variable\n",
    "2. Declare your height as a float variable\n",
    "3. Declare a complex number variable\n",
    "4. Calcaulate an area of a triangle (area = 0.5 x  b x h)\n",
    "5. Calaculate the primeter of triangle (p = a + b + c)\n",
    "6. Calaculate the of area rectangle (area = lenght x width)\n",
    "7. Calaculate the primeter of rectangle (p = 2 x (length + width))\n",
    "8. Calculate the area of a circle (area = 3.14 x r x r)\n",
    "9. Calculate the circumference of a circle(c = 2 x pi x r)\n",
    "10. Calculate the value of y (y = x2 + 6x + 9). Try to use different x value and figure out at what x value y is 0."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Strings\n",
    "String is data type. Any data under single or double quot are a string. There are diferent string methods to deal with string data types. To check the length of a string use the ***len()*** method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabeneh\n",
      "8\n",
      "Yetayeh\n",
      "7\n",
      "Helsinki\n",
      " \n",
      " Asabeneh Yetayeh\n"
     ]
    }
   ],
   "source": [
    "# Assigning variables to string value\n",
    "\n",
    "first_name = \"Asabeneh\"\n",
    "space = ' ' # an empty space string\n",
    "last_name = \"Yetayeh\"\n",
    "country = \"Helsinki\"\n",
    "full_name = ' Asabeneh Yetayeh'\n",
    "\n",
    "print(first_name)\n",
    "print(len(first_name))\n",
    "print(last_name)\n",
    "print(len(last_name))\n",
    "print(country)\n",
    "print(space)  # You don't see the printed empty space\n",
    "print(full_name) # there is indent because of the trailing space in the full name is string\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### String Concatination\n",
    "Merging two or more strings together is called ***concatination***"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Full name:  Asabeneh Yetayeh\n",
      "Person Information: I am Asabeneh Yetayeh. I live in Finland, Helsinki.\n",
      "Git repository:  Python  for  Everyone\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# String concatination\n",
    "first_name = \"Asabeneh\"\n",
    "space = ' ' # an empty space string\n",
    "last_name = \"Yetayeh\"\n",
    "country = \"Finland\"\n",
    "city = 'Helsinki'\n",
    "full_name = first_name  + space + last_name\n",
    "git_repo= 'Python ' + ' for ' + ' Everyone'\n",
    "person_info = 'I am ' + full_name + '. I live in ' + country + ', '+ city + '.'\n",
    "print('Full name: ', full_name)\n",
    "print('Person Information:', person_info)\n",
    "print('Git repository: ', git_repo)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  String transformations\n",
    "\n",
    "- ***s.lower()***:  Change all letters to lowercase\n",
    "- ***s.upper()***:  Change all letters to uppercase\n",
    "- ***s.capitalize()***: Change all letters to capitalcase\n",
    "- ***s.title()***: Change to titlecase\n",
    "- ***s.swapcase()***: Change all uppercase letters to lowercase, and vice versa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== change to lower case ===\n",
      "asabeneh\n",
      "yetayeh\n",
      "asabeneh yetayeh\n",
      "=== change to upper case ===\n",
      "ASABENEH\n",
      "YETAYEH\n",
      "ASABENEH YETAYEH\n",
      "=== change to capitalize ===\n",
      "Asabeneh\n",
      "Yetayeh\n",
      "Asabeneh yetayeh\n",
      "=== change to title ===\n",
      "Python For Everyone\n",
      "Learning Programming Using Python\n",
      "Python\n",
      "Both Begineer And Advanced Learners\n",
      "=== swapping cases ===\n",
      "asabeeh\n",
      "YETAYEH\n",
      "asabeeh YETAYEH\n"
     ]
    }
   ],
   "source": [
    "firstName = 'Asabeneh'\n",
    "lastName = 'Yetayeh'\n",
    "space = ' '\n",
    "full_Name = first_name + space + last_name;\n",
    "\n",
    "# Changing string to lower case\n",
    "print('=== change to lower case ===')\n",
    "print(first_name.lower())\n",
    "print(last_name.lower())\n",
    "print(full_Name.lower())\n",
    "\n",
    "# Changing string to upper case\n",
    "print('=== change to upper case ===')\n",
    "print(first_name.upper())\n",
    "print(lastName.upper())\n",
    "print(full_Name.upper())\n",
    "\n",
    "\n",
    "# Changing string to capitalize\n",
    "print('=== change to capitalize ===')\n",
    "print(first_name.capitalize())\n",
    "print(lastName.capitalize())\n",
    "print(full_Name.capitalize())\n",
    "\n",
    "# Changing string to capitalize\n",
    "\n",
    "print('=== change to title ===')\n",
    "title = 'python for everyone'\n",
    "sub_title = 'learning programming using python'\n",
    "lang = 'python'\n",
    "level = 'both begineer and advanced learners'\n",
    "print(title.title())\n",
    "print(sub_title.title())\n",
    "print(lang.title())\n",
    "print(level.title())\n",
    "\n",
    "# Changing string to swapcase()\n",
    "print('=== swapping cases ===')\n",
    "\n",
    "first_name = 'ASABEEH'\n",
    "last_name = 'yetayeh'\n",
    "space = ' '\n",
    "full_name = first_name + space + last_name;\n",
    "\n",
    "print(first_name.swapcase())\n",
    "print(last_name.swapcase())\n",
    "print(full_name.swapcase())\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Spliting string\n",
    "\n",
    "Empty space is the default paramter. \n",
    "\n",
    "- ***s.split()***:  Change the string to a list containing the string\n",
    "- ***s.split(' ')***:Change the string to a list containing the words of in the string\n",
    "- ***s.split(',')***: split the words at the comma\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Asabeneh']\n",
      "['A', 's', 'a', 'b', 'e', 'n', 'e', 'h']\n",
      "['Asabeneh', 'Yetayeh']\n",
      "['python', ' R', ' matlab', ' and Java']\n",
      "8\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "# Spliting a stirng to list\n",
    "first_name = 'Asabeneh'\n",
    "last_name = 'Yetayeh'\n",
    "full_name = 'Asabeneh Yetayeh'\n",
    "\n",
    "programming_lang = 'python, R, matlab, and Java'\n",
    "\n",
    "\n",
    "# Changing a string to list\n",
    "print(first_name.split())\n",
    "print(list(first_name))\n",
    "print(full_name.split(' '))\n",
    "print(programming_lang.split(','))\n",
    "\n",
    "\n",
    "# To check the length of string\n",
    "print(len(first_name))\n",
    "\n",
    "# To check the data type of the string\n",
    "print(type(first_name))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### String Formatting"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercises- Strings\n",
    "\n",
    "1. Concatinate the string 'Python', 'For','Everyone' to a single string, 'Python for Everyone'\n",
    "1. Concatinate the string 'Coding', 'For' , 'All' to a single string, 'Coding For All'\n",
    "1. Declare a variable name company and assign it to an initial value **\"Coding For All\"**.\n",
    "1. Print company using __print()__\n",
    "1. Print the __length__ of the company string using ***len()*** method and  _print()_\n",
    "1. Change all the string to capital letters using __upper()__ method\n",
    "1. Change all the string to lowercase letters using __lower()__ method\n",
    "1. Use ***capitalize(),title(), swapcase()*** methods to format the value stored in the varaible name company\n",
    "1. Cut(slice) out the first word of the company string \n",
    "1. Check if the string contains a word __Coding__ using the method index, find or other methods.\n",
    "1. Replace the word coding in the string 'Coding For All' to Python using replace or other methods.\n",
    "1. Change Python for Everyone to Python for All using the replace method or other methods\n",
    "1. Split the string 'Coding For All' at the space using __split()__ method\n",
    "1. \"Facebook, Google, Microsoft, Apple, IBM, Oracle, Amazon\" __split__ the string at the comma\n",
    "1. What is character at index 10 in \"Coding For All\"\n",
    "1. Create an acronym or an abbrivaton for the name 'Python For Everyone'\n",
    "1. Create an acronym or an abbrivaton for the name 'Coding For All'\n",
    "1. Use __index__ to determine the position of the first occurrence of C in Coding For All\n",
    "1. Use __index__ to determine the position of the first occurrence of F in Coding For All\n",
    "1. Use __rfind__ to determine the position of the last occurrence of l in Coding For All People.\n",
    "1. Use __index or find__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__\n",
    "1. Use __rindex__ to find the position of the last occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__\n",
    "1. Slice out the phase __because because because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__\n",
    "1. Use __search__ to find the position of the first occurrence of the word __because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__\n",
    "1. Slice out the phase __because because because__ in the following sentence:__'You cannot end a sentence with because because because is a conjunction'__\n",
    "1. Use __trim()__ to remove if there is trailing whitespace at the beginning and the end of a string.E.g \" Coding For All \".\n",
    "1. Use __startswith()__ method with the string Coding For All make the result true\n",
    "1. Use __endswith()__ method with the string Python for Everyone make the result true\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Booleans\n",
    "A boolean value is either True or False.\n",
    "\n",
    "- Comparison operatiors: >, >=, <, <=, ==, !=\n",
    "- Logical Operators ***or***, ***and***, !"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Data Type Conversion"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "<class 'str'>\n",
      "10\n",
      "<class 'int'>\n",
      "10.0\n"
     ]
    }
   ],
   "source": [
    "num_str = '10'\n",
    "print(num_str)\n",
    "print(type(num_str))\n",
    "\n",
    "num_int = int(num)\n",
    "print(num_int)\n",
    "print(type(num_int))\n",
    "\n",
    "num_float = float(num_str)\n",
    "print(num_float)\n",
    "\n",
    "e = 2.71"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">CONDITIONALS </h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True == True:  True\n",
      "True == False:  False\n",
      "False == False: True\n",
      "True and True:  True\n",
      "True or False: True\n",
      "a in an: True\n",
      "4 is 2 ** 2: True\n",
      "True\n",
      "True\n",
      "True\n",
      "False\n",
      "False\n",
      "False\n",
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "# Comparing something give either a True or False\n",
    "print('True == True: ', True == True)\n",
    "print('True == False: ', True == False)\n",
    "print('False == False:', False == False)\n",
    "print('True and True: ', True and True)\n",
    "print('True or False:', True or False)\n",
    "print('a in an:', 'a' in 'an')\n",
    "print('4 is 2 ** 2:', 4 is 2 **2)\n",
    "\n",
    "print(3 > 2)\n",
    "print(3 >= 2)\n",
    "print(3 != 2)\n",
    "print(3 < 2)\n",
    "print(3 <= 2)\n",
    "print(3==2)\n",
    "print(3!='3')\n",
    "print(3==3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number is greater than 5\n",
      "Number is greater than 5\n",
      "Number is 5\n"
     ]
    }
   ],
   "source": [
    "num = 10\n",
    "if num > 5:\n",
    "    print('Number is greater than 5')\n",
    "# The is conditon does't get exected so we need else\n",
    "if num < 5:\n",
    "    print('Number is less than 5')\n",
    "\n",
    "if num < 5:\n",
    "    print('Number is less than 5')\n",
    "else:\n",
    "    print('Number is greater than 5')\n",
    "    \n",
    "num = 5\n",
    "if num < 5:\n",
    "    print('Number is less than 5')\n",
    "elif num == 5:\n",
    "    print('Number is 5')\n",
    "else:\n",
    "    print('Number is greater than 5')\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercises: Conditional\n",
    "1. Get user input using input(“Enter your age:”). If user is 18 or older , give feedback:You are old enough to drive but if not 18 give feedback to wait for the years he supposed to wait for.\n",
    "   Output:\n",
    "   ```sh\n",
    "   Enter your age: 30\n",
    "   You are old enough to drive.\n",
    "   ```\n",
    "   Output:\n",
    "   ```sh\n",
    "   Enter your age:15\n",
    "   You are left with 3 years to drive.\n",
    "   ```\n",
    "1. Compare the values of myAge and yourAge using if … else. Based on the comparison log to console who is older (me or you). Use prompt(“Enter your age:”) to get the age as input.\n",
    "   Output:\n",
    "   ```sh\n",
    "   Enter your age: 30\n",
    "   You are 5 years older than me.\n",
    "   ```\n",
    "1. If a is greater than b return a is greater than b else a is less than b.\n",
    "   Output:\n",
    "   `sh let a = 4; let b = 3; 4 is greater than 3`\n",
    "1. Write a code which give grade students according to theirs scores:\n",
    "   - 80-100, A\n",
    "   - 70-89, B\n",
    "   - 60-69, C\n",
    "   - 50-59, D\n",
    "   - 0 -49, F\n",
    "1. Check if the season is Autumn, Winter, Spring or Summer.\n",
    "   If the user input is:\n",
    "   - September, October or November, the season is Autumn.\n",
    "   - December, January or February, the season is Winter.\n",
    "   - March, April or May, the season is Spring\n",
    "   - June, July or August, the season is Summer\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">LOOPS</h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### For loops:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== Whole Numbers===\n",
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n",
      "10\n",
      "=== Even Numbers===\n",
      "0\n",
      "2\n",
      "4\n",
      "6\n",
      "8\n",
      "10\n",
      "=== Odd Numbers===\n",
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "print('=== Whole Numbers===')\n",
    "for x in range(11):\n",
    "    print(x)\n",
    "\n",
    "print('=== Even Numbers===')\n",
    "# the range(initial, stop, step)\n",
    "for n in range(0, 11, 2):\n",
    "    print(n)\n",
    "    \n",
    "print('=== Odd Numbers===')\n",
    "# the range(initial, stop, step)\n",
    "for n in range(1, 11, 2):\n",
    "    print(n)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Continue and break in for loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "for x in range(10):\n",
    "    if (x is 1):\n",
    "        continue\n",
    "    if (x > 5):\n",
    "        break\n",
    "    print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### While Loop\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "x = 0\n",
    "while (x < 10):\n",
    "    print(x)\n",
    "    x += 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercises\n",
    "1. Iterate 0 to 10 using for loop, do the same using while and do while loop.\n",
    "1. Iterate 10 to 0 using for loop, do the same using while and do while loop.\n",
    "1. Write a loop that makes seven calls to print() to output the following triangle:\n",
    "   ```python\n",
    "       #\n",
    "       ##\n",
    "       ###\n",
    "       ####\n",
    "       #####\n",
    "       ######\n",
    "       #######\n",
    "   ```\n",
    "1. Use nested loops to create the following:\n",
    "```sh\n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "    # # # # # # # # \n",
    "```\n",
    "1. Iterate the list, ['Python', 'Numpy','Pandas','Data Science', AI','ML'] using a for loop and print out the items.\n",
    "1. Use for loop to iterate from 0 to 100 and print only even numbers\n",
    "1. Use for loop to iterate from 0 to 100 and print only odd numbers\n",
    "1. Use for loop to iterate from 0 to 100 and print and print the sum of all numbers.\n",
    "   ```python\n",
    "    # The sum of all numbers is 5050.\n",
    "   ```\n",
    "1. Use for loop to iterate from 0 to 100 and print the sum of all evens and the sum of all odds.\n",
    "   ```python\n",
    "   # The sum of all evens is 2550. And the sum of all odds is 2500.\n",
    "    ```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# Lists\n",
    "Lists are like arrays in JavaScript. They store different elements unlike other varialbles. List has different methods to modify and manipulate the list. Some of the methods which are used to modiyf lists **append**, **insert**, **extend**."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Creating an empty list or list containing values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'>\n",
      "[]\n",
      "[1, 2, 3, 4, 5, 6]\n",
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n",
      "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]\n",
      "['Asabeneh', 'Brook', 'Sami', 'David']\n",
      "['Google', 'Facebook', 'Nokia', 'Apple', 'Oracle', 'Amazon', 'IBM']\n",
      "[3.14, 9.81, 98.6, 100]\n"
     ]
    }
   ],
   "source": [
    "# Creating lists\n",
    "lst = [] # empty list\n",
    "print(list)\n",
    "lst = list() # empty list\n",
    "print(lst)\n",
    "numbers = [1, 2, 3, 4, 5, 6] # creating list 1 to 6\n",
    "print(numbers)\n",
    "one_to_hunderd = list(range(11)) # creating list 1 to 10\n",
    "even_numbers = list(range(0,51, 2)) # Create even number lists 0 to 50\n",
    "print(one_to_hunderd)\n",
    "print(even_numbers)\n",
    "\n",
    "names = ['Asabeneh','Brook','Sami','David']\n",
    "print(names)\n",
    "it_companies = ['Google','Facebook','Nokia','Apple','Oracle','Amazon','IBM']\n",
    "print(it_companies)\n",
    "constants = [3.14, 9.81, 98.6, 100]\n",
    "print(constants)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "is odd\n",
      "2\n",
      "is even\n",
      "3\n",
      "is odd\n",
      "4\n",
      "is even\n",
      "5\n",
      "is odd\n",
      "6\n",
      "is even\n",
      "All done.\n"
     ]
    }
   ],
   "source": [
    "for number in numbers:\n",
    "    print(number)\n",
    "    if (number % 2 == 0):\n",
    "        print(\"is even\")\n",
    "    else:\n",
    "        print(\"is odd\")\n",
    "        \n",
    "print (\"All done.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Appending value  to lists"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using different methods to manipulate lists. Slicing using :, appending, extending and inserting:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n"
     ]
    }
   ],
   "source": [
    "# First lets create a list\n",
    "x = [1, 2, 3, 4, 5, 6]\n",
    "print(len(x)) # to check the length of the list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 8, 9]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.append(8)\n",
    "x.append(9)\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Inserting value among values in a list\n",
    "Inserting a value at a certain index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.insert(6,7) # the missing value in the list which is 7 is inserted\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Use extend to two or more arrays together"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10]"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.extend([9,10])\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Slicing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:3]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[4, 5, 6, 7, 8, 9, 9, 10]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[3:]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[9, 10]"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[-2:]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Concating lists (Merging)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5, 6]\n"
     ]
    }
   ],
   "source": [
    "a = [1, 2,3]\n",
    "b = [4, 5,6]\n",
    "c = a + b\n",
    "print(c)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "List of lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1, 2, 3], [4, 5, 6]]\n"
     ]
    }
   ],
   "source": [
    "x = [1, 2,3]\n",
    "y = [4, 5,6];\n",
    "z = [x, y]\n",
    "print(z)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "[1, 2, 3]\n",
      "1\n",
      "[4, 5, 6]\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "print(x[0])\n",
    "print(z[0])\n",
    "print(z[0][0])\n",
    "print(z[1])\n",
    "print(z[1][0])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z = [3, 2, 1]\n",
    "z.sort()\n",
    "z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3, 2, 1]"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z.sort(reverse=True)\n",
    "z"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Sort vs Sorted in list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 3, 4, 5]\n",
      "None\n",
      "[3, 1, 4, 2, 5]\n",
      "[1, 2, 3, 4, 5]\n"
     ]
    }
   ],
   "source": [
    "nums_one = [3,1,4,2,5]\n",
    "nums_sort =nums_one.sort() # mutate the original list and return None\n",
    "print(nums_one)\n",
    "print(nums_sort) # return None\n",
    "nums_two = [3,1,4,2,5]\n",
    "nums_sorted = sorted(nums_two) # mutate the original list\n",
    "print(nums_two)\n",
    "print(nums_sorted)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Getting index of a list using enumerate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "index: 0 2\n",
      "index: 1 4\n",
      "index: 2 6\n",
      "index: 3 8\n",
      "index: 4 10\n"
     ]
    }
   ],
   "source": [
    "even_nums = [2,4,6,8,10]\n",
    "for i, n in enumerate(even_nums):\n",
    "    print('index:',i, n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "index: 0 0\n",
      "index: 1 1\n",
      "index: 2 2\n",
      "index: 3 3\n",
      "index: 4 4\n",
      "index: 5 5\n",
      "index: 6 6\n",
      "index: 7 7\n",
      "index: 8 8\n",
      "index: 9 9\n"
     ]
    }
   ],
   "source": [
    "for i, n in enumerate(range (10)):\n",
    "    print('index:',i, n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [],
   "source": [
    "(name, age) = ['Asabeneh', 250]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabeneh 250\n"
     ]
    }
   ],
   "source": [
    "print(name, age)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## List Comprehension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[i  for i in range (11)] # list of whole numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[i * i for i in range (11)] # List of squares "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]\n"
     ]
    }
   ],
   "source": [
    "even_nums = [i for i in range(51) if i % 2 == 0] # List of even numbers\n",
    "print(even_nums)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]\n"
     ]
    }
   ],
   "source": [
    "odds = [i for i in range(51) if i % 2 != 0] # List of odd numbers\n",
    "print(odds)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 4, 9, 16, 25]"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers = [1, 2, 3,4,5]\n",
    "[n * n for n in numbers]  # maping using list comprehension\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['ASABENEH', 'BROOK', 'DAVID', 'MARTHA']"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "names = ['Asabeneh','Brook','David','Martha']\n",
    "[name.upper () for name in names] # Mapping using list comprehension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2, 4, 6]"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers = [-4, -3, -2, -1, 0, 2, 4, 6]\n",
    "[n for n in numbers if n > 0] # Filtering using list comprehension"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercises\n",
    "\n",
    "1. Declare an _empty_ list;\n",
    "1. Declare a list with more than 5 number of items\n",
    "1. Find the length of your list\n",
    "1. Get the first item, the middle item and the last item of the list\n",
    "1. Declare a list called _mixed_data_types_,put different data types and in your array and the array size should be greater than 5\n",
    "1. Declare a list variable name it_companies and assign initial values Facebook, Google, Microsoft, Apple, IBM, Oracle and Amazon.\n",
    "1. Print the list using _print()_\n",
    "1. Print the number of companies in the list\n",
    "1. Print the first, middle and last company\n",
    "1. Print out each company\n",
    "1. Change companies to uppercase and print them out\n",
    "1. Print the list like as a sentence: Facebook, Google, Microsoft, Apple, IBM,Oracle and Amazon are big IT companies.\n",
    "1. Check if a certain company exists in the it_companies list. If it exist return the company else return a company is _not found_.\n",
    "1. Filter out companies which have more than one 'o' without the filter method\n",
    "1. Sort the array using _sort()_ method\n",
    "1. Reverse the array without method\n",
    "1. Reverse the array using  method\n",
    "1. Slice out the first 3 companies from the list\n",
    "1. Slice out the last 3 companies from the list\n",
    "1. Slice out the middle IT company or companies from the list\n",
    "1. Remove the first IT company from the array\n",
    "1. Remove the middle IT company or companies from the list\n",
    "1. Remove the last IT company from the list\n",
    "1. Remove all IT companies\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  Tuples\n",
    "###  Creating Tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'tuple'>\n",
      "<class 'tuple'>\n",
      "(1, 2, 3)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Tuples are just immutable lists. Use () instead of []\n",
    "tp = tuple()\n",
    "print(type (tp))\n",
    "tp = ()\n",
    "print(type(tp))\n",
    "nums = (1, 2, 3)\n",
    "print(nums)\n",
    "len(nums)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "for n in nums:\n",
    "    print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = (1, 2, 3)\n",
    "y = (4, 5, 6)\n",
    "print(x[0])\n",
    "y[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 2, 3), (4, 5, 6)]"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list_of_tuples = [x, y]\n",
    "list_of_tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "32\n",
      "120000\n"
     ]
    }
   ],
   "source": [
    "(age, income) = \"32,120000\".split(',')\n",
    "print(age)\n",
    "print(income)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers = [1, 2, 3,4,5]\n",
    "[(n,n * n) for n in numbers]  # maping using list comprehension\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('ASABENEH', 8), ('BROOK', 5), ('DAVID', 5), ('MARTHA', 6)]"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = ['Asabeneh','Brook','David','Martha']\n",
    "[(name.upper (), len(name)) for name in names] # Mapping using list comprehension"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Dictionaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'Asabenh', 'age': 250, 'country': 'Finland', 'city': 'Helsinki', 'job': 'instructor and developer', 'skills': ['HTML', 'CSS', 'JavaScript', 'Python', 'Node'], 'is_married': True}\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "# Creating empty dictionary\n",
    "\n",
    "dic = dict()\n",
    "dic = {}\n",
    "\n",
    "# Another more dictionary\n",
    "person = {\n",
    "    'name':'Asabenh',\n",
    "    'age':250, \n",
    "    'country':'Finland',\n",
    "    'city':'Helsinki', \n",
    "    'job':'instructor and developer',\n",
    "    'skills':['HTML','CSS','JavaScript','Python','Node'],\n",
    "    'is_married':True\n",
    "}\n",
    "print(person)\n",
    "print(len(person))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': 'Asabenh', 'age': 250, 'country': 'Finland', 'city': 'Helsinki', 'job': 'instructor and developer', 'skills': ['HTML', 'CSS', 'JavaScript', 'Python', 'Node'], 'is_married': True}\n"
     ]
    }
   ],
   "source": [
    "print(person)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabenh\n"
     ]
    }
   ],
   "source": [
    "print(person[\"name\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "250\n"
     ]
    }
   ],
   "source": [
    "print(person[\"age\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(person.get(\"is_married\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name: Asabenh\n",
      "age: 250\n",
      "country: Finland\n",
      "city: Helsinki\n",
      "job: instructor and developer\n",
      "skills: ['HTML', 'CSS', 'JavaScript', 'Python', 'Node']\n",
      "is_married: True\n"
     ]
    }
   ],
   "source": [
    "for key in person:\n",
    "        print(key + \": \" + str(person[key]))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Dictionary Methods\n",
    "**keys**, **values**, **items**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys(['name', 'age', 'country', 'city', 'job', 'skills', 'is_married'])\n",
      "dict_values(['Asabenh', 250, 'Finland', 'Helsinki', 'instructor and developer', ['HTML', 'CSS', 'JavaScript', 'Python', 'Node'], True])\n",
      "dict_items([('name', 'Asabenh'), ('age', 250), ('country', 'Finland'), ('city', 'Helsinki'), ('job', 'instructor and developer'), ('skills', ['HTML', 'CSS', 'JavaScript', 'Python', 'Node']), ('is_married', True)])\n"
     ]
    }
   ],
   "source": [
    "keys = person.keys()\n",
    "values = person.values()\n",
    "items = person.items()\n",
    "\n",
    "print(keys)\n",
    "print(values)\n",
    "print(items)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name : Asabenh\n",
      "age : 250\n",
      "country : Finland\n",
      "city : Helsinki\n",
      "job : instructor and developer\n",
      "skills : ['HTML', 'CSS', 'JavaScript', 'Python', 'Node']\n",
      "is_married : True\n"
     ]
    }
   ],
   "source": [
    "for k, v in items:\n",
    "    print(k,':', v)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{1: 1}, {2: 4}, {3: 9}, {4: 16}, {5: 25}]"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "numbers = [1, 2, 3,4,5]\n",
    "[{n:n * n} for n in numbers]  # maping using list comprehension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'Asabeneh': 8}, {'Brook': 5}, {'David': 5}, {'Martha': 6}]"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = ['Asabeneh','Brook','David','Martha']\n",
    "[{name:len(name)} for name in names] # Mapping using list comprehension"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Unpacking lists, tupples"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Unpacking tuples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "Asabeneh\n",
      "Yetayeh\n",
      "Finland\n"
     ]
    }
   ],
   "source": [
    "one, two, three = (1, 2,3)\n",
    "print(one)\n",
    "print(two)\n",
    "print(three)\n",
    "\n",
    "first_name, last_name, country = ('Asabeneh','Yetayeh','Finland')\n",
    "print(first_name)\n",
    "print(last_name)\n",
    "print(country)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Unpacking lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabeneh\n",
      "Eyob\n",
      "['David', 'Lidiya', 'Woyneshet', 'Yetayeh']\n",
      "1\n",
      "2\n",
      "3\n",
      "[4, 5, 6, 7, 8, 9]\n",
      "10\n",
      "Germany\n",
      "France\n",
      "Belgium\n",
      "Sweden\n",
      "['Denmark', 'Finland', 'Norway', 'Iceland']\n",
      "Estonia\n"
     ]
    }
   ],
   "source": [
    "# First Example about unpacking list\n",
    "names = ['Asabeneh','Eyob','David','Lidiya', 'Woyneshet','Yetayeh']\n",
    "first_person, second_person, *rest = names\n",
    "print(first_person)\n",
    "print(second_person)\n",
    "print(rest)\n",
    "\n",
    "# Second Example about unpacking list\n",
    "first, second, third,*rest, tenth = [1,2,3,4,5,6,7,8,9,10]\n",
    "print(first)\n",
    "print(second)\n",
    "print(third)\n",
    "print(rest)\n",
    "print(tenth)\n",
    "\n",
    "# Third Example about unpacking list\n",
    "countries = ['Germany', 'France','Belgium','Sweden','Denmark','Finland','Norway','Iceland','Estonia']\n",
    "gr, fr, bg, sw, *scandic, es = countries\n",
    "print(gr)\n",
    "print(fr)\n",
    "print(bg)\n",
    "print(sw)\n",
    "print(scandic)\n",
    "print(es)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">SET </h1>\n",
    "\n",
    "Creating a set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 2, 3, 4, 5}\n",
      "5\n",
      "{1, 2, 3, 4, 5, 6, 7}\n",
      "7\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "s = set()\n",
    "s.add(1) # adding value to a set\n",
    "s.add(2)\n",
    "s.add(3)\n",
    "s.add(4)\n",
    "s.add(5)\n",
    "print(s)\n",
    "print(len(s))\n",
    "\n",
    "nums = [1, 2,2,3,4,5,4,6,7,6]\n",
    "numbers = set(nums)\n",
    "print(numbers)\n",
    "print(len(numbers))\n",
    "for n in numbers:\n",
    "    print(n)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">FUNCTIONS</h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function without parameter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabeneh Yetayeh\n",
      "5\n",
      "Asabeneh Yetayeh\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "def generate_full_name ():\n",
    "    first_name = 'Asabeneh'\n",
    "    last_name = 'Yetayeh'\n",
    "    space = ' '\n",
    "    full_name = first_name + space + last_name\n",
    "    print(full_name)\n",
    "\n",
    "generate_full_name () # calling a function\n",
    "\n",
    "def add_two_numbers ():\n",
    "    num_one = 2\n",
    "    num_two = 3\n",
    "    total = num_one + num_two\n",
    "    print(total)\n",
    "add_two_numbers() # call the functionK\n",
    "\n",
    "# Function can also return values, if a function doen't return values the value of the function is None\n",
    "# Lets rewrite the above functions using return\n",
    "# From now on, we return value to a function instead of priting it\n",
    "\n",
    "def generate_full_name ():\n",
    "    first_name = 'Asabeneh'\n",
    "    last_name = 'Yetayeh'\n",
    "    space = ' '\n",
    "    full_name = first_name + space + last_name\n",
    "    return full_name\n",
    "print(generate_full_name())\n",
    "\n",
    "def add_two_numbers ():\n",
    "    num_one = 2\n",
    "    num_two = 3\n",
    "    total = num_one + num_two\n",
    "    return total\n",
    "print(add_two_numbers())\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function with one parameter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Asabeneh, welcome to Python for Everyone!\n",
      "100\n",
      "4\n",
      "314.0\n"
     ]
    }
   ],
   "source": [
    "def greetings (name):\n",
    "    message = name + ', welcome to Python for Everyone!'\n",
    "    return message\n",
    "\n",
    "print(greetings('Asabeneh'))\n",
    "\n",
    "def add_ten(num):\n",
    "    ten = 10\n",
    "    return num + ten\n",
    "\n",
    "print(add_ten(90))\n",
    "    \n",
    "\n",
    "def square_number(x):\n",
    "    return x * x\n",
    "\n",
    "print(square_number(2))\n",
    "\n",
    "def area_of_circle (r):\n",
    "    PI = 3.14\n",
    "    area = PI * r ** 2\n",
    "    return area\n",
    "\n",
    "print(area_of_circle(10))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function with two parameter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Full Name:  Asabeneh Yetayeh\n",
      "Sum of two numbers:  10\n",
      "Age:  200\n",
      "Weight of an object in Newton:  981.0 N\n"
     ]
    }
   ],
   "source": [
    "def generate_full_name (first_name, last_name):\n",
    "    space = ' '\n",
    "    full_name = first_name + space + last_name\n",
    "    return full_name\n",
    "print('Full Name: ', generate_full_name('Asabeneh','Yetayeh'))\n",
    "\n",
    "def sum_two_numbers (num_one, num_two):\n",
    "    sum = num_one + num_two\n",
    "    return sum\n",
    "print('Sum of two numbers: ', sum_two_numbers(1, 9))\n",
    "\n",
    "def calculate_age (current_year, birth_year):\n",
    "    age = current_year - birth_year\n",
    "    return age;\n",
    "\n",
    "print('Age: ', calculate_age(2019, 1819))\n",
    "\n",
    "def weight_of_object (mass, gravity):\n",
    "    weight = str(mass * gravity)+ ' N' # the value has to be changed to string first\n",
    "    return weight\n",
    "print('Weight of an object in Newton: ', weight_of_object(100, 9.81))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function with arbitrary number of paramters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "55\n"
     ]
    }
   ],
   "source": [
    "def sum_of_numbers(*args):\n",
    "    s = 0;\n",
    "    for i in args:\n",
    "        s = s + i\n",
    "    return s\n",
    "print(sum_of_numbers(1,2,3))\n",
    "print(sum_of_numbers(1,2,3, 4,5,6,7,8,9,10))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function with default parameter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Anonymous, welcome to Python for Everyone!\n",
      "Asabeneh, welcome to Python for Everyone!\n",
      "Asabeneh Yetayeh\n",
      "David Smith\n",
      "Age:  200\n",
      "Weight of an object in Newton:  981.0 N\n",
      "Weight of an object in Newton:  162.0 N\n"
     ]
    }
   ],
   "source": [
    "def greetings (name = 'Anonymous'):\n",
    "    message = name + ', welcome to Python for Everyone!'\n",
    "    return message\n",
    "\n",
    "print(greetings())\n",
    "print(greetings('Asabeneh'))\n",
    "\n",
    "def generate_full_name (first_name = 'Asabeneh', last_name = 'Yetayeh'):\n",
    "    space = ' '\n",
    "    full_name = first_name + space + last_name\n",
    "    return full_name\n",
    "\n",
    "\n",
    "\n",
    "print(generate_full_name())\n",
    "print(generate_full_name('David','Smith'))\n",
    "\n",
    "def calculate_age (birth_year,current_year = 2019):\n",
    "    age = current_year - birth_year\n",
    "    return age;\n",
    "print('Age: ', calculate_age(1819))\n",
    "\n",
    "\n",
    "def weight_of_object (mass, gravity = 9.81):\n",
    "    weight = str(mass * gravity)+ ' N' # the value has to be changed to string first\n",
    "    return weight\n",
    "print('Weight of an object in Newton: ', weight_of_object(100)) # 9.81 gravity at the surface of Earth\n",
    "print('Weight of an object in Newton: ', weight_of_object(100, 1.62)) # gravit at surface of Moon\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function with default parameter and aribtrary number of parameters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Team-1\n",
      "Asabeneh\n",
      "Brook\n",
      "David\n",
      "Eyob\n"
     ]
    }
   ],
   "source": [
    "def generate_groups (team,*args):\n",
    "    print(team)\n",
    "    for i in args:\n",
    "        print(i)\n",
    "generate_groups('Team-1','Asabeneh','Brook','David','Eyob')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Function as parameter of other function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n"
     ]
    }
   ],
   "source": [
    "#You can pass functions around as parameters\n",
    "def square_number (n):\n",
    "    return n * n\n",
    "def do_something(f, x):\n",
    "    return f(x)\n",
    "\n",
    "print(do_something(square_number, 3))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Lamda Function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "27\n"
     ]
    }
   ],
   "source": [
    "#Lambda functions let you inline simple functions\n",
    "print(do_something(lambda x: x * x * x, 3))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercises\n",
    "\n",
    "1. Declare a function _full_name_ and it print out your full name.\n",
    "1. Declare a function _full_name_ and now it takes firstName, lastName as a parameter and it returns your full - name.\n",
    "1. Declare a function _add_two_numbers_ and it takes two two parameters and it returns sum.\n",
    "1. An area of a rectangle is calculated as follows: _area = lenght x width_. Write a function which calculates _area_of_rectangle_.\n",
    "1. A perimeter of a rectangle is calculated as follows: _perimeter= 2x(lenght + width)_. Write a function which calculates _perimeter_of_rectangle_.\n",
    "1. A volume of a rectangular prism is calculated as follows: _volume = lenght x width x height_. Write a function which calculates _volume_of_rect_prism_.\n",
    "1. Area of a circle is calculated as follows: _area = π x r x r_. Write a function which calculates _area_of_circle_\n",
    "1. Circumference of a circle is calculated as follows: _circumference = 2πr_. Write a function which calculates _circum_of_circle\n",
    "1. Density of a substance is calculated as follows:_density= mass/volume_. Write a function which calculates _density_.\n",
    "1. Speed is calculated by dividing the total distance covered by a moving object divided by the total amount of time taken. Write a fucntion which calculates a speed of a moving object, _speed_.\n",
    "1. Weight of a substance is calculated as follows: _weight = mass x gravity_. Write a function which calculates _weight_.\n",
    "1. Temperature in oC can be converted to oF using this formula: _oF = (oC x 9/5) + 32_. Write a function which converst oC to oF _convert_celcius_to_fahrenheit_.\n",
    "1. Body mass index(BMI) is calculated as follows: _bmi = weight in Kg / (height x height) in m2_. Write a function which calculates _bmi_. BMI is used to broadly define different weight groups in adults 20 years old or older.Check if a person is _underweight, normal, overweight_ or _obsese_ based the information given below.\n",
    "   - The same groups apply to both men and women.\n",
    "   - _Underweight_: BMI is less than 18.5\n",
    "   - _Normal weight_: BMI is 18.5 to 24.9\n",
    "   - _Overweight_: BMI is 25 to 29.9\n",
    "   - _Obese_: BMI is 30 or more\n",
    "1. Write a function called _check-season_, it takes a month parameter and returns the season:Autumn, Winter, Spring or Summer.\n",
    "1. Linear equation is calculated as follows: _ax + b = c_. Write a function which calculates value of a linear equation, _solve_linear_equation_.\n",
    "1. Quadratic equation is calculated as follows: _ax2 + bx + c = 0_. Write a function which calculates value or values of a quadratic equation, _solve_quadratic_equation_.\n",
    "1. Declare a function name _print_list. It takes list as a parameter and it prints out each element of the list.\n",
    "1. Declare a functin name _swap_values_. This function swaps value of x to y.\n",
    "   ```python\n",
    "       swap_values(3, 4) # x => 4, y=>3\n",
    "       swap_values(4, 5) # x = 5, y = 4\n",
    "   ```\n",
    "1. Declare a function name _reverse_list_. It takes array as a parameter and it returns the reverse of the array (dont’ use method).\n",
    "   ```python\n",
    "       pirnt(reverseArray([1, 2, 3, 4, 5]))\n",
    "       # [5, 4, 3, 2, 1]\n",
    "       print(reverseArray([\"A\", \"B\", \"C\"]))\n",
    "       # [\"C\", \"B\", \"A\"]\n",
    "   ```\n",
    "1. Declare a function name _capitalize_list_items_. It takes list as a parameter and it returns the capitalized list of the elements\n",
    "1. Declare a function name _add_item. It takess an item parameter and it returns a list after adding the element\n",
    "1. Declare a function name _remove_tem_. It takes an index parameter and it returns a list after removing an element\n",
    "1. Declare a function name _sum_of_numbers_. It takes a number parameter and it adds all the numbers in that range.\n",
    "1. Declare a function name _sum_of_odds_. It takes a number parameter and it adds all the odd numbers in that - range.\n",
    "1. Declare a function name _sum_of_even_. It takes a number parameter and it adds all the even numbers in that - range.\n",
    "1. Declare a function name evens_and_odds . It takes a positive integer as parameter and it counts number of evens and odds in the number.\n",
    "   ```python\n",
    "       print(evens_and_odds(100))\n",
    "       # The number of odds are 50.\n",
    "       # The number of evens are 51.\n",
    "   ```\n",
    "1. Write a funcition which takes any number of arguments and return the sum of the arguments\n",
    "   ```js\n",
    "   sum_all_numbers(1, 2, 3); // -> 6\n",
    "   sum_all_numbers(1, 2, 3, 4); // -> 10\n",
    "   ```\n",
    "1. Writ a function which generates a _random_user_id_.\n",
    "1. Write a function which generates a _random_MAC_address_\n",
    "1. Declare a function name _random_hexa_gen_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.\n",
    "   ```python\n",
    "       print(random_hexa_gen());\n",
    "      # '#ee33df'\n",
    "   ```\n",
    "1. Declare a function name _user_id_gen_. When this function is called it generates seven character id. The function return the id.\n",
    "   ```python\n",
    "       print(user_id_gen());\n",
    "       # 41XTDbE\n",
    "   ```\n",
    "1. Modify question number above . Declare a function name _user_id_gen_by_user_. It doesn’t take any parameter but it takes two inputs using input(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated.\n",
    "   ```python\n",
    "   user_id_gen_by_user()\n",
    "   \"kcsy2\n",
    "   SMFYb\n",
    "   bWmeq\n",
    "   ZXOYh\n",
    "   2Rgxf\n",
    "   \"\n",
    "    user_id_gen_by_user()\n",
    "   \"1GCSgPLMaBAVQZ26\n",
    "   YD7eFwNQKNs7qXaT\n",
    "   ycArC5yrRupyG00S\n",
    "   UbGxOFI7UXSWAyKN\n",
    "   dIV0SSUTgAdKwStr\n",
    "   \"\n",
    "   ```\n",
    "1. Write a function name _rgb_color_gen_ and it generates rgb colors.\n",
    "   ```python\n",
    "       print(rgb_color_gen())\n",
    "       # rgb(125,244,255)\n",
    "   ```\n",
    "1. Write a function ***list_of_hexa_colors*** which return any number of hexadecimal colors in an array.\n",
    "2. Write a function ***list_of_rgb_colors*** which return any number of RGB colors in an array.\n",
    "3. Write a function ***convert_hexa_to_rgb*** which converts hexa color to rgb and it returns an rgb color.\n",
    "4. Write a function ***convert_rgb_to_hexa** which converts rgb to hexa color  and it returns an hexa color.\n",
    "5. Write a function ***generate_colors*** which can generate any number of hexa or rgb colors. \n",
    "    ```python\n",
    "          generate_colors('hexa', 3)\n",
    "          # ['#a3e12f','#03ed55','#eb3d2b']\n",
    "          generate_colors('hexa', 1)\n",
    "          # '#b334ef'\n",
    "\n",
    "          generate_colors('rgb', 3)\n",
    "          # ['rgb(5, 55, 175','rgb(50, 105, 100','rgb(15, 26, 80']\n",
    "          generate_colors('rgb', 1)\n",
    "          # 'rgb(33,79, 176)'\n",
    "\n",
    "    ```\n",
    "6. Call your function _shuffle_list, it takes a list as a parameter and it returns a shuffled list\n",
    "7. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number\n",
    "8. Call your function _is_empty_, it takes a parameter and it checks if it is empty or not\n",
    "10. Write a function called _sum_of_list_items_, it takes a list parameter and return the sum of all the items. Check if all the list items are number types. If not give return reasonable feedback.\n",
    "11. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback.\n",
    "12. Write a function called _modify_list_ takes list as parameter and modifies the fifth element of the list and return the list. If the list length is less than five it return 'item not found'.\n",
    "      ```python\n",
    "          print(modifyArray([\"Avocado\", \"Tomato\", \"Potato\",\"Mango\", \"Lemon\",\"Carrot\"]);\n",
    "          # →[\"Avocado\", \"Tomato\", \"Potato\",\"Mango\", \"LEMON\", \"Carrot\"]\n",
    "          print(modifyArray([\"Google\", \"Facebook\",\"Apple\", \"Amazon\",\"Microsoft\",  \"IBM\"]);\n",
    "          # →[\"Google\", \"Facebook\",\"Apple\", \"Amazon\",\"MICROSOFT\",  \"IBM\"]\n",
    "          print(modifyArray([\"Google\", \"Facebook\",\"Apple\", \"Amazon\"]);\n",
    "          # →\"Not Found\"\n",
    "      ```\n",
    "13. Write a function called *is_prime*, which checks if a number is prime number.\n",
    "14. Write a functions which checks if all items are unique in the array.\n",
    "15. Write a function which checks if all the itmes of the array are the same data type.\n",
    "1. JavaScript variable name does not support special characters or symbols execpt $ or _. Write a function ***is_valid_variable** which check if a variable is valid or invlaid variable.\n",
    "16. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">CLASSES</h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">REGULAR EXPRESSONS</h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">MODULES</h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Importing Modules"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.4142135623730951\n",
      "9.0\n",
      "True\n",
      "3.141592653589793\n",
      "2.718281828459045\n",
      "3.141592653589793\n",
      "2.718281828459045\n",
      "6.283185307179586\n",
      "[22.76977213 31.19118012 31.39357782 28.82041376 18.95246175 33.6695274\n",
      " 22.31571545 21.39637955 28.40572587 24.38512071]\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "import re\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import urllib3\n",
    "import lxml\n",
    "\n",
    "print(math.sqrt(2))\n",
    "print(math.pow(3,2))\n",
    "print(math.pow(3,2) == 3 ** 2)\n",
    "print(math.pi)\n",
    "print(math.e)\n",
    "# constantcs\n",
    "pi = math.pi\n",
    "e = math.e\n",
    "t = math.tau # 2pi\n",
    "\n",
    "print(pi)\n",
    "print(e)\n",
    "print(t)\n",
    "\n",
    "\n",
    "A = np.random.normal(25, 5.0, 10)\n",
    "print (A)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">NUMPY<h1>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0 1 2]\n",
      " [3 4 5]]\n",
      "1\n",
      "[0 1 2 3 4 5 6 7 8 9]\n",
      "6\n",
      "[0 1 2 3 4 5]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# Creating an list using np.array\n",
    "\n",
    "x = np.array([0,1,2,3,4,5])\n",
    "print(x.reshape(2,3))\n",
    "print(x.ndim)\n",
    "y = np.arange(10)\n",
    "print(y)\n",
    "print(len(x))\n",
    "print(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">PANDAS<h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1 align=\"center\" style=\"color:#306998;font-size:64px;\">Challenges Coming ...<h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write python comment\n",
    "Declare different varaibles\n",
    "Check different data tyypes\n",
    "Concatinate strings\n",
    "Write some code that creates a list of integers, \n",
    "loops through each element of the list, \n",
    "and only prints out even numbers!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]\n"
     ]
    }
   ],
   "source": [
    "list_nums = range(100);\n",
    "print(list(list_nums))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sum_of_evens_and_sum_of_odds (n):\n",
    "    numbers = range(n)\n",
    "    evens_sum = 0;\n",
    "    odds_sum = 0;\n",
    "    for n in numbers:\n",
    "        if n % 2 == 0 :\n",
    "            evens_sum = evens_sum + n\n",
    "        else:\n",
    "            odds_sum = odds_sum + n;\n",
    "    return [evens_sum, odds_sum]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2550, 2500]"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum_of_evens_and_sum_of_odds(101)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}