diff options
Diffstat (limited to 'sample_notebooks/SoumenGanguly/ncert_Maths.ipynb')
-rwxr-xr-x | sample_notebooks/SoumenGanguly/ncert_Maths.ipynb | 355 |
1 files changed, 355 insertions, 0 deletions
diff --git a/sample_notebooks/SoumenGanguly/ncert_Maths.ipynb b/sample_notebooks/SoumenGanguly/ncert_Maths.ipynb new file mode 100755 index 00000000..30efaf66 --- /dev/null +++ b/sample_notebooks/SoumenGanguly/ncert_Maths.ipynb @@ -0,0 +1,355 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Chapter 1: Sets\n", + "========" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 1, Page 03:\n", + "----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Therefore, the solution set of the given equation can be written in roaster form as {-2,1}\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "coeff = [1,1,-2]\n", + "\n", + "#Calculations\n", + "roots_array = np.roots(coeff)\n", + "\n", + "#Result\n", + "print \"Therefore, the solution set of the given equation can be written in roaster form as {%d,%d}\"%(roots_array[0],roots_array[1])\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 2, Page 03:\n", + "---------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The required numbers are 1,2,3,4,5,6\n", + "So, the given set in the roster form is {1,2,3,4,5,6}\n" + ] + } + ], + "source": [ + "#Variable declaration\n", + "pos_integer = []\n", + "\n", + "#Calculations\n", + "for i in range(1,1000): #1000 is taken as the upper limit of a positive integer\n", + " if i**2<40:\n", + " pos_integer.append(i)\n", + " \n", + "#Result\n", + "print \"The required numbers are %d,%d,%d,%d,%d,%d\"%(pos_integer[0],pos_integer[1],pos_integer[2],pos_integer[3],pos_integer[4],pos_integer[5])\n", + "print \"So, the given set in the roster form is {%d,%d,%d,%d,%d,%d}\"%(pos_integer[0],pos_integer[1],pos_integer[2],pos_integer[3],pos_integer[4],pos_integer[5])\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 12, Page 14:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The union of the two given arrays is \n", + "[ 2 4 6 8 10 12]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = [2,4,6,8]\n", + "b = [6,8,10,12]\n", + "\n", + "#Calculations\n", + "union_array = np.union1d(a,b)\n", + "\n", + "#Result\n", + "print \"The union of the two given arrays is \"\n", + "print union_array" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 13, Page 14:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A U B = ['a' 'e' 'i' 'o' 'u']\n", + "A = ['a', 'e', 'i', 'o', 'u']\n", + "Thus, A U B = A\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = ['a','e','i','o','u']\n", + "b = ['a','i','u']\n", + "\n", + "#Calculations\n", + "union_array = np.union1d(a,b)\n", + "\n", + "#Result\n", + "print \"A U B = %s\"%(union_array)\n", + "print \"A = %s\"%(a)\n", + "print \"Thus, A U B = A\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 15, Page 15:\n", + "----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A intersection B = [6 8]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = [2,4,6,8]\n", + "b = [6,8,10,12]\n", + "\n", + "#Calculations\n", + "intersect_array = np.intersect1d(a,b)\n", + "\n", + "#Result\n", + "print \"A intersection B = %s\"%(intersect_array)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 18, Page 17:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A - B = [1 3 5]\n", + "B - A = [8]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = [1,2,3,4,5,6]\n", + "b = [2,4,6,8]\n", + "\n", + "#Calculations\n", + "diff_a = np.setdiff1d(a,b)\n", + "diff_b = np.setdiff1d(b,a)\n", + "\n", + "#Result\n", + "print \"A - B = %s\"%(diff_a)\n", + "print \"B - A = %s\"%(diff_b)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 20, Page 19:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A' = [ 2 4 6 8 10]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "u = [1,2,3,4,5,6,7,8,9,10]\n", + "a = [1,3,5,7,9]\n", + "\n", + "#Calculations\n", + "complement_a = np.setdiff1d(u,a)\n", + "\n", + "#Result\n", + "print \"A' = %s\"%(complement_a)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 22, Page 19:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A' = [1 4 5 6]\n", + "B' = [1 2 6]\n", + "A' intersection B' = [1 6]\n", + "A U B = [2 3 4 5]\n", + "(A U B)' = [1 6]\n", + "Therefore, (A U B)' = A' intersection B' \n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "u = [1,2,3,4,5,6]\n", + "a = [2,3]\n", + "b = [3,4,5]\n", + "\n", + "#Calculations\n", + "complement_a = np.setdiff1d(u,a)\n", + "complement_b = np.setdiff1d(u,b)\n", + "intersect_ab = np.intersect1d(complement_a,complement_b)\n", + "union_ab = np.union1d(a,b)\n", + "complement_union_ab = np.setdiff1d(u,union_ab)\n", + "\n", + "#Result\n", + "print \"A' = %s\"%(complement_a)\n", + "print \"B' = %s\"%(complement_b)\n", + "print \"A' intersection B' = %s\"%(intersect_ab)\n", + "print \"A U B = %s\"%(union_ab)\n", + "print \"(A U B)' = %s\"%(complement_union_ab)\n", + "print \"Therefore, (A U B)\\' = A\\' intersection B\\' \"\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.8" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |