Skip to content

Commit d1e4cf8

Browse files
committed
refactor: move Python Math module notebook into 06_Built_In_Functions
1 parent dab1d57 commit d1e4cf8

1 file changed

Lines changed: 88 additions & 93 deletions

File tree

Learn_the_Python_Math_Module.ipynb renamed to Python/06_Built_In_Functions/Math_Module.ipynb

Lines changed: 88 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
11
{
2-
"nbformat": 4,
3-
"nbformat_minor": 0,
4-
"metadata": {
5-
"colab": {
6-
"name": "Learn the Python Math Module.ipynb",
7-
"provenance": [],
8-
"collapsed_sections": [],
9-
"authorship_tag": "ABX9TyOwgJhxR8T7UydRYxOPlUbq",
10-
"include_colab_link": true
11-
},
12-
"kernelspec": {
13-
"name": "python3",
14-
"display_name": "Python 3"
15-
}
16-
},
172
"cells": [
183
{
194
"cell_type": "markdown",
205
"metadata": {
21-
"id": "view-in-github",
22-
"colab_type": "text"
6+
"colab_type": "text",
7+
"id": "view-in-github"
238
},
249
"source": [
2510
"<a href=\"https://colab.research.google.com/github/Tanu-N-Prabhu/Python/blob/master/Learn_the_Python_Math_Module.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
@@ -28,8 +13,8 @@
2813
{
2914
"cell_type": "markdown",
3015
"metadata": {
31-
"id": "iOM74FRHcq3g",
32-
"colab_type": "text"
16+
"colab_type": "text",
17+
"id": "iOM74FRHcq3g"
3318
},
3419
"source": [
3520
"# Learn the Python Math Module"
@@ -38,8 +23,8 @@
3823
{
3924
"cell_type": "markdown",
4025
"metadata": {
41-
"id": "g-hJaHmZc2UC",
42-
"colab_type": "text"
26+
"colab_type": "text",
27+
"id": "g-hJaHmZc2UC"
4328
},
4429
"source": [
4530
"In this tutorial, I will show you how to use to the builtin Python `math` module."
@@ -48,8 +33,8 @@
4833
{
4934
"cell_type": "markdown",
5035
"metadata": {
51-
"id": "mf1bX3MQc76M",
52-
"colab_type": "text"
36+
"colab_type": "text",
37+
"id": "mf1bX3MQc76M"
5338
},
5439
"source": [
5540
"![alt text](https://miro.medium.com/max/743/1*EfK0rFMPhh57Q70auf8T_w.png)"
@@ -58,8 +43,8 @@
5843
{
5944
"cell_type": "markdown",
6045
"metadata": {
61-
"id": "rPl_xuiadFJ1",
62-
"colab_type": "text"
46+
"colab_type": "text",
47+
"id": "rPl_xuiadFJ1"
6348
},
6449
"source": [
6550
"# What is the math module?\n"
@@ -68,8 +53,8 @@
6853
{
6954
"cell_type": "markdown",
7055
"metadata": {
71-
"id": "FCvwxdR2dIvR",
72-
"colab_type": "text"
56+
"colab_type": "text",
57+
"id": "FCvwxdR2dIvR"
7358
},
7459
"source": [
7560
"It is the C standard defined math module. The math module provides access to mathematical functions.\n",
@@ -80,8 +65,8 @@
8065
{
8166
"cell_type": "markdown",
8267
"metadata": {
83-
"id": "zJe5CnI1dOyY",
84-
"colab_type": "text"
68+
"colab_type": "text",
69+
"id": "zJe5CnI1dOyY"
8570
},
8671
"source": [
8772
"\n",
@@ -103,8 +88,8 @@
10388
{
10489
"cell_type": "markdown",
10590
"metadata": {
106-
"id": "ZvvM2dNSd1wA",
107-
"colab_type": "text"
91+
"colab_type": "text",
92+
"id": "ZvvM2dNSd1wA"
10893
},
10994
"source": [
11095
"# Why do we need to use the math module?\n"
@@ -113,8 +98,8 @@
11398
{
11499
"cell_type": "markdown",
115100
"metadata": {
116-
"id": "SrUQXTeld5Ta",
117-
"colab_type": "text"
101+
"colab_type": "text",
102+
"id": "SrUQXTeld5Ta"
118103
},
119104
"source": [
120105
"Well, the answer is simple: Whenever we need to perform mathematical operations then the math module comes in handy. Let me give you a simple example. It’s quiz time!\n"
@@ -123,8 +108,8 @@
123108
{
124109
"cell_type": "markdown",
125110
"metadata": {
126-
"id": "ch7vaPiNd8Xc",
127-
"colab_type": "text"
111+
"colab_type": "text",
112+
"id": "ch7vaPiNd8Xc"
128113
},
129114
"source": [
130115
"## Calculate the area of a regular polygon with 4 sides and length of a side is 20\n",
@@ -142,7 +127,7 @@
142127
"* n = number of sides\n",
143128
"* l = length of a side\n",
144129
"\n",
145-
"Now you have things clarified, give me the answer (the program to solve it without using the math module) in about 57 minutes. You can post the answer in the comment section below.\n",
130+
"Now you have things clarified, give me the answer (the program to solve it without using the math module) in about 5-7 minutes. You can post the answer in the comment section below.\n",
146131
"\n",
147132
"\n",
148133
"![alt text](https://miro.medium.com/max/2115/1*7DBF85m70NNuujpg7uEBMA.png)\n",
@@ -161,36 +146,36 @@
161146
},
162147
{
163148
"cell_type": "code",
149+
"execution_count": 1,
164150
"metadata": {
165-
"id": "pp_A8CNEfNU_",
166-
"colab_type": "code",
167151
"colab": {
168152
"base_uri": "https://localhost:8080/",
169153
"height": 34
170154
},
155+
"colab_type": "code",
156+
"id": "pp_A8CNEfNU_",
171157
"outputId": "f351de5f-0d2b-4de8-9a96-c4f885aa72c1"
172158
},
173-
"source": [
174-
"import math\n",
175-
"area = (4 * math.pow(20, 2))/(4 * math.tan(math.pi/4))\n",
176-
"print(area)"
177-
],
178-
"execution_count": 1,
179159
"outputs": [
180160
{
161+
"name": "stdout",
181162
"output_type": "stream",
182163
"text": [
183164
"400.00000000000006\n"
184-
],
185-
"name": "stdout"
165+
]
186166
}
167+
],
168+
"source": [
169+
"import math\n",
170+
"area = (4 * math.pow(20, 2))/(4 * math.tan(math.pi/4))\n",
171+
"print(area)"
187172
]
188173
},
189174
{
190175
"cell_type": "markdown",
191176
"metadata": {
192-
"id": "i-wzJoIxfR2D",
193-
"colab_type": "text"
177+
"colab_type": "text",
178+
"id": "i-wzJoIxfR2D"
194179
},
195180
"source": [
196181
"\n",
@@ -202,7 +187,7 @@
202187
"The `math.pow()` → It is a built-in power function that is used to calculate the exponent of the given number used in the math module.\n",
203188
"\n",
204189
"\n",
205-
"```\n",
190+
"```python\n",
206191
"pow(...) \n",
207192
" pow(x, y) \n",
208193
" Return x**y (x to the power of y).\n",
@@ -215,35 +200,35 @@
215200
},
216201
{
217202
"cell_type": "code",
203+
"execution_count": 2,
218204
"metadata": {
219-
"id": "NtQUWBn0gdLE",
220-
"colab_type": "code",
221205
"colab": {
222206
"base_uri": "https://localhost:8080/",
223207
"height": 34
224208
},
209+
"colab_type": "code",
210+
"id": "NtQUWBn0gdLE",
225211
"outputId": "5af667dd-0ae7-4860-adc2-5d38c7ea0bb2"
226212
},
227-
"source": [
228-
"import math\n",
229-
"print(math.pow(150, 4))"
230-
],
231-
"execution_count": 2,
232213
"outputs": [
233214
{
215+
"name": "stdout",
234216
"output_type": "stream",
235217
"text": [
236218
"506250000.0\n"
237-
],
238-
"name": "stdout"
219+
]
239220
}
221+
],
222+
"source": [
223+
"import math\n",
224+
"print(math.pow(150, 4))"
240225
]
241226
},
242227
{
243228
"cell_type": "markdown",
244229
"metadata": {
245-
"id": "T_B0RZruggTa",
246-
"colab_type": "text"
230+
"colab_type": "text",
231+
"id": "T_B0RZruggTa"
247232
},
248233
"source": [
249234
"The `math.tan()` → It is used to calculate the tangent of a given number in radians.\n"
@@ -252,13 +237,13 @@
252237
{
253238
"cell_type": "markdown",
254239
"metadata": {
255-
"id": "eKxIPY-TgjwY",
256-
"colab_type": "text"
240+
"colab_type": "text",
241+
"id": "eKxIPY-TgjwY"
257242
},
258243
"source": [
259244
"\n",
260245
"\n",
261-
"```\n",
246+
"```python\n",
262247
"tan(...) \n",
263248
" tan(x) \n",
264249
" Return the tangent of x (measured in radians).\n",
@@ -269,44 +254,44 @@
269254
{
270255
"cell_type": "markdown",
271256
"metadata": {
272-
"id": "gMTxZmnIgnGm",
273-
"colab_type": "text"
257+
"colab_type": "text",
258+
"id": "gMTxZmnIgnGm"
274259
},
275260
"source": [
276261
"## Calculate the tangent of 60\n"
277262
]
278263
},
279264
{
280265
"cell_type": "code",
266+
"execution_count": 3,
281267
"metadata": {
282-
"id": "l3XohnCSgq9X",
283-
"colab_type": "code",
284268
"colab": {
285269
"base_uri": "https://localhost:8080/",
286270
"height": 34
287271
},
272+
"colab_type": "code",
273+
"id": "l3XohnCSgq9X",
288274
"outputId": "4f8516e8-02c5-486e-a0cd-ecf0503d08cd"
289275
},
290-
"source": [
291-
"import math\n",
292-
"print(math.tan(60))"
293-
],
294-
"execution_count": 3,
295276
"outputs": [
296277
{
278+
"name": "stdout",
297279
"output_type": "stream",
298280
"text": [
299281
"0.320040389379563\n"
300-
],
301-
"name": "stdout"
282+
]
302283
}
284+
],
285+
"source": [
286+
"import math\n",
287+
"print(math.tan(60))"
303288
]
304289
},
305290
{
306291
"cell_type": "markdown",
307292
"metadata": {
308-
"id": "enyfb98Jgs8t",
309-
"colab_type": "text"
293+
"colab_type": "text",
294+
"id": "enyfb98Jgs8t"
310295
},
311296
"source": [
312297
"The `math.pi` → As the name suggests is used as the constant value of Pi (3.14159265359). It returns the floating value of pi, rather than memorizing and then writing the value of pi, just use the math module.\n",
@@ -318,35 +303,35 @@
318303
},
319304
{
320305
"cell_type": "code",
306+
"execution_count": 4,
321307
"metadata": {
322-
"id": "vm4tPQM4gxj7",
323-
"colab_type": "code",
324308
"colab": {
325309
"base_uri": "https://localhost:8080/",
326310
"height": 34
327311
},
312+
"colab_type": "code",
313+
"id": "vm4tPQM4gxj7",
328314
"outputId": "498934be-c416-4612-d883-dd9e299a8609"
329315
},
330-
"source": [
331-
"import math\n",
332-
"print(math.pi)"
333-
],
334-
"execution_count": 4,
335316
"outputs": [
336317
{
318+
"name": "stdout",
337319
"output_type": "stream",
338320
"text": [
339321
"3.141592653589793\n"
340-
],
341-
"name": "stdout"
322+
]
342323
}
324+
],
325+
"source": [
326+
"import math\n",
327+
"print(math.pi)"
343328
]
344329
},
345330
{
346331
"cell_type": "markdown",
347332
"metadata": {
348-
"id": "YlAJgpM1g0zn",
349-
"colab_type": "text"
333+
"colab_type": "text",
334+
"id": "YlAJgpM1g0zn"
350335
},
351336
"source": [
352337
"Back to the explanation.\n",
@@ -387,15 +372,25 @@
387372
"Anyway, I hope that you guys learned something new today. Learning is the stepping stone of success. So keep learning. Stay tuned for more updates.\n",
388373
"\n",
389374
"\n",
390-
"![alt text](https://miro.medium.com/max/1280/1*0VoACtfamg5rUQyfWD8OhA.jpeg)\n",
391-
"\n",
392-
"\n",
393-
"\n",
394-
"\n",
395375
"---\n",
396376
"\n",
397377
"\n"
398378
]
399379
}
400-
]
380+
],
381+
"metadata": {
382+
"colab": {
383+
"authorship_tag": "ABX9TyOwgJhxR8T7UydRYxOPlUbq",
384+
"collapsed_sections": [],
385+
"include_colab_link": true,
386+
"name": "Learn the Python Math Module.ipynb",
387+
"provenance": []
388+
},
389+
"kernelspec": {
390+
"display_name": "Python 3",
391+
"name": "python3"
392+
}
393+
},
394+
"nbformat": 4,
395+
"nbformat_minor": 0
401396
}

0 commit comments

Comments
 (0)