Skip to content

Commit c06b1dc

Browse files
committed
add 2 more example
1 parent a53d900 commit c06b1dc

File tree

2 files changed

+218
-12
lines changed

2 files changed

+218
-12
lines changed

condition/.ipynb_checkpoints/condition01_CompareValues-checkpoint.ipynb

Lines changed: 109 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@
162162
"name": "stdout",
163163
"output_type": "stream",
164164
"text": [
165-
"10\n",
166-
"Number of even numbers : 5\n",
167-
"Number of odd numbers : 5\n"
165+
"15\n",
166+
"Number of even numbers : 8\n",
167+
"Number of odd numbers : 7\n"
168168
]
169169
}
170170
],
@@ -211,8 +211,8 @@
211211
"['Pritom', 'Saha', 'Hello World']\n",
212212
"Equal : True\n",
213213
"Is opreator : False\n",
214-
"ID of a : 2879757711296\n",
215-
"ID of b : 2879757709376\n"
214+
"ID of a : 2321053160064\n",
215+
"ID of b : 2321053156096\n"
216216
]
217217
}
218218
],
@@ -228,11 +228,114 @@
228228
"print(\"ID of b : \",id(b))"
229229
]
230230
},
231+
{
232+
"cell_type": "markdown",
233+
"id": "00b67de5",
234+
"metadata": {},
235+
"source": [
236+
"### Exercise 5\n",
237+
"#### Test whether these expressions are True or False"
238+
]
239+
},
231240
{
232241
"cell_type": "code",
233-
"execution_count": null,
242+
"execution_count": 8,
234243
"id": "3a640df2",
235244
"metadata": {},
245+
"outputs": [
246+
{
247+
"name": "stdout",
248+
"output_type": "stream",
249+
"text": [
250+
"False\n",
251+
"False\n",
252+
"True\n",
253+
"False\n"
254+
]
255+
}
256+
],
257+
"source": [
258+
"\n",
259+
"print((1 <= 1) and (1 != 1))\n",
260+
"print(not (1 != 2))\n",
261+
"print((\"good\" != \"bad\") or False)\n",
262+
"print((\"good\" != \"Good\") and not (1 == 1))"
263+
]
264+
},
265+
{
266+
"cell_type": "markdown",
267+
"id": "12a9ba9a",
268+
"metadata": {},
269+
"source": [
270+
"### Exercise 6\n",
271+
"#### Add parentheses so that the following expressions all\n",
272+
"#### evaluate to True"
273+
]
274+
},
275+
{
276+
"cell_type": "code",
277+
"execution_count": 9,
278+
"id": "af24ec91",
279+
"metadata": {},
280+
"outputs": [
281+
{
282+
"name": "stdout",
283+
"output_type": "stream",
284+
"text": [
285+
"True\n",
286+
"True\n",
287+
"True\n"
288+
]
289+
}
290+
],
291+
"source": [
292+
"# False == not True\n",
293+
"print(False == (not True))\n",
294+
"# True and False == True and False\n",
295+
"print((True and False) == (True and False))\n",
296+
"# not True and \"A\" == \"B\"\n",
297+
"print(not (True and \"A\" == \"B\"))"
298+
]
299+
},
300+
{
301+
"cell_type": "markdown",
302+
"id": "6b94e1d4",
303+
"metadata": {},
304+
"source": [
305+
"### Exercise 7\n",
306+
"#### Challenge: Find the Factors of a Number\n",
307+
"#### Solution to challenge\n",
308+
"#### Display all the factors of a number chosen by the user"
309+
]
310+
},
311+
{
312+
"cell_type": "code",
313+
"execution_count": 10,
314+
"id": "8700cccd",
315+
"metadata": {},
316+
"outputs": [
317+
{
318+
"name": "stdout",
319+
"output_type": "stream",
320+
"text": [
321+
"Enter a positive integer: 11\n",
322+
"1 is a factor of 11\n",
323+
"11 is a factor of 11\n"
324+
]
325+
}
326+
],
327+
"source": [
328+
"num = int(input(\"Enter a positive integer: \"))\n",
329+
"for divisor in range(1, num + 1):\n",
330+
" if num % divisor == 0:\n",
331+
" print(f\"{divisor} is a factor of {num}\")"
332+
]
333+
},
334+
{
335+
"cell_type": "code",
336+
"execution_count": null,
337+
"id": "9419f28f",
338+
"metadata": {},
236339
"outputs": [],
237340
"source": []
238341
}

condition/condition01_CompareValues.ipynb

Lines changed: 109 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@
162162
"name": "stdout",
163163
"output_type": "stream",
164164
"text": [
165-
"10\n",
166-
"Number of even numbers : 5\n",
167-
"Number of odd numbers : 5\n"
165+
"15\n",
166+
"Number of even numbers : 8\n",
167+
"Number of odd numbers : 7\n"
168168
]
169169
}
170170
],
@@ -211,8 +211,8 @@
211211
"['Pritom', 'Saha', 'Hello World']\n",
212212
"Equal : True\n",
213213
"Is opreator : False\n",
214-
"ID of a : 2879757711296\n",
215-
"ID of b : 2879757709376\n"
214+
"ID of a : 2321053160064\n",
215+
"ID of b : 2321053156096\n"
216216
]
217217
}
218218
],
@@ -228,11 +228,114 @@
228228
"print(\"ID of b : \",id(b))"
229229
]
230230
},
231+
{
232+
"cell_type": "markdown",
233+
"id": "00b67de5",
234+
"metadata": {},
235+
"source": [
236+
"### Exercise 5\n",
237+
"#### Test whether these expressions are True or False"
238+
]
239+
},
231240
{
232241
"cell_type": "code",
233-
"execution_count": null,
242+
"execution_count": 8,
234243
"id": "3a640df2",
235244
"metadata": {},
245+
"outputs": [
246+
{
247+
"name": "stdout",
248+
"output_type": "stream",
249+
"text": [
250+
"False\n",
251+
"False\n",
252+
"True\n",
253+
"False\n"
254+
]
255+
}
256+
],
257+
"source": [
258+
"\n",
259+
"print((1 <= 1) and (1 != 1))\n",
260+
"print(not (1 != 2))\n",
261+
"print((\"good\" != \"bad\") or False)\n",
262+
"print((\"good\" != \"Good\") and not (1 == 1))"
263+
]
264+
},
265+
{
266+
"cell_type": "markdown",
267+
"id": "12a9ba9a",
268+
"metadata": {},
269+
"source": [
270+
"### Exercise 6\n",
271+
"#### Add parentheses so that the following expressions all\n",
272+
"#### evaluate to True"
273+
]
274+
},
275+
{
276+
"cell_type": "code",
277+
"execution_count": 9,
278+
"id": "af24ec91",
279+
"metadata": {},
280+
"outputs": [
281+
{
282+
"name": "stdout",
283+
"output_type": "stream",
284+
"text": [
285+
"True\n",
286+
"True\n",
287+
"True\n"
288+
]
289+
}
290+
],
291+
"source": [
292+
"# False == not True\n",
293+
"print(False == (not True))\n",
294+
"# True and False == True and False\n",
295+
"print((True and False) == (True and False))\n",
296+
"# not True and \"A\" == \"B\"\n",
297+
"print(not (True and \"A\" == \"B\"))"
298+
]
299+
},
300+
{
301+
"cell_type": "markdown",
302+
"id": "6b94e1d4",
303+
"metadata": {},
304+
"source": [
305+
"### Exercise 7\n",
306+
"#### Challenge: Find the Factors of a Number\n",
307+
"#### Solution to challenge\n",
308+
"#### Display all the factors of a number chosen by the user"
309+
]
310+
},
311+
{
312+
"cell_type": "code",
313+
"execution_count": 10,
314+
"id": "8700cccd",
315+
"metadata": {},
316+
"outputs": [
317+
{
318+
"name": "stdout",
319+
"output_type": "stream",
320+
"text": [
321+
"Enter a positive integer: 11\n",
322+
"1 is a factor of 11\n",
323+
"11 is a factor of 11\n"
324+
]
325+
}
326+
],
327+
"source": [
328+
"num = int(input(\"Enter a positive integer: \"))\n",
329+
"for divisor in range(1, num + 1):\n",
330+
" if num % divisor == 0:\n",
331+
" print(f\"{divisor} is a factor of {num}\")"
332+
]
333+
},
334+
{
335+
"cell_type": "code",
336+
"execution_count": null,
337+
"id": "9419f28f",
338+
"metadata": {},
236339
"outputs": [],
237340
"source": []
238341
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy