|
40 | 40 | "Executes the statements inside the block only if the condition is satisfied.\n",
|
41 | 41 | "\n",
|
42 | 42 | "Syntax: \n",
|
43 |
| - ">*if* condition: \n", |
44 |
| - " Statements" |
| 43 | + "```python\n", |
| 44 | + "if condition: \n", |
| 45 | + " Statements\n", |
| 46 | + "```" |
45 | 47 | ]
|
46 | 48 | },
|
47 | 49 | {
|
|
74 | 76 | },
|
75 | 77 | {
|
76 | 78 | "cell_type": "code",
|
77 |
| - "execution_count": 5, |
| 79 | + "execution_count": 2, |
78 | 80 | "metadata": {},
|
79 | 81 | "outputs": [
|
80 | 82 | {
|
81 | 83 | "name": "stdin",
|
82 | 84 | "output_type": "stream",
|
83 | 85 | "text": [
|
84 |
| - " -1\n" |
| 86 | + " -2\n" |
85 | 87 | ]
|
86 | 88 | },
|
87 | 89 | {
|
|
108 | 110 | "#### 2. *if - else* statements:\n",
|
109 | 111 | "Executes *else* when *if* condition fails \n",
|
110 | 112 | "Syntax: \n",
|
111 |
| - ">if condition1: \n", |
112 |
| - " Statements \n", |
| 113 | + "```python\n", |
| 114 | + "if condition1: \n", |
| 115 | + " Statements \n", |
113 | 116 | "else: \n",
|
114 |
| - " Statements" |
| 117 | + " Statements\n", |
| 118 | + "```" |
115 | 119 | ]
|
116 | 120 | },
|
117 | 121 | {
|
|
121 | 125 | "#### 3. *if - elif - else* statements:\n",
|
122 | 126 | "Checks for truth of *elif* statement when *if* statement fails. Chain of *if-else* \n",
|
123 | 127 | "Syntax: \n",
|
124 |
| - ">if condition1: \n", |
125 |
| - " Statements\n", |
| 128 | + "```python\n", |
| 129 | + "if condition1: \n", |
| 130 | + " Statements \n", |
126 | 131 | "elif condition2: \n",
|
127 |
| - " Statements\n", |
| 132 | + " Statements \n", |
128 | 133 | "else: \n",
|
129 |
| - " Statements" |
| 134 | + " Statements\n", |
| 135 | + "```" |
130 | 136 | ]
|
131 | 137 | },
|
132 | 138 | {
|
|
137 | 143 | "*if else* within another *if else* statement\n",
|
138 | 144 | "\n",
|
139 | 145 | "Syntax:\n",
|
140 |
| - ">if condition1: \n", |
141 |
| - " if condition2: \n", |
142 |
| - " Statements \n", |
143 |
| - " else: \n", |
144 |
| - " Statements \n", |
| 146 | + "```python\n", |
| 147 | + "if condition1: \n", |
| 148 | + " if condition2: \n", |
| 149 | + " Statements \n", |
| 150 | + " else: \n", |
| 151 | + " Statements \n", |
145 | 152 | "else: \n",
|
146 |
| - " if condition3: \n", |
147 |
| - " Statements \n", |
148 |
| - " else: \n", |
149 |
| - " Statements " |
| 153 | + " if condition3: \n", |
| 154 | + " Statements \n", |
| 155 | + " else: \n", |
| 156 | + " Statements \n", |
| 157 | + "```" |
150 | 158 | ]
|
151 | 159 | },
|
152 | 160 | {
|
|
157 | 165 | "One liner of *if else* statements\n",
|
158 | 166 | "\n",
|
159 | 167 | "Syntax:\n",
|
160 |
| - "> Statement1 if condition else Statement2" |
| 168 | + "```python\n", |
| 169 | + "Statement1 if condition else Statement2\n", |
| 170 | + "```" |
161 | 171 | ]
|
162 | 172 | }
|
163 | 173 | ],
|
|
177 | 187 | "name": "python",
|
178 | 188 | "nbconvert_exporter": "python",
|
179 | 189 | "pygments_lexer": "ipython3",
|
180 |
| - "version": "3.8.6" |
| 190 | + "version": "3.9.4" |
181 | 191 | }
|
182 | 192 | },
|
183 | 193 | "nbformat": 4,
|
|
0 commit comments