-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.html
More file actions
3966 lines (3827 loc) · 252 KB
/
README.html
File metadata and controls
3966 lines (3827 loc) · 252 KB
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
<!DOCTYPE html><html><head>
<title>README</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="file:///c:\Users\bryan\.vscode-insiders\extensions\shd101wyy.markdown-preview-enhanced-0.6.0\node_modules\@shd101wyy\mume\dependencies\katex\katex.min.css">
<style>
/**
* prism.js Github theme based on GitHub's theme.
* @author Sam Clarke
*/
code[class*="language-"],
pre[class*="language-"] {
color: #333;
background: none;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.4;
-moz-tab-size: 8;
-o-tab-size: 8;
tab-size: 8;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
/* Code blocks */
pre[class*="language-"] {
padding: .8em;
overflow: auto;
/* border: 1px solid #ddd; */
border-radius: 3px;
/* background: #fff; */
background: #f5f5f5;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
background: #f5f5f5;
}
.token.comment,
.token.blockquote {
color: #969896;
}
.token.cdata {
color: #183691;
}
.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
color: #333;
}
.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
color: #a71d5d;
}
.token.string,
.token.url,
.token.regex,
.token.attr-value {
color: #183691;
}
.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
color: #0086b3;
}
.token.tag,
.token.selector,
.token.prolog {
color: #63a35c;
}
.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
color: #795da3;
}
.token.entity {
cursor: help;
}
.token.title,
.token.title .token.punctuation {
font-weight: bold;
color: #1d3e81;
}
.token.list {
color: #ed6a43;
}
.token.inserted {
background-color: #eaffea;
color: #55a532;
}
.token.deleted {
background-color: #ffecec;
color: #bd2c00;
}
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
/* JSON */
.language-json .token.property {
color: #183691;
}
.language-markup .token.tag .token.punctuation {
color: #333;
}
/* CSS */
code.language-css,
.language-css .token.function {
color: #0086b3;
}
/* YAML */
.language-yaml .token.atrule {
color: #63a35c;
}
code.language-yaml {
color: #183691;
}
/* Ruby */
.language-ruby .token.function {
color: #333;
}
/* Markdown */
.language-markdown .token.url {
color: #795da3;
}
/* Makefile */
.language-makefile .token.symbol {
color: #795da3;
}
.language-makefile .token.variable {
color: #183691;
}
.language-makefile .token.builtin {
color: #0086b3;
}
/* Bash */
.language-bash .token.keyword {
color: #0086b3;
}
/* highlight */
pre[data-line] {
position: relative;
padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
position: absolute;
top: 0;
left: 0;
background-color: transparent;
display: block;
width: 100%;
}
pre[data-line] .line-highlight {
position: absolute;
left: 0;
right: 0;
padding: inherit 0;
margin-top: 1em;
background: hsla(24, 20%, 50%,.08);
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
pointer-events: none;
line-height: inherit;
white-space: pre;
}
pre[data-line] .line-highlight:before,
pre[data-line] .line-highlight[data-end]:after {
content: attr(data-start);
position: absolute;
top: .4em;
left: .6em;
min-width: 1em;
padding: 0 .5em;
background-color: hsla(24, 20%, 50%,.4);
color: hsl(24, 20%, 95%);
font: bold 65%/1.5 sans-serif;
text-align: center;
vertical-align: .3em;
border-radius: 999px;
text-shadow: none;
box-shadow: 0 1px white;
}
pre[data-line] .line-highlight[data-end]:after {
content: attr(data-end);
top: auto;
bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% - 300px);padding:2em calc(50% - 457px - 150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/* https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */
</style>
</head>
<body for="html-export">
<div class="mume markdown-preview ">
<h1 class="mume-header" id="python-data-structures-repo-website">Python Data Structures Repo & Website</h1>
<h1 class="mume-header" id="table-of-contents">Table of contents</h1>
<ul>
<li><a href="README.md">Python Data Structures Repo & Website</a></li>
</ul>
<h2 class="mume-header" id="main-curriculum">MAIN-Curriculum</h2>
<ul>
<li><a href="main-curriculum/youtube.md">Youtube</a></li>
<li><a href="main-curriculum/curriculum.md">Curriculum</a></li>
</ul>
<hr>
<ul>
<li><a href="projects-of-python-installation-and-packaging.md">projects of Python installation and packaging</a></li>
<li><a href="running-list-of-notes.md">Running List Of Notes</a></li>
<li><a href="aux-resources.md">Aux Resources</a></li>
<li><a href="untitled.md">Python Data Structures Repo & Website</a></li>
<li><a href="built-in-functions.md">Built-in Functions</a></li>
</ul>
<h2 class="mume-header" id="practice">practice</h2>
<ul>
<li><a href="practice/problems-w-solutions.md">Problems w Solutions</a></li>
<li><a href="practice/exercises.md">Exercises</a></li>
<li><a href="practice/exercises-1.md">Exercises</a></li>
</ul>
<h2 class="mume-header" id="embeds">Embeds</h2>
<ul>
<li><a href="embeds/trinket.md">Trinket</a></li>
<li><a href="embeds/repl.it.md">Repl.it</a></li>
</ul>
<h2 class="mume-header" id="resources">Resources</h2>
<ul>
<li><a href="resources/my-python-ds-websites.md">My Python DS Websites</a></li>
<li><a href="resources/reference-materials/README.md">Reference Materials</a>
<ul>
<li><a href="resources/reference-materials/appendix.md">Appendix</a></li>
<li><a href="resources/reference-materials/errors.md">Errors</a></li>
<li><a href="resources/reference-materials/python-keywords.md">Python Keywords</a></li>
</ul>
</li>
<li><a href="resources/intro-2-python3/README.md">Intro 2 Python3</a>
<ul>
<li><a href="resources/intro-2-python3/untitled.md">Untitled</a></li>
</ul>
</li>
<li><a href="resources/stdlib.md">STDLib</a></li>
<li><a href="resources/data-structures.md">Data Structures</a></li>
<li><a href="resources/links.md">Links</a></li>
<li><a href="resources/python-glossary.md">Python Glossary</a></li>
<li><a href="resources/repositories.md">Repositories</a></li>
<li><a href="resources/python-cheat-sheet.md">Python Cheat Sheet</a></li>
</ul>
<h2 class="mume-header" id="reference">reference</h2>
<ul>
<li><a href="reference/untitled.md">Untitled</a></li>
</ul>
<h2 class="mume-header" id="python-language">python-language</h2>
<ul>
<li><a href="python-language/general-notes-on-graphs/README.md">General Notes On Graphs</a>
<ul>
<li><a href="python-language/general-notes-on-graphs/untitled.md">Untitled</a></li>
</ul>
</li>
<li><a href="python-language/classes.md">Classes</a></li>
<li><a href="python-language/untitled.md">Collections In Python</a></li>
</ul>
<h2 class="mume-header" id="misc">misc</h2>
<ul>
<li><a href="misc/d2.md">Python Problems & Solutions For Beginners</a></li>
<li><a href="misc/pipenv-and-virtual-environments.md">Pipenv & Virtual Environments</a></li>
<li><a href="misc/about-python.md">About Python</a></li>
<li><a href="misc/misc.md">Misc</a></li>
<li><a href="misc/python-problems-and-solutions-1.md">Beginners Guide To Python</a></li>
<li><a href="misc/numbers.md">Numbers</a></li>
</ul>
<h2 class="mume-header" id="wk-16">Wk-16</h2>
<ul>
<li><a href="wk-16/past-material.md">Past Material</a></li>
</ul>
<hr>
<ul>
<li><a href="youtube-1.md">Youtube</a></li>
<li><a href="d1.md">D1</a></li>
<li><a href="d2.md">D2</a></li>
<li><a href="d3.md">D3</a></li>
<li><a href="untitled-1.md">D4</a></li>
<li><a href="how-to-reverse-a-stack.md">How To Reverse A Stack</a></li>
</ul>
<h2 class="mume-header" id="wk-20-notes">Wk-20-Notes</h2>
<ul>
<li><a href="wk-20-notes/generate-a-graph.md">Generate a graph</a></li>
<li><a href="wk-20-notes/d1-notes.md">D1 Notes</a></li>
<li><a href="wk-20-notes/d3.md">D3</a></li>
<li><a href="wk-20-notes/sprint-prep.md">Sprint Prep</a></li>
</ul>
<h2 class="mume-header" id="wk-19">WK-19</h2>
<ul>
<li><a href="wk-19/untitled-1.md">D3</a></li>
<li><a href="wk-19/untitled.md">D1 - Linked Lists & BigO</a></li>
<li><a href="wk-19/d2.md">D2</a></li>
<li><a href="wk-19/untitled-2.md">D4</a></li>
</ul>
<h2 class="mume-header" id="wk-20">WK-20</h2>
<ul>
<li><a href="wk-20/d1.md">D3</a></li>
<li><a href="wk-20/untitled.md">D2</a></li>
<li><a href="wk-20/d4.md">D4</a></li>
</ul>
<h2 class="mume-header" id="dev-enviorment-setup">dev-enviorment-setup</h2>
<ul>
<li><a href="dev-enviorment-setup/virtual-environment-setup.md">Virtual Environment Setup:</a></li>
<li><a href="dev-enviorment-setup/installing-stand-alone-command-line-tools.md">Installing stand alone command line tools</a></li>
<li><a href="dev-enviorment-setup/pip.md">Pip</a></li>
</ul>
<h2 class="mume-header" id="guides-n-tutorials">guides-n-tutorials</h2>
<ul>
<li><a href="guides-n-tutorials/untitled.md">Complete Beginner's Guide</a></li>
</ul>
<p>{% tabs %}<br>
{% tab title="Blog" %}</p>
<p>{% tab title="Algorithms" %}<br>
{% embed url="<a href="https://codesandbox.io/s/ds-algo-forked-iezyk?file=/index.html">https://codesandbox.io/s/ds-algo-forked-iezyk?file=/index.html</a>" caption="" %}<br>
{% endtab %}</p>
<p>{% tab title="Awesome Find:" %}<br>
Awesome Find:</p>
<p>{% embed url="<a href="https://codesandbox.io/s/ds-algo-forked-ysri0">https://codesandbox.io/s/ds-algo-forked-ysri0</a>" %}<br>
{% endtab %}</p>
<p>{% tab title="DS Website" %}<br>
{% embed url="<a href="https://codesandbox.io/s/s2y91">https://codesandbox.io/s/s2y91</a>" %}<br>
{% endtab %}</p>
<p>{% tab title="My Blog" %}<br>
{% embed url="<a href="https://codesandbox.io/s/c1qdv">https://codesandbox.io/s/c1qdv</a>" %}<br>
{% endtab %}</p>
<p>{% tab title="CS-Unit" %}<br>
{% embed url="<a href="https://codesandbox.io/s/e754i">https://codesandbox.io/s/e754i</a>" %}<br>
{% endtab %}</p>
<p>{% tab title="" %}<br>
<a href="https://codesandbox.io/s/ys5bq">https://codesandbox.io/s/ys5bq</a></p>
<p>{% embed url="<a href="https://codesandbox.io/s/ys5bq">https://codesandbox.io/s/ys5bq</a>" %}<br>
{% endtab %}<br>
{% endtabs %}</p>
<p>Python syntax was made for readability, and easy editing. For example, the python language uses a <code>:</code> and indented code, while javascript and others generally use <code>{}</code> and indented code.</p>
<p>Lets create a <a href="https://repl.it/languages/python3">python 3</a> repl, and call it <em>Hello World</em>. Now you have a blank file called <em><a href="http://main.py">main.py</a></em>. Now let us write our first line of code:</p>
<p><em><a href="http://helloworld.py">helloworld.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">print('Hello world!')
</pre><blockquote>
<p>Brian Kernighan actually wrote the first “Hello, World!” program as part of the documentation for the BCPL programming language developed by Martin Richards.</p>
</blockquote>
<p>Now, press the run button, which obviously runs the code. If you are not using replit, this will not work. You should research how to run a file with your text editor.</p>
<p>If you look to your left at the console where hello world was just printed, you can see a <code>></code>, <code>>>></code>, or <code>$</code> depending on what you are using. After the prompt, try typing a line of code.</p>
<pre data-role="codeBlock" data-info="text" class="language-text">Python 3.6.1 (default, Jun 21 2017, 18:48:35)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
> print('Testing command line')
Testing command line
> print('Are you sure this works?')
Are you sure this works?
>
</pre><p>The command line allows you to execute single lines of code at a time. It is often used when trying out a new function or method in the language.</p>
<p>Another cool thing that you can generally do with all languages, are comments. In python, a comment starts with a <code>#</code>. The computer ignores all text starting after the <code>#</code>.</p>
<p><em><a href="http://shortcom.py">shortcom.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text"># Write some comments!
</pre><p>If you have a huge comment, do <strong>not</strong> comment all the 350 lines, just put <code>'''</code> before it, and <code>'''</code> at the end. Technically, this is not a comment but a string, but the computer still ignores it, so we will use it.</p>
<p><em><a href="http://longcom.py">longcom.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">'''
Dear PYer,
I am confused about how you said you could use triple quotes to make
SUPER
LONG
COMMENTS
!
I am wondering if this is true,
and if so,
I am wondering if this is correct.
Could you help me with this?
Thanks,
Random guy who used your tutorial.
'''
print('Testing')
</pre><p>Unlike many other languages, there is no <code>var</code>, <code>let</code>, or <code>const</code> to declare a variable in python. You simply go <code>name = 'value'</code>.</p>
<p><em><a href="http://vars1.py">vars1.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">x = 5
y = 7
z = x*y # 35
print(z) # => 35
</pre><p>Remember, there is a difference between integers and strings. <em>Remember: String = <code>""</code>.</em> To convert between these two, you can put an int in a <code>str()</code> function, and a string in a <code>int()</code> function. There is also a less used one, called a float. Mainly, these are integers with decimals. Change them using the <code>float()</code> command.</p>
<p><em><a href="http://vars2.py">vars2.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">x = 5
x = str(x)
b = '5'
b = int(b)
print('x = ', x, '; b = ', str(b), ';') # => x = 5; b = 5;
</pre><p>Instead of using the <code>,</code> in the print function, you can put a <code>+</code> to combine the variables and string.</p>
<p>There are many operators in python:</p>
<ul>
<li><code>+</code></li>
<li><code>-</code></li>
<li><code>/</code></li>
<li><code>*</code> These operators are the same in most languages, and allow for addition, subtraction, division, and multiplicaiton. Now, we can look at a few more complicated ones:</li>
<li><code>%</code></li>
<li><code>//</code></li>
<li><code>**</code></li>
<li><code>+=</code></li>
<li><code>-=</code></li>
<li><code>/=</code></li>
<li><code>*=</code> Research these if you want to find out more…</li>
</ul>
<p><em><a href="http://simpleops.py">simpleops.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">x = 4
a = x + 1
a = x - 1
a = x * 2
a = x / 2
</pre><p>You should already know everything shown above, as it is similar to other languages. If you continue down, you will see more complicated ones.</p>
<p><em><a href="http://complexop.py">complexop.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">a += 1
a -= 1
a *= 2
a /= 2
</pre><p>The ones above are to edit the current value of the variable.<br>
Sorry to JS users, as there is no <code>i++;</code> or anything.</p>
<blockquote>
<p>Fun Fact:<br>
The python language was named after Monty Python.</p>
</blockquote>
<p>If you really want to know about the others, view <a href="https://www.tutorialspoint.com/python/python_basic_operators.htm">Py Operators</a></p>
<p>Like the title?<br>
Anyways, a <code>'</code> and a <code>"</code> both indicate a string, but <strong>do not combine them!</strong></p>
<p><em><a href="http://quotes.py">quotes.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">x = 'hello' # Good
x = "hello" # Good
x = "hello' # ERRORRR!!!
</pre><p><em><a href="http://slicing.py">slicing.py</a></em></p>
<h3 class="mume-header" id="string-slicing">String Slicing</h3>
<p>You can look at only certain parts of the string by slicing it, using <code>[num:num]</code>.<br>
The first number stands for how far in you go from the front, and the second stands for how far in you go from the back.</p>
<pre data-role="codeBlock" data-info="text" class="language-text">x = 'Hello everybody!'
x[1] # 'e'
x[-1] # '!'
x[5] # ' '
x[1:] # 'ello everybody!'
x[:-1] # 'Hello everybod'
x[2:-3] # 'llo everyb'
</pre><h3 class="mume-header" id="methods-and-functions">Methods and Functions</h3>
<p>Here is a list of functions/methods we will go over:</p>
<ul>
<li><code>.strip()</code></li>
<li><code>len()</code></li>
<li><code>.lower()</code></li>
<li><code>.upper()</code></li>
<li><code>.replace()</code></li>
<li><code>.split()</code></li>
</ul>
<p>I will make you try these out yourself. See if you can figure out how they work.</p>
<p><em><a href="http://strings.py">strings.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">x = " Testing, testing, testing, testing "
print(x.strip())
print(len(x))
print(x.lower())
print(x.upper())
print(x.replace('test', 'runn'))
print(x.split(','))
</pre><p>Good luck, see you when you come back!</p>
<p>Input is a function that gathers input entered from the user in the command line. It takes one optional parameter, which is the users prompt.</p>
<p><em><a href="http://inp.py">inp.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">print('Type something: ')
x = input()
print('Here is what you said: ', x)
</pre><p>If you wanted to make it smaller, and look neater to the user, you could do…</p>
<p><em><a href="http://inp2.py">inp2.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">print('Here is what you said: ', input('Type something: '))
</pre><p>Running:<br>
<em><a href="http://inp.py">inp.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">Type something:
Hello World
Here is what you said: Hello World
</pre><p><em><a href="http://inp2.py">inp2.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">Type something: Hello World
Here is what you said: Hello World
</pre><p>Python has created a lot of functions that are located in other .py files. You need to import these <strong>modules</strong> to gain access to the,, You may wonder why python did this. The purpose of separate modules is to make python faster. Instead of storing millions and millions of functions, , it only needs a few basic ones. To import a module, you must write <code>input <modulename></code>. Do not add the .py extension to the file name. In this example , we will be using a python created module named random.</p>
<p><em><a href="http://module.py">module.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
</pre><p>Now, I have access to all functions in the <a href="http://random.py">random.py</a> file. To access a specific function in the module, you would do <code><module>.<function></code>. For example:</p>
<p><em><a href="http://module2.py">module2.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
print(random.randint(3,5)) # Prints a random number between 3 and 5
</pre><blockquote>
<p>Pro Tip:<br>
Do <code>from random import randint</code> to not have to do <code>random.randint()</code>, just <code>randint()</code><br>
To import all functions from a module, you could do <code>from random import *</code></p>
</blockquote>
<p>Loops allow you to repeat code over and over again. This is useful if you want to print Hi with a delay of one second 100 times.</p>
<p><strong>for Loop</strong></p>
<p>The for loop goes through a list of variables, making a seperate variable equal one of the list every time.<br>
Let’s say we wanted to create the example above.</p>
<p><em><a href="http://loop.py">loop.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">from time import sleep
for i in range(100):
print('Hello')
sleep(.3)
</pre><p>This will print Hello with a .3 second delay 100 times. This is just one way to use it, but it is usually used like this:</p>
<p><em><a href="http://loop2.py">loop2.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import time
for number in range(100):
print(number)
time.sleep(.1)
</pre><p><strong>while Loop</strong></p>
<p>The while loop runs the code while something stays true. You would put <code>while <expression></code>. Every time the loop runs, it evaluates if the expression is True. It it is, it runs the code, if not it continues outside of the loop. For example:</p>
<p><em><a href="http://while.py">while.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">while True: # Runs forever
print('Hello World!')
</pre><p>Or you could do:</p>
<p><em><a href="http://while2.py">while2.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
position = '<placeholder>'
while position != 1: # will run at least once
position = random.randint(1, 10)
print(position)
</pre><p>The if statement allows you to check if something is True. If so, it runs the code, if not, it continues on. It is kind of like a while loop, but it executes <strong>only once</strong>. An if statement is written:</p>
<p><em><a href="http://if.py">if.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
num = random.randint(1, 10)
if num == 3:
print('num is 3. Hooray!!!')
if num > 5:
print('Num is greater than 5')
if num == 12:
print('Num is 12, which means that there is a problem with the python language, see if you can figure it out. Extra credit if you can figure it out!')
</pre><p>Now, you may think that it would be better if you could make it print only one message. Not as many that are True. You can do that with an <code>elif</code> statement:</p>
<p><em><a href="http://elif.py">elif.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
num = random.randint(1, 10)
if num == 3:
print('Num is three, this is the only msg you will see.')
elif num > 2:
print('Num is not three, but is greater than 1')
</pre><p>Now, you may wonder how to run code if none work. Well, there is a simple statement called <code>else:</code></p>
<p><em><a href="http://else.py">else.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
num = random.randint(1, 10)
if num == 3:
print('Num is three, this is the only msg you will see.')
elif num > 2:
print('Num is not three, but is greater than 1')
else:
print('No category')
</pre><p>So far, you have only seen how to use functions other people have made. Let use the example that you want to print the a random number between 1 and 9, and print different text every time.<br>
It is quite tiring to type:</p>
<p>Characters: 389</p>
<p><em><a href="http://nofunc.py">nofunc.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
print(random.randint(1, 9))
print('Wow that was interesting.')
print(random.randint(1, 9))
print('Look at the number above ^')
print(random.randint(1, 9))
print('All of these have been interesting numbers.')
print(random.randint(1, 9))
print("these random.randint's are getting annoying to type")
print(random.randint(1, 9))
print('Hi')
print(random.randint(1, 9))
print('j')
</pre><p>Now with functions, you can seriously lower the amount of characters:</p>
<p>Characters: 254</p>
<p><em><a href="http://functions.py">functions.py</a></em></p>
<pre data-role="codeBlock" data-info="text" class="language-text">import random
def r(t):
print(random.randint(1, 9))
print(t)
r('Wow that was interesting.')
r('Look at the number above ^')
r('All of these have been interesting numbers.')
r("these random.randint's are getting annoying to type")
r('Hi')
r('j')
</pre><h2 class="mume-header" id="chapter-01-getting-ready-with-python">Chapter 01 - Getting Ready with Python</h2>
<h3 class="mume-header" id="installing-python-3-and-launching-python-shell">Installing Python 3, And Launching Python Shell</h3>
<p>This video should help you get up and running with Python 3</p>
<ul>
<li><a href="https://www.youtube.com/watch?v=Ji1WW4Suaww">Installing Python 3 and Launch Python Shell</a></li>
</ul>
<p>Installing Python is really a cakewalk. Search for “Python download” on <a href="http://www.google.com/">www.google.com</a>. Download the installable and install it.</p>
<p>A quick word of caution on Windows</p>
<ul>
<li>Make sure that you have the check-box “Add Python 3.6 to PATH”, checked.</li>
</ul>
<p>Once you have installed Python, you can launch the Python Shell.</p>
<ul>
<li>Windows - Launch cmd prompt by typing in ‘cmd’ command.</li>
<li>Mac or Linux - Launch up terminal.</li>
</ul>
<p>Command to launch Python 3 is different in Mac.</p>
<ul>
<li>In Mac, type in <code>python3</code></li>
<li>In other operating systems, including windows, type <code>python</code></li>
</ul>
<p>You can type code in python shell and code as well!</p>
<p>You can use <code>print(5*4)</code>, and it shows <code>20</code>.</p>
<p>You can execute the code, and the shell would immediately give you output.</p>
<p>Using the the Python Shell is an awesome way to learn Python.</p>
<h2 class="mume-header" id="chapter-02-introduction-to-python-programming">Chapter 02 - Introduction To Python Programming</h2>
<p>Most programmers find programming a lot of fun, and besides, it also gets their work done.</p>
<p>Programming mainly involves <em>problem solving</em>, where one makes use of a computer to solve a real world problem.</p>
<p>During our journey here, we will approach programming in a very different way. We will not only introduce you to the Python language, but also help you pick up essential problem solving skills.</p>
<p>As a programmer, you need to be able to look at a problem, and identify the important programming concepts relevant to solving it. Finally, you need to be able to use the language features and syntax, to express your solution on the computer. While all this looks complex, we want to make it easy for you. Together, we will tackle a variety of programming challenges, using these same steps. We will start with simple challenges <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>s</mi><mi>u</mi><mi>c</mi><mi>h</mi><mi>a</mi><mi>s</mi><mi>a</mi><mi>M</mi><mi>u</mi><mi>l</mi><mi>t</mi><mi>i</mi><mi>p</mi><mi>l</mi><mi>i</mi><mi>c</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mi>T</mi><mi>a</mi><mi>b</mi><mi>l</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">such as a Multiplication Table</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">u</span><span class="mord mathnormal">c</span><span class="mord mathnormal">ha</span><span class="mord mathnormal">s</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.10903em;">M</span><span class="mord mathnormal">u</span><span class="mord mathnormal">lt</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.01968em;">pl</span><span class="mord mathnormal">i</span><span class="mord mathnormal">c</span><span class="mord mathnormal">a</span><span class="mord mathnormal">t</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord mathnormal">ab</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span></span></span></span>, and gradually increase the difficulty level over the duration of this book.</p>
<p>Learning to program is a lot like learning to ride a bicycle. The first few steps are the most challenging ones.</p>
<p>Once you get over these initial steps, your experience will become more and more enjoyable.</p>
<p>Are you ready for your first programming challenge? Let’s get going now! We wish you all the best.</p>
<p><strong>Summary</strong></p>
<p>In this step, we:</p>
<ul>
<li>Were introduced to the concept of problem solving</li>
<li>Understood how good programmers approach problem solving</li>
</ul>
<h3 class="mume-header" id="step-01-our-first-programming-challenge">Step 01: Our First Programming Challenge</h3>
<p>Our first <em>programming challenge</em> aims to do, what every kid does in math class: read out a multiplication table. We now want to give this task to the computer. Here is the statement of our problem:</p>
<p><strong>The Print Multiplication Table Challenge <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>P</mi><mi>M</mi><mi>T</mi><mo>−</mo><mi>C</mi><mi>h</mi><mi>a</mi><mi>l</mi><mi>l</mi><mi>e</mi><mi>n</mi><mi>g</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">PMT-Challenge</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.76666em;vertical-align:-0.08333em;"></span><span class="mord mathnormal" style="margin-right:0.13889em;">PMT</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord mathnormal">ha</span><span class="mord mathnormal" style="margin-right:0.01968em;">ll</span><span class="mord mathnormal">e</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">e</span></span></span></span></strong></p>
<ol>
<li>Compute the multiplication table for <code>5</code>, with entries from <code>1</code> to <code>10</code>.</li>
<li>Display this table.</li>
</ol>
<p>The display needs to be:</p>
<p><em><strong>5 * 1 = 5</strong></em></p>
<p><em><strong>5 * 2 = 10</strong></em></p>
<p><em><strong>5 * 3 = 15</strong></em></p>
<p><em><strong>5 * 4 = 20</strong></em></p>
<p><em><strong>5 * 5 = 25</strong></em></p>
<p><em><strong>5 * 6 = 30</strong></em></p>
<p><em><strong>5 * 7 = 35</strong></em></p>
<p><em><strong>5 * 8 = 40</strong></em></p>
<p><em><strong>5 * 9 = 45</strong></em></p>
<p><em><strong>5 * 10 = 50</strong></em></p>
<p>This is the challenge. For convenience, let’s give it a label, say <em>PMT-Challenge</em>. What would be the important concepts we need to learn, to solve this challenge? The following list of concepts would be a good starting point:</p>
<ul>
<li><strong>Statements</strong></li>
<li><strong>Expressions</strong></li>
<li><strong>Variables</strong></li>
<li><strong>Literals</strong></li>
<li><strong>Conditionals</strong></li>
<li><strong>Loops</strong></li>
<li><strong>Methods</strong></li>
</ul>
<p>In the rest of this chapter, we will introduce these concepts to you, one-by-one. We will also show you how learning each concept, takes us closer to a solution to <em>PMT-Challenge</em>.</p>
<p><strong>Summary</strong></p>
<p>In this step, we:</p>
<ul>
<li>Stated our first programming challenge</li>
<li>Identified what programming concepts we need to learn, to solve this challenge</li>
</ul>
<h3 class="mume-header" id="step-02-breaking-down-_pmt-challenge_">Step 02: Breaking Down <em>PMT-Challenge</em></h3>
<p>Typically when we do programming, we have problems. Solving the problem typically need a step-by -step approach. Common sense tells us that to solve a complex problem, we break it into smaller parts, and solve each part one by one. Here is how any good programmer worth her salt, would solve a problem:</p>
<ul>
<li>Simplify the problem, by breaking it into sub-problems</li>
<li>Solve the sub-problems in stages <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>i</mi><mi>n</mi><mi>s</mi><mi>o</mi><mi>m</mi><mi>e</mi><mi>o</mi><mi>r</mi><mi>d</mi><mi>e</mi><mi>r</mi></mrow><annotation encoding="application/x-tex">in some order</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mord mathnormal">in</span><span class="mord mathnormal">so</span><span class="mord mathnormal">m</span><span class="mord mathnormal" style="margin-right:0.02778em;">eor</span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span></span></span></span>, using the language</li>
<li>Combine these solutions to get a final solution</li>
</ul>
<p>The <em>PMT-Challenge</em> is no different! Now how do we break it down, and where do we really start? Once again, your common sense will reveal a solution. As a first step, we could get the computer to calculate say, <code>5 * 3</code>. The second thing we can do, is to try and print the calculated value, in a manner similar to <code>5 * 3 = 15</code>. Then, we could repeat what we just did, to print out all the entries of the <code>5</code> multiplication table. Let’s put it down a little more formally:</p>
<p>Here is how our draft steps look like</p>
<ul>
<li>Calculate <code>5 * 3</code> and print result as <code>15</code></li>
<li>Print <code>5 * 3 = 15</code> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi><mn>15</mn><mi mathvariant="normal">‘</mi><mi>i</mi><mi>s</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>u</mi><mi>l</mi><mi>t</mi><mi>o</mi><mi>f</mi><mi>p</mi><mi>r</mi><mi>e</mi><mi>v</mi><mi>i</mi><mi>o</mi><mi>u</mi><mi>s</mi><mi>c</mi><mi>a</mi><mi>l</mi><mi>c</mi><mi>u</mi><mi>l</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi></mrow><annotation encoding="application/x-tex">`15` is result of previous calculation</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord">‘15‘</span><span class="mord mathnormal">i</span><span class="mord mathnormal">sres</span><span class="mord mathnormal">u</span><span class="mord mathnormal">lt</span><span class="mord mathnormal">o</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">p</span><span class="mord mathnormal">re</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">u</span><span class="mord mathnormal">sc</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">c</span><span class="mord mathnormal">u</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">a</span><span class="mord mathnormal">t</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span></span></span></span></li>
<li>Do this ten times, once for each table entry <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>g</mi><mi>o</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi>f</mi><mi>r</mi><mi>o</mi><mi>m</mi><mi mathvariant="normal">‘</mi><mn>1</mn><mi mathvariant="normal">‘</mi><mi>t</mi><mi>o</mi><mi mathvariant="normal">‘</mi><mn>10</mn><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">going from `1` to `10`</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal">o</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">ro</span><span class="mord mathnormal">m</span><span class="mord">‘1‘</span><span class="mord mathnormal">t</span><span class="mord mathnormal">o</span><span class="mord">‘10‘</span></span></span></span></li>
</ul>
<p>Let’s start with that kind of a game plan, and see where it takes us.</p>
<p><strong>Summary</strong></p>
<p>In this step, we:</p>
<ul>
<li>Learned that breaking down a problem into sub-problems is a great help</li>
<li>Found a way to break down the <em>PMT-Challenge</em> problem</li>
</ul>
<h3 class="mume-header" id="step-03-introducing-operators-and-expressions">Step 03: Introducing Operators And Expressions</h3>
<p>Let’s focus on solving the first sub-problem of <em>PMT-Challenge</em>, the numeric computation. We want the computer to calculate <code>5 * 5</code> for example, and print <code>25</code> for us. How do we get it to do that? That’s what we would be looking at in this step.</p>
<p><strong>Snippet-01: Introducing Operators</strong></p>
<p>Launch up Python shell. We want to calculate <code>5 * 5</code>. How do we do that?</p>
<p>Using our knowledge of school math, let’s try <code>5 X 5</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 X 5
File "< stdin >", line 1
5 X 5
^
SyntaxError: invalid syntax
</pre><p>The Python Shell hits back at us, saying “<em>invalid syntax</em>”. This is how Python complains, when it doesn’t fully understand the code you type in. Here, it says our code has a “<strong>SyntaxError</strong>”.</p>
<p>The reason why it complains, is because ‘<code>X</code>’ is not a valid <strong>operator</strong> in Python.</p>
<p>The way you can do multiplication is by using the ‘<code>*</code>’ <em>operator</em> .</p>
<p>“<em>5 into 5</em>” is achieved by the code <code>5 * 5</code>, and you can see the result <code>25</code> being printed. Similarly, <code>5 * 6</code> gives us <code>30</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 * 6
30
</pre><p>There are a wide range of other operators in Python:</p>
<ul>
<li>
<p><code>5 + 6</code> gives a result of <code>11</code>.</p>
</li>
<li>
<p><code>5 - 6</code> leads to <code>-1</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text">>>> 5 + 6
11
>>> 5 - 6
-1
</pre></li>
</ul>
<p><code>10 / 2</code>, gives an output of <code>5.0</code> . There is one interesting operator, <code>**</code>. Let’s try <code>10 ** 3</code>. We ran this code, and the result we get is <code>1000</code>. Yes you guessed right, the operator performs “to the power of”. “<code>10</code> to the power of <code>3</code>” is <code>10 * 10 * 10</code>, or <code>1000</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 10 / 2
5.0
>>> 10 ** 3
1000
</pre><p>Another interesting operator is <code>%</code>, called “<em>modulo</em>”, which computes the remainder on integer division. If we do <code>10 % 3</code>, what is the remainder when <code>10</code> is divided by <code>3</code>? <code>3 * 3</code> is <code>9</code>, and <code>10 - 9</code> is <code>1</code>, which is what <code>%</code> returns in this case.</p>
<p>Let’s look at some terminology:</p>
<ul>
<li>Whatever pieces of code we gave Python shell to run, are called <strong>expressions</strong>. So, <code>5 * 5</code>, <code>5 * 6</code> and <code>5 - 6</code> are all <em>expressions</em>. An expression is composed of <em>operators</em> and <strong>operands</strong>.</li>
<li>In the expression <code>5 * 6</code>, the two values <code>5</code> and <code>6</code> are called operands, and the <code>*</code> operator <em>operates</em> on them.</li>
<li>The values <code>5</code> and <code>6</code> are <strong>literals</strong>, because those are constants which cannot be changed.</li>
</ul>
<p>The cool thing about Python, is that you can even have expressions with multiple operators. Therefore, you can form an expression with <code>5 + 5 + 5</code>, which evaluates to <code>15</code>. This is an expression which has three operands, and two <code>+</code> operators. You can even have expressions with different types of operators, such as in <code>5 + 5 * 5</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 + 5 + 5
15
>>> 5 + 5 * 5
30
</pre><p>Try and play around with the expressions, and understand the output which results.</p>
<p><strong>Summary</strong></p>
<p>In this step, we:</p>
<ul>
<li>Learned how to give code input to the Python Shell</li>
<li>Understood that Python has a predefined set of operators</li>
<li>Used a few types of basic operators and their operands, to form expressions</li>
</ul>
<h3 class="mume-header" id="step-04-programming-exercise-in-pe-01">Step 04: Programming Exercise IN-PE-01</h3>
<p>At this stage, your smile tells us that you enjoy evaluating Python expressions. What if we tickle your mind a bit, to make sure it hasn’t fallen asleep? Here is your first programming exercise.</p>
<p><strong>Exercises</strong></p>
<ol>
<li>Write an expression to calculate the number of minutes in a day.</li>
<li>Write an expression to calculate the number of seconds in a day.</li>
</ol>
<p><strong>Note</strong></p>
<p>You need to solve these problems by yourself. If you are able to work them out, that’s fantastic! But if not, that’s part of the learning process.</p>
<p><strong>Solutions</strong></p>
<p><strong>Solution 1</strong></p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 24 * 60
1440
</pre><p>We wanted to calculate the number of minutes in a day. How do we do that? Think about this…</p>
<ul>
<li>How many number of hours are there in a day? <code>24</code>.</li>
<li>And how many minutes does each hour have? It’s <code>60</code>.</li>
<li>So if you want to find out the number of minutes in a day, it’s <code>24 * 60</code>, which is <code>1440</code>.</li>
</ul>
<p><strong>Solution 2</strong></p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 24 * 60 * 60
86400
</pre><p>How many seconds are there in a day?</p>
<ul>
<li>Let’s start with the number of hours, <code>24</code>.</li>
<li>The number of minutes in an hour is <code>60</code>, and</li>
<li>The number of seconds in a minute is <code>60</code> as well.</li>
<li>So it’s <code>24 * 60 * 60</code>, or <code>86400</code>.</li>
</ul>
<p><strong>Summary</strong></p>
<p>In this step, we:</p>
<ul>
<li>Solved a Programming Exercise involving common scenarios, using Python code involving:
<ul>
<li>Expressions</li>
<li>Operators</li>
<li>Literals</li>
</ul>
</li>
</ul>
<h3 class="mume-header" id="step-05-puzzles-on-expressions">Step 05: Puzzles On Expressions</h3>
<p>Let’s look at a few puzzles related to expressions, in this step. Before that, let’s revise some of the terminology we had learned earlier.</p>
<p><code>5 + 6 + 10</code> is an example of an expression. In this expression, <code>5</code>, <code>6</code> and <code>10</code> are operands. The <code>+</code> here is the operator. You can have multiple operators in an expression. We also did mention that the operands, namely <code>10</code>, <code>6</code> and <code>5</code>, are literals. Their values will not change.</p>
<p>Here are a few puzzles coming up, to explore aspects of expressions.</p>
<p><strong>Snippet-01: Puzzles On Expressions</strong></p>
<p>Think about what would happen when you do something of this kind: <code>5 $ 2</code>. You’re right, it would throw a <code>SyntaxError</code>. When Python does not understand the code you type in, it reports an error. Here, the expression we’re typing is <code>5 $ 2</code>, which does not make sense to Python, hence the <code>SyntaxError</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 $ 2
File "< stdin >", line 1
5 $ 2
^
SyntaxError: invalid syntax
>>> 5$2
File "< stdin >", line 1
5 $ 2
^
SyntaxError: invalid syntax
</pre><p>Let’s say we type in <code>5+6+10</code>, without any spaces between the operands, and the operators. What do you think will happen? Surprisingly, the Python Shell does calculate the value!</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5+6+10
21
</pre><p>In an expression, using spaces makes it easier for you to read it, but it’s not mandatory. <code>5 + 6 + 10</code> is easier to read than <code>5+6+10</code>, but does not make any difference to the Python compiler.</p>
<p>The next puzzle tries to evaluate <code>5 / 2</code>, which is “<code>5</code> divided by <code>2</code>”. What would be the output? <code>2.5</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5/2
2.5
</pre><p>If you’re coming from other programming languages like Java or C, this might be a surprising result. If you try this in Java for instance, you would get <code>2</code> as the output. Note that even though both operands are integers, the result of the <code>/</code> operation is a floating point value, <code>2.5</code> . Python does what is expected by a programmer!</p>
<p>The puzzle after that tries to play with <code>5 + 5 * 6</code>. What would be the result of this expression? Will it be <code>5 + 5</code> or <code>10</code>, then <code>10 * 6</code>, which is <code>60</code>? Or, will it be <code>5</code> plus <code>5 * 6</code>, which is <code>5</code> + <code>30</code>, that’s <code>35</code>?</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 + 5 * 6
35
</pre><p>The correct result is <code>35</code>.</p>
<p>Python decides this is based on the <strong>precedence</strong> of operators.</p>
<p>Operators in Python are divided into two sets as follows:</p>
<ul>
<li><code>**</code>, <code>*</code>, <code>/</code> and <code>%</code> have higher precedence, or priority.</li>
<li><code>+</code> and <code>-</code> have a lower precedence.</li>
</ul>
<p>Sub-expressions involving operators from {<code>*</code>, <code>/</code>, <code>%</code>, <code>**</code>} are evaluated before those involving operators from {<code>+</code>, <code>-</code>}</p>
<p>Let’s try another small puzzle on precedence, with <code>5 - 2 * 2</code>. What would be the result of this? Will it be <code>6</code>, or <code>1</code>? It’s <code>1</code>, because <code>*</code> has a higher precedence than <code>-</code>. Thus <code>2 * 2</code> is <code>4</code>, and <code>5 - 4</code> gives us <code>1</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 - 2 * 2
1
</pre><p>Let’s say we want to execute <code>5 - 2</code>, to give an output of <code>2</code>. How do we change the operator precedence?</p>
<p>You cannot really change the precedence, but you can add parentheses to group sub-expressions differently.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> (5 - 2) * 2
6
>>> 5 - ( 2 * 2 )
1
</pre><p>Parentheses have the highest precedence in Python, and can be used to override operator precedence. <code>(5 - 2)</code> gets calculated first, and the final result of the expression is <code>6</code>.</p>
<p>A positive thing about using parentheses is, that it makes expressions more readable. So even in situations such as <code>5 - 2 * 2</code>, where we know the result according to precedence, adding parentheses is good.</p>
<p><strong>Summary</strong></p>
<p>In this step, we went about solving a few puzzles about expressions, touching concepts such as:</p>
<ul>
<li><code>SyntaxError</code> for incorrect operators</li>
<li>White-space in expressions</li>
<li>Floating Point division by default</li>
<li>Operator Precedence</li>
<li>Using parentheses</li>
</ul>
<h3 class="mume-header" id="step-06-printing-text">Step 06: Printing Text</h3>
<p>In the previous step, we learned how to use expressions to compute values. In this step, let’s see how we can actually print multiplication table entries, that are readable by the user.</p>
<p><strong>Snippet-01: Printing Text</strong></p>
<p>How do we go about printing a complete multiplication table entry? We want to print text such as <code>5 * 6 = 30</code> . But trying to do so, as we know it, gives us a <code>SyntaxError</code>. Clearly, there is a different way to print text, as compared to an expression.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> 5 * 6 = 30
File "<stdin>", line 1
SyntaxError: can't assign to operator
</pre><p>Let’s first try to print a simple piece of text, <code>Hello</code>. Typing in this piece of code directly on Python Shell also gives us an error.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> Hello
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Hello' is not defined
</pre><p>Only expressions work that way, and <code>Hello</code> is not really an expression.</p>
<p><code>"Hello"</code> is typically called a <strong>string</strong>, and represents the text of letters <code>'H'</code>, <code>'e'</code>, <code>'l'</code>, <code>'l'</code>, <code>'o'</code>. <code>"Hello"</code> is hence different from the number <code>5</code>.</p>
<p>There are a number of in-built functions in Python to help print strings. One of these is the <code>print()</code> function. Can you just say <code>print Hello</code>?</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> print Hello
File "<stdin>", line 1
print Hello
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(Hello)?
</pre><p>The Python compiler gives you an error, that says “missing parentheses”.</p>
<p>Will <code>print(Hello)</code> work?</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> print (Hello)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Hello' is not defined
</pre><p>Nope! Again, this one failed because you need to indicate that <code>"Hello"</code> is a string.</p>
<p>How do I indicate that <code>"Hello"</code> is a string? By putting it within double quotes.</p>
<p>Let’s try <code>print ("Hello")</code></p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> print ("Hello")
Hello
>>> print("Hello")
Hello
</pre><p><code>print("Hello")</code> finally results in <code>"Hello"</code> being printed out. To be able to print <code>"Hello"</code>, the things we need to do are:</p>
<ul>
<li>Typing the method name print ,</li>
<li>open parentheses ( ,</li>
<li>Followed by a double quote " ,</li>
<li>The text Hello,</li>
<li>and another double quote " ,</li>
<li>finished off with a closed parentheses ).</li>
</ul>
<p>What we have written here is called a <strong>statement</strong>, a simple piece of code to execute. As part of this statement, we are <strong>calling</strong> a <strong>function</strong>, named <code>print()</code>.</p>
<p>What exactly are we trying to print?</p>
<p>The text <code>"Hello"</code>, which is called a <strong>parameter</strong> or <strong>argument</strong>, to <code>print()</code>.</p>
<p>Now let’s get back to what we wanted to do, which is to print <code>5 * 6 = 30</code>. The most basic version would be something of this kind, <code>print("5 * 6 = 30")</code>. Here, we are passing the entire value in the form of a string.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> print("5 * 6 = 30")
5 * 6 = 30
</pre><p>This prints the text on the console, as-is. The thing you need to understand here is, we aren’t really calculating <code>30</code> using the formula <code>5 * 6</code>, but directly putting text <code>30</code> in here. That’s called <strong>hard-coding</strong>.</p>
<p>In a later step, we will look at how to actually calculate the value and pass it in.</p>
<p><strong>Summary</strong></p>
<p>In this step, we:</p>
<ul>
<li>Understood that displaying text on the console is not the same as printing an expression value</li>
<li>Learned about the <code>print()</code> function, that is used to print text in Python.</li>
<li>Found a way to print the text <code>"5 * 6 = 30"</code> on the console, by hard-coding values in a string</li>
</ul>
<h3 class="mume-header" id="step-07-puzzles-on-utility-methods-and-strings">Step 07: Puzzles On Utility Methods, And Strings</h3>
<p>In the previous step, we learned how to print <code>5 * 6 = 30</code>. It was not a perfect solution, because we hard-coded everything. we used an in-built function named <code>print()</code>, passed a string to it, and invoked the method.</p>
<p>In this step, let’s look at a number of puzzles related to in-built methods, their parameters, and strings in general.</p>
<p>For example, let’s do <code>print("5 * 6")</code>, as in the previous step. What does this code result in?</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> print("5*6")
5*6
>>> print('5*6')
5*6
</pre><p>It just prints the string <code>"5 * 6"</code>.</p>
<p>Let’s say we try the code <code>print(5 * 6)</code>,</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> print(5*6)
30
</pre><p>Without the double quotes, <code>5 * 6</code> is an expression. What will be the output? <code>30</code>.</p>
<p>If you call <code>print()</code> with an expression argument, it prints the value of the expression. However, when we pass something within double quotes, it becomes a piece of text, printed as-is.</p>
<p>An interesting thing to note is, that in Python you can use either double-quotes <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">‘</mi><mi mathvariant="normal">"</mi><mi mathvariant="normal">‘</mi><mi>a</mi><mi>n</mi><mi>d</mi><mi mathvariant="normal">‘</mi><mi mathvariant="normal">"</mi><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">`"` and `"`</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.69444em;vertical-align:0em;"></span><span class="mord">‘"‘</span><span class="mord mathnormal">an</span><span class="mord mathnormal">d</span><span class="mord">‘"‘</span></span></span></span>, or single-quotes <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msup><mi mathvariant="normal">‘</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi mathvariant="normal">‘</mi><mi>a</mi><mi>n</mi><mi>d</mi><msup><mi mathvariant="normal">‘</mi><mo mathvariant="normal" lspace="0em" rspace="0em">′</mo></msup><mi mathvariant="normal">‘</mi></mrow><annotation encoding="application/x-tex">`'` and `'`</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.751892em;vertical-align:0em;"></span><span class="mord"><span class="mord">‘</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.751892em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord">‘</span><span class="mord mathnormal">an</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord">‘</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height:0.751892em;"><span style="top:-3.063em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">′</span></span></span></span></span></span></span></span></span><span class="mord">‘</span></span></span></span> with text values.</p>
<p>Let’s look at a few other in-built methods within Python.</p>
<p>Consider <code>abs()</code> <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>w</mi><mi>h</mi><mi>i</mi><mi>c</mi><mi>h</mi><mi>s</mi><mi>t</mi><mi>a</mi><mi>n</mi><mi>d</mi><mi>s</mi><mi>f</mi><mi>o</mi><mi>r</mi><mi>a</mi><mi>b</mi><mi>s</mi><mi>o</mi><mi>l</mi><mi>u</mi><mi>t</mi><mi>e</mi><mi>v</mi><mi>a</mi><mi>l</mi><mi>u</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">which stands for absolute value</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8888799999999999em;vertical-align:-0.19444em;"></span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">hi</span><span class="mord mathnormal">c</span><span class="mord mathnormal">h</span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal">an</span><span class="mord mathnormal">d</span><span class="mord mathnormal">s</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mord mathnormal">ab</span><span class="mord mathnormal">so</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">u</span><span class="mord mathnormal">t</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">a</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">u</span><span class="mord mathnormal">e</span></span></span></span>, a method that accepts a numeric value. You can use <code>abs(10.5)</code>, passing <code>10.5</code> as a value to it, and it prints the absolute value of <code>10</code>.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> abs 10.5
File "<stdin>", line 1
abs 10.5
^
SyntaxError: invalid syntax
>>> abs(10.5)
10.5
</pre><p>If you pass in a string value, will it work? It complains, “<code>abs()</code> function will not work with a string, it only works with numeric values”.</p>
<pre data-role="codeBlock" data-info="text" class="language-text"> >>> abs("10.5")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bad operand type for abs(): 'str'