|
413 | 413 | "source": [
|
414 | 414 | "<a id=\"6B Multi-line commenting in Python\"></a>\n",
|
415 | 415 | "<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", |
418 | 419 | "<br>\n",
|
419 | 420 | "<br>\n",
|
420 | 421 | "Eg : \n",
|
|
614 | 615 | },
|
615 | 616 | {
|
616 | 617 | "cell_type": "code",
|
617 |
| - "execution_count": 77, |
| 618 | + "execution_count": 5, |
618 | 619 | "metadata": {},
|
619 | 620 | "outputs": [
|
620 | 621 | {
|
|
625 | 626 | " This is a sentence. This is a second sentence!\n",
|
626 | 627 | " The third sentence. This sentence is fourth.\n",
|
627 | 628 | " 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" |
629 | 632 | ]
|
| 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" |
630 | 643 | }
|
631 | 644 | ],
|
632 | 645 | "source": [
|
|
637 | 650 | " The third sentence. This sentence is fourth.\n",
|
638 | 651 | " Fifth sentence is this one. \n",
|
639 | 652 | " \"\"\"\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" |
641 | 663 | ]
|
642 | 664 | },
|
643 | 665 | {
|
|
3983 | 4005 | "3. <code><b>></code></b>\tIf the value of left operand is greater than the value of right operand, then condition becomes true.<br> Similar to !=.</li>\n",
|
3984 | 4006 | "4. <code><b><</code></b>\tIf the value of left operand is less than the value of right operand, then condition becomes true.\n",
|
3985 | 4007 | "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", |
3987 | 4009 | " </pre><br><b>Eg :</b>"
|
3988 | 4010 | ]
|
3989 | 4011 | },
|
|
4016 | 4038 | "print (\"2 : \",90==99) #False\n",
|
4017 | 4039 | "print (\"3 : \",99!=99) #False\n",
|
4018 | 4040 | "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", |
4027 | 4049 | " "
|
4028 | 4050 | ]
|
4029 | 4051 | },
|
|
4348 | 4370 | " #on it's own until we type-cast it to a secondary data-type like list or tuples\n",
|
4349 | 4371 | " #or use this function with for-loop and \"in\" keyword.\n",
|
4350 | 4372 | "\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", |
4351 | 4379 | "\n",
|
4352 | 4380 | "print (type(range(10))) #To check the data-type of range() function output.\n",
|
4353 | 4381 | " #The output is going to be class \"range\" or data-type range which is not useable on \n",
|
|
0 commit comments