Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd28694

Browse files
Minor Changes
1 parent 3aaa7c1 commit dd28694

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

Python_Notes_by_Saket_Savarn.ipynb

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,9 @@
413413
"source": [
414414
"<a id=\"6B Multi-line commenting in Python\"></a>\n",
415415
"<br><br><b><u>(b.) Multi-line commenting in python</u> : </b>\n",
416-
"<br>Mutli-line commenting means commenting multiple lines in one go. This is useful when you want to comment out a whole specific block of codes (multiple code statements) unlike just one or two statements. For example you can comment out a whole for loop if you think it's causing errors in your code and see if your code works with it or without it.<br><br>\n",
417-
"You can do multi-line commenting in python using triple quotes <code>\"\"\".</code>Just type everything inside the triple quotes and enclose it by them.\n",
416+
"<br>Mutli-line commenting means commenting multiple lines in one go. This is useful when you want to comment out a whole specific block of codes (multiple code statements) unlike just one or two statements. For example you can comment out a whole for-loop if you think it's causing errors in your code and see if your code works with it or without it.<br><br>\n",
417+
"You can do multi-line commenting in python using triple quotes <code>\"\"\".</code>. These triple-quotes are actually unlike # (single comments) not ignored by the python interpreter because, they aren't comments (which the interpreter ignores) but the string data-type. Tripe-quotes basically are multi-line strings which if not assigned to a variable or used in print() function converts the whole code-block to a string which isn't outputted anywhere. So this code-block acts as a commented block but in traditional sense it is not comments but string datatype. To get started, just type everything inside the triple quotes and enclose it by them.<br>\n",
418+
"<a href=\"#8C Multi-line printing in Python\">More on Multi-line printing.</a>\n",
418419
"<br>\n",
419420
"<br>\n",
420421
"Eg : \n",
@@ -614,7 +615,7 @@
614615
},
615616
{
616617
"cell_type": "code",
617-
"execution_count": 77,
618+
"execution_count": 5,
618619
"metadata": {},
619620
"outputs": [
620621
{
@@ -625,8 +626,20 @@
625626
" This is a sentence. This is a second sentence!\n",
626627
" The third sentence. This sentence is fourth.\n",
627628
" Fifth sentence is this one. \n",
628-
" \n"
629+
" \n",
630+
"What's up my friend?\n",
631+
"Nothing much dude, just chilling you know\n"
629632
]
633+
},
634+
{
635+
"data": {
636+
"text/plain": [
637+
"\"What's up my friend?\\nNothing much dude, just chilling you know\""
638+
]
639+
},
640+
"execution_count": 5,
641+
"metadata": {},
642+
"output_type": "execute_result"
630643
}
631644
],
632645
"source": [
@@ -637,7 +650,16 @@
637650
" The third sentence. This sentence is fourth.\n",
638651
" Fifth sentence is this one. \n",
639652
" \"\"\"\n",
640-
")"
653+
")\n",
654+
"\n",
655+
"st = \"\"\"What's up my friend?\n",
656+
"Nothing much dude, just chilling you know\"\"\" #Assigning multi-line strings to a variable\n",
657+
"\n",
658+
"print (st)\n",
659+
"\n",
660+
"#see how escape sequence \\n is added wherever the line breaks, which isn't visible when we use print() function\n",
661+
"# (there's a \\n before 'Nothing' in st variable)\n",
662+
"st"
641663
]
642664
},
643665
{
@@ -3983,7 +4005,7 @@
39834005
"3. <code><b>></code></b>\tIf the value of left operand is greater than the value of right operand, then condition becomes true.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Similar to !=.</li>\n",
39844006
"4. <code><b><</code></b>\tIf the value of left operand is less than the value of right operand, then condition becomes true.\n",
39854007
"5. <code><b>>=</code></b>\tIf the value of left operand is greater than or equal to the value of right operand, then condition becomes true.\n",
3986-
"6. <code><b><=</code></b>\tIf the value of left operand is less than or equal to the value of right operand, then condition becomes true.\n",
4008+
"6. <code><b><=</code></b>\tIf the value of left operand is less than or equal to the value of right operand,<br> then condition becomes true.\n",
39874009
" </pre><br><b>Eg :</b>"
39884010
]
39894011
},
@@ -4016,14 +4038,14 @@
40164038
"print (\"2 : \",90==99) #False\n",
40174039
"print (\"3 : \",99!=99) #False\n",
40184040
"print (\"4 : \",90!=99) #True\n",
4019-
"print (\"7 : \",4.8 > 4.7) #True\n",
4020-
"print (\"8 : \",4.8 > 4.8) #False\n",
4021-
"print (\"9 : \",4.8 < 2.1) #False\n",
4022-
"print (\"10 : \",2.1 < 4.8) #True\n",
4023-
"print (\"11 : \",4.8>=4.8) #True\n",
4024-
"print (\"12 : \",4.8>=4.7) #False\n",
4025-
"print (\"13 : \",1.2<=1.2) #True\n",
4026-
"print (\"14 : \",1.2<= 1.1) #False \n",
4041+
"print (\"5 : \",4.8 > 4.7) #True\n",
4042+
"print (\"6 : \",4.8 > 4.8) #False\n",
4043+
"print (\"7 : \",4.8 < 2.1) #False\n",
4044+
"print (\"8 : \",2.1 < 4.8) #True\n",
4045+
"print (\"9 : \",4.8>=4.8) #True\n",
4046+
"print (\"10 : \",4.8>=4.7) #False\n",
4047+
"print (\"11 : \",1.2<=1.2) #True\n",
4048+
"print (\"12 : \",1.2<= 1.1) #False \n",
40274049
" "
40284050
]
40294051
},
@@ -4348,6 +4370,12 @@
43484370
" #on it's own until we type-cast it to a secondary data-type like list or tuples\n",
43494371
" #or use this function with for-loop and \"in\" keyword.\n",
43504372
"\n",
4373+
"# NOTE : \n",
4374+
"#The range data-type evaluated is known as \"Lazy Evaluation\" which is a feature of python. Python instead of\n",
4375+
"#evaluating a full output (which should be a list, see next code block for list(range(n))),\n",
4376+
"#Python doesn't full evaluate the output until each loop of the for-loop is executed.\n",
4377+
"#This saves memory consumption and time-consumption though we end up with an unusable data-type of range() function.\n",
4378+
"\n",
43514379
"\n",
43524380
"print (type(range(10))) #To check the data-type of range() function output.\n",
43534381
" #The output is going to be class \"range\" or data-type range which is not useable on \n",

0 commit comments

Comments
 (0)