diff options
Diffstat (limited to 'Quantitative_Aptitude_for_Competitive_Examinations')
28 files changed, 21154 insertions, 0 deletions
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter1.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter1.ipynb new file mode 100755 index 00000000..c048e488 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter1.ipynb @@ -0,0 +1,455 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#1: Numbers"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.1, Page number 1.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "quotient is 381.097560976\n",
+ "remainder is 4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "D=41; #divisor\n",
+ "d=15625; #dividend\n",
+ "\n",
+ "#Calculation\n",
+ "q=d/D; #quotient\n",
+ "r=d%D; #remainder\n",
+ "\n",
+ "#Result\n",
+ "print \"quotient is\",q\n",
+ "print \"remainder is\",r"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.2, Page number 1.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "divisor is 459.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "D=397246; #dividend\n",
+ "r=211; #remainder\n",
+ "q=865; #quotient\n",
+ "\n",
+ "#Calculation\n",
+ "d=(D-r)/q; #divisor\n",
+ "\n",
+ "#Result\n",
+ "print \"divisor is\",d"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.4, Page number 1.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "least number to be subtracted is 125\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=87375; #dividend\n",
+ "D=698; #divisor\n",
+ "\n",
+ "#Calculation\n",
+ "r=d%D; #remainder\n",
+ "\n",
+ "#Result\n",
+ "print \"least number to be subtracted is\",r"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.5, Page number 1.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "least number to be added is 58\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=49123; #dividend\n",
+ "D=263; #divisor\n",
+ "\n",
+ "#Calculation\n",
+ "r=d%D; #remainder\n",
+ "l=D-r; #least number to be added\n",
+ "\n",
+ "#Result\n",
+ "print \"least number to be added is\",l"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.6, Page number 1.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required number is 980\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration \n",
+ "d=999; #dividend\n",
+ "D=35; #divisor\n",
+ "\n",
+ "#Calculation\n",
+ "r=d%D; #remainder\n",
+ "rn=d-r; #required number\n",
+ "\n",
+ "#Result\n",
+ "print \"required number is\",rn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.7, Page number 1.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required number is 112\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration \n",
+ "d=100; #dividend\n",
+ "D=14; #divisor\n",
+ "\n",
+ "#Calculation\n",
+ "r=d%D; #remainder\n",
+ "rn=d+D-r; #required number\n",
+ "\n",
+ "#Result\n",
+ "print \"required number is\",rn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.8, Page number 1.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required remainder is 8\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration \n",
+ "d=602; #dividend\n",
+ "D=14; #divisor\n",
+ "rl=36; #remainder\n",
+ "\n",
+ "#Calculation\n",
+ "k=d/D; #quotient\n",
+ "rs=rl-(2*D); #required remainder\n",
+ "\n",
+ "#Result\n",
+ "print \"required remainder is\",rs"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.9, Page number 1.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required remainder is 39\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration \n",
+ "d=357; #dividend\n",
+ "D=17; #divisor\n",
+ "rs=5; #remainder\n",
+ "\n",
+ "#Calculation\n",
+ "k=d/D; #quotient\n",
+ "rl=(2*D)+rs; #required remainder\n",
+ "\n",
+ "#Result\n",
+ "print \"required remainder is\",rl"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.11, Page number 1.25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "binary equivalent of 30 is 0b11110\n",
+ "binary equivalent of 27 is 0b11011\n",
+ "binary equivalent of 41 is 0b101001\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration \n",
+ "a=30;\n",
+ "b=27;\n",
+ "c=41; #numbers in decimal form\n",
+ "\n",
+ "#Calculation\n",
+ "ba=bin(a); #binary equivalent of 30\n",
+ "bb=bin(b); #binary equivalent of 27\n",
+ "bc=bin(c); #binary equivalent of 41\n",
+ "\n",
+ "#Result\n",
+ "print \"binary equivalent of 30 is\",ba\n",
+ "print \"binary equivalent of 27 is\",bb\n",
+ "print \"binary equivalent of 41 is\",bc"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 1.12, Page number 1.26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result of 10110-1011 is 0b1011\n",
+ "result of 1001+1010 is 0b10011\n",
+ "result of 101*100 is 0b10100\n",
+ "result of 1100/11 is 0b100\n",
+ "result of 101+1100/10 is 0b1011\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration \n",
+ "a='10110'\n",
+ "b='1011'\n",
+ "c='1001'\n",
+ "d='1010'\n",
+ "e='101'\n",
+ "f='100'\n",
+ "g='1100'\n",
+ "h='11'\n",
+ "i='101'\n",
+ "j='1100'\n",
+ "k='10'\n",
+ "\n",
+ "#Calculation\n",
+ "a_b=bin(int(a,2)-int(b,2)); #result of 10110-1011\n",
+ "c_d=bin(int(c,2)+int(d,2)); #result of 1001+1010\n",
+ "e_f=bin(int(e,2)*int(f,2)); #result of 101*100\n",
+ "gh1=int(g,2);\n",
+ "gh2=int(h,2);\n",
+ "gh=int(gh1/gh2); \n",
+ "g_h=bin(gh); #result of 1100/11\n",
+ "j_k=bin(int(int(j,2)/int(k,2))); #result of 1100/10\n",
+ "i_j_k=bin(int(i,2)+int(j_k,2)); #result of 101+1100/10\n",
+ "\n",
+ "#Result\n",
+ "print \"result of 10110-1011 is\",a_b\n",
+ "print \"result of 1001+1010 is\",c_d\n",
+ "print \"result of 101*100 is\",e_f\n",
+ "print \"result of 1100/11 is\",g_h\n",
+ "print \"result of 101+1100/10 is\",i_j_k"
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter10.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter10.ipynb new file mode 100755 index 00000000..e80ad105 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter10.ipynb @@ -0,0 +1,659 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 10: Chain Rule"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.1, Page number 10.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 80.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=120; #number of men\n",
+ "N2=150; #number of men\n",
+ "D1=100; #number of days\n",
+ "\n",
+ "#Calculation\n",
+ "D2=N1*D1/N2; #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.2, Page number 10.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of men is 15.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=18; #number of men\n",
+ "D1=8; #number of days\n",
+ "D2=6; #number of days\n",
+ "R1=5; #number of hours\n",
+ "R2=8; #number of hours\n",
+ "\n",
+ "#Calculation\n",
+ "N2=N1*D1*R1/(D2*R2); #number of men\n",
+ "\n",
+ "#Result\n",
+ "print \"number of men is\",N2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.3, Page number 10.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 10.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=1000; #number of men\n",
+ "D1=12; #number of days\n",
+ "N2=200; #number of men joined\n",
+ "\n",
+ "#Calculation\n",
+ "D2=N1*D1/(N1+N2); #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.4, Page number 10.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of acres is 72.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=4; #number of men\n",
+ "D1=30; #number of days\n",
+ "D2=12; #number of days\n",
+ "W1=40; #number of acres\n",
+ "N2=18; #number of men\n",
+ "\n",
+ "#Calculation\n",
+ "W2=N2*D2*W1/(D1*N1); #number of acres\n",
+ "\n",
+ "#Result\n",
+ "print \"number of acres is\",W2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.5, Page number 10.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 6.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=12; #number of men\n",
+ "D1=25; #number of days\n",
+ "N2=20; #number of men\n",
+ "W1=100*3*0.5; #volume of wall\n",
+ "W2=60*4*0.25; #volume of wall\n",
+ "\n",
+ "#Calculation\n",
+ "D2=N1*D1*W2/(W1*N2); #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.6, Page number 10.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 30.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=15; #number of men\n",
+ "D1=21; #number of days\n",
+ "N2=14; #number of men\n",
+ "R1=8; #number of hours\n",
+ "R2=6; #number of hours\n",
+ "\n",
+ "#Calculation\n",
+ "D2=N1*D1*R1/(N2*R2); #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.7, Page number 10.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 5.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=100; #number of men\n",
+ "D2=40-35; #number of days\n",
+ "N2=100; #number of men joined\n",
+ "\n",
+ "#Calculation\n",
+ "D=(N1+N2)*D2/N1;\n",
+ "D1=D-D2; #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D1"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.8, Page number 10.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of additional men is 56.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=104; #number of men\n",
+ "D1=30; #number of days\n",
+ "D=56; #number of days\n",
+ "R1=8; #number of hours\n",
+ "R2=9; #number of hours\n",
+ "W1=2/5; #fraction of work\n",
+ "\n",
+ "#Calculation\n",
+ "D2=D-D1; #number of days\n",
+ "W2=1-W1; #rest of the work\n",
+ "N=N1*D1*R1*W2/(D2*R2*W1);\n",
+ "N2=N-N1; #number of additional men\n",
+ "\n",
+ "#Result\n",
+ "print \"number of additional men is\",N2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.9, Page number 10.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 25.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M1=10; #number of men\n",
+ "D1=40; #number of days\n",
+ "M2=4; #number of men\n",
+ "M3=6; #number of men\n",
+ "D3=50; #number of days\n",
+ "\n",
+ "#Calculation\n",
+ "D2=((M1*D1)-(M3*D3))/M2; #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.10, Page number 10.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 30.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=4; #number of lorries\n",
+ "D1=8; #number of days\n",
+ "R1=4; #number of tons\n",
+ "R2=3; #number of tons\n",
+ "W1=128; #number of tons\n",
+ "N2=6; #number of lorries\n",
+ "W2=540; #number of tons\n",
+ "\n",
+ "#Calculation\n",
+ "D2=N1*D1*R1*W2/(N2*R2*W1);\n",
+ "N2=N-N1; #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.11, Page number 10.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days is 19.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N=250; #number of students\n",
+ "D=30; #number of days \n",
+ "N_1=25; #number of students added\n",
+ "D1=10; #number of days\n",
+ "\n",
+ "#Calculation\n",
+ "N1=N+N_1; #number of students\n",
+ "N2=N; #number of students\n",
+ "D2=((N*D)-(N1*D1))/N2; #number of days\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days is\",D2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.12, Page number 10.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of men is 1500.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=3000; #number of men\n",
+ "D1=25-11; #number of days\n",
+ "R1=900; #rate per head\n",
+ "D2=10; #number of days\n",
+ "R2=840; #rate per head\n",
+ "\n",
+ "#Calculation\n",
+ "N=N1*D1*R1/(D2*R2); \n",
+ "N2=N-N1; #number of men\n",
+ "\n",
+ "#Result\n",
+ "print \"number of men is\",N2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.13, Page number 10.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required diesel is 1350.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=6; #number of diesel engines\n",
+ "D1=5; #number of hours\n",
+ "R1=1/5; \n",
+ "R2=1/8; \n",
+ "W1=900; #number of litres\n",
+ "N2=9; #number of diesel engines\n",
+ "D2=8; #number of hours\n",
+ "\n",
+ "#Calculation\n",
+ "W2=N2*D2*R2*W1/(N1*R1*D1); #required diesel(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"required diesel is\",W2,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.14, Page number 10.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "each machine should work 16.0 h/day\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=2; #number of machines\n",
+ "D1=8; #number of days\n",
+ "R1=12; #number of hours/day\n",
+ "E2=80/100; #efficiency \n",
+ "E1=90/100; #efficiency\n",
+ "W1=9000; #tonnes of coal\n",
+ "N2=3; #number of machines\n",
+ "D2=6; #number of days\n",
+ "W2=12000; #tonnes of coal\n",
+ "\n",
+ "#Calculation\n",
+ "R2=N1*D1*R1*E1*W2/(N2*D2*E2*W1); #number of hours/day\n",
+ "\n",
+ "#Result\n",
+ "print \"each machine should work\",R2,\"h/day\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 10.15, Page number 10.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount charged is 300.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N1=1; #number of persons\n",
+ "D1=5/2; #number of days\n",
+ "R1=50; #amount(Rs) \n",
+ "R2=42.50; #amount(Rs) \n",
+ "W2=340; #amount(Rs)\n",
+ "N2=1; #number of persons\n",
+ "D2=10/3; #number of days\n",
+ "\n",
+ "#Calculation\n",
+ "W1=N1*D1*R1*W2/(N2*R2*D2); #amount charged(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount charged is\",W1,\"Rs\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb new file mode 100755 index 00000000..c9ef92fc --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter11.ipynb @@ -0,0 +1,765 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 11: Time and Work"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.1, Page number 11.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A and B can do the job together in 12.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t1=20; #number of days A can do a job\n",
+ "t2=30; #number of days B can do a job\n",
+ "\n",
+ "#Calculation\n",
+ "T=t1*t2/(t1+t2); #number of days for A and B to do the job together\n",
+ "\n",
+ "#Result\n",
+ "print \"A and B can do the job together in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.2, Page number 11.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A can do the job in 21.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t1=28; #number of days B can do a job\n",
+ "T=12; #number of days for A and B to do the job together\n",
+ "\n",
+ "#Calculation\n",
+ "t2=T*t1/(t1-T); #number of days A can do a job\n",
+ "\n",
+ "#Result\n",
+ "print \"A can do the job in\",t2,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.3, Page number 11.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "work done by A, B and C together is 10.0 days\n",
+ "work done by A alone is 30.0 days\n",
+ "work done by B alone is 20.0 days\n",
+ "work done by C alone is 60.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=12; #work done by A and B together(days)\n",
+ "T2=15; #work done by C and B together(days)\n",
+ "T3=20; #work done by A and C together(days)\n",
+ "\n",
+ "#Calculation\n",
+ "l1=T1*T2/gcd(T1,T2); #lcm of T1 and T2\n",
+ "L=l1*T3/gcd(l1,T3); #lcm of the given 3 numbers\n",
+ "a=L/T1;\n",
+ "b=L/T2;\n",
+ "c=L/T3;\n",
+ "T=2*L/(a+b+c); #work done by A, B and C together(days)\n",
+ "Ta=2*L/(a-b+c); #work done by A alone(days)\n",
+ "Tb=2*L/(a+b-c); #work done by B alone(days)\n",
+ "Tc=2*L/(-a+b+c); #work done by C alone(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"work done by A, B and C together is\",T,\"days\"\n",
+ "print \"work done by A alone is\",Ta,\"days\"\n",
+ "print \"work done by B alone is\",Tb,\"days\"\n",
+ "print \"work done by C alone is\",Tc,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.4, Page number 11.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 8.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=10; #alone time of A(days)\n",
+ "TB=3; #number of days B worked(days)\n",
+ "Tb=15; #alone time of B(days)\n",
+ "\n",
+ "#Calculation\n",
+ "T=Ta*(1-(TB/Tb)); #total work finished(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.5, Page number 11.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 15.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=20; #alone time of A(days)\n",
+ "Tb=30; #alone time of B(days)\n",
+ "a=5; #number of days A leaves(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L=Ta*Tb/gcd(Ta,Tb); #lcm of T1 and T2\n",
+ "l1=L/Ta;\n",
+ "l2=L/Tb;\n",
+ "T=(L+(l1*a))/(l1+l2); #total work finished(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.6, Page number 11.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 8.72727272727 days\n",
+ "B worked for 2.72727272727 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=10; #alone time of A(days)\n",
+ "Tb=12; #alone time of B(days)\n",
+ "a=6; #number of days after A started(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L=T1*T2/gcd(T1,T2); #lcm of T1 and T2\n",
+ "l1=L/Ta;\n",
+ "l2=L/Tb;\n",
+ "T=(L+(l1*a))/(l1+l2); #total work finished(days)\n",
+ "TB=T-a; #number of days B worked for(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\"\n",
+ "print \"B worked for\",TB,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.7, Page number 11.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of days to complete the job is 10.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M1=1; #number of men\n",
+ "E1=1; #efficiency of anil\n",
+ "D1=8; #number of days worked(days)\n",
+ "E=60/100; #efficiency of rakesh(%)\n",
+ "P1=1/3; #part of work done by anil\n",
+ "M2=1; #number of men\n",
+ "\n",
+ "#Calculation\n",
+ "E2=(M1*M2)+(E1*E); #efficiency\n",
+ "P2=1-P1; #part of work done by rakesh\n",
+ "D2=M1*E1*D1*P2/(P1*E2); #number of days to complete the job(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"number of days to complete the job is\",D2,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.8, Page number 11.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken for A to complete the job is 6 1/4 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=5; #work done by A and B together(days)\n",
+ "T=1; #total job done\n",
+ "eB=1/3; #efficiency of B\n",
+ "\n",
+ "#Calculation\n",
+ "t=T-(T/T1); \n",
+ "tA=T1*(1/t); #time taken for A to complete the job(days)\n",
+ "x=tA-int(tA);\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken for A to complete the job is\",int(tA),Fraction(x),\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.9, Page number 11.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A can finish in 2.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M1=1; #number of men\n",
+ "D1=12; #number of days worked(days)\n",
+ "M2=1; #number of men\n",
+ "W1=3/4; #work done by A\n",
+ "W2=1/8; #part of work done\n",
+ "\n",
+ "#Calculation\n",
+ "d=M1*D1*W2/(W1*M2); #number of days for A(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"A can finish in\",d,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.10, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total work is finished in 7.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ta=10; #alone time of A(days)\n",
+ "Tb=12; #alone time of B(days)\n",
+ "Tc=15; #alone time of C(days)\n",
+ "a=2; #number of days after A started(days)\n",
+ "b=3; #number of days before the work finished(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L1=Ta*Tb/gcd(Ta,Tb); #lcm of Ta and Tb\n",
+ "L=L1*Tc/gcd(L1,Tc); #lcm of all the three\n",
+ "l1=L/Ta;\n",
+ "l2=L/Tb;\n",
+ "l3=L/Tc;\n",
+ "r=1-a/Ta;\n",
+ "T=((r*L)+Tc)/(l2+l3); #total work finished(days)\n",
+ "TB=T-a; #number of days B worked for(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"total work is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.11, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A left after 3.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=15; #alone time of A(days)\n",
+ "T2=10; #alone time of B(days)\n",
+ "a=5; #number of days for B to finish(days)\n",
+ "\n",
+ "#Calculation\n",
+ "L=T1*T2/gcd(T1,T2); #lcm of T1 and T2\n",
+ "l1=L/T1;\n",
+ "l2=L/T2;\n",
+ "x=(L-(l2*a))/(l1+l2); #A left after days(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"A left after\",x,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.12, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "C can do it alone in 25.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=12; #alone time of A(days)\n",
+ "T2=15; #alone time of B(days)\n",
+ "T=2; #number of days they work together(days)\n",
+ "t=5; #number of days work is completed(days)\n",
+ "\n",
+ "#Calculation\n",
+ "Ta=(1+T+t)*(1/T1); #A's amount of work\n",
+ "Tb=T*(1/T2); #B's amount of work\n",
+ "T3=1-(Ta+Tb);\n",
+ "t3=t/T3; #C can do it in(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"C can do it alone in\",t3,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.13, Page number 11.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount received by C is 5.33 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=25; #amount paid(Rs)\n",
+ "A=32; #number of days for A(days)\n",
+ "B=20; #number of days for B(days)\n",
+ "C=12; #number of days for C(days)\n",
+ "D=24; #number of days for B(days)\n",
+ "\n",
+ "#Calculation\n",
+ "l1=A*B/gcd(A,B); #lcm of A and B\n",
+ "l2=C*D/gcd(C,D); #lcm of C and D\n",
+ "L=l1*l2/gcd(l1,l2); #LCM of A,B,C and D\n",
+ "a=L/A;\n",
+ "b=L/B;\n",
+ "c1=(1/C)-(1/B);\n",
+ "c=L*c1;\n",
+ "d=L/D;\n",
+ "Cs=c*p/(a+b+c+d); #amount received by C(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount received by C is\",round(Cs,2),\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.14, Page number 11.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken to finish the job if A starts the work is 5.8 days\n",
+ "time taken to finish the job if B starts the work is 5.86 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "tA=5; #work for A alone(days)\n",
+ "tB=7; #work for B alone(days)\n",
+ "\n",
+ "#Calculation\n",
+ "p=round(tA*tB/(tA+tB)); #nearest integer value\n",
+ "Ta=((tA*tB)+(p*(tA-tB)))/tA; #time taken to finish the job if A starts the work(days)\n",
+ "Tb=((tA*tB)-(p*(tA-tB)))/tB; #time taken to finish the job if B starts the work(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken to finish the job if A starts the work is\",Ta,\"days\"\n",
+ "print \"time taken to finish the job if B starts the work is\",round(Tb,2),\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Example number 11.15, Page number 11.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "job is finished in 15.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "tA=20; #number of days for A(days)\n",
+ "tB=30; #number of days for B(days)\n",
+ "tC=60; #number of days for C(days)\n",
+ "da=3; #help done by A\n",
+ "db=1;\n",
+ "dc=1;\n",
+ "\n",
+ "#Calculation\n",
+ "t=(da/tA)+(db/tB)+(dc/tC);\n",
+ "T=da/t; #job is finished in(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"job is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.16, Page number 11.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "job is finished in 30.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "K=3;\n",
+ "l=80; #number of days\n",
+ "\n",
+ "#Calculation\n",
+ "T=K*l/((K**2)-1); #job is finished in(days)\n",
+ "\n",
+ "#Result\n",
+ "print \"job is finished in\",T,\"days\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 11.17, Page number 11.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken if they work together is 12.0 days\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "tA=20; #work by skilled men(days)\n",
+ "tB=30; #work by boys(days)\n",
+ "\n",
+ "#Calculation\n",
+ "T=tA*tB/(tA+tB); #time taken if they work together(days) \n",
+ "\n",
+ "#Result\n",
+ "print \"time taken if they work together is\",T,\"days\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb new file mode 100755 index 00000000..def9a8d2 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter12.ipynb @@ -0,0 +1,760 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 12: Pipes and Cisterns"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.1, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by leak to empty the cistern is 45.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f=4+(1/2); #time(hours)\n",
+ "x=1/2; #time(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "E=f*(1+(f/x)); #time taken by leak to empty the cistern(hours)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by leak to empty the cistern is\",E,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.2, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by leak to empty the cistern is 112.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=32/60; #time(hours)\n",
+ "f1=14; #time for 1st pipe(hours)\n",
+ "f2=16; #time for 2nd pipe(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "T=f1*f2/(f1+f2); #time(h)\n",
+ "E=T*(1+(T/x)); #time taken by leak to empty the cistern(hours)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by leak to empty the cistern is\",E,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.3, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time to fill is 12.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=20; #time for 1st pipe(minutes)\n",
+ "f2=30; #time for 2nd pipe(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "T=f1*f2/(f1+f2); #total time to fill(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time to fill is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.4, Page number 12.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "fill or empty time is 50.0 minutes\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f=25; #time(minutes)\n",
+ "e=50; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "Et=1/((1/f)-(1/e)); #fill or empty time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"fill or empty time is\",Et,\"minutes\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.5, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill half the cistern is 8.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x1=3/4; #part of cistern\n",
+ "x2=1/2; #part of cistern\n",
+ "f1=12; #time to fill(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "f2=f1*x2/x1; #time to fill(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill half the cistern is\",f2,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.6, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " part of cistern to be emptied is 3/8\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "e1=20; #time(minutes)\n",
+ "e2=9; #time(minutes)\n",
+ "y1=5/6; #part of cistern\n",
+ "\n",
+ "#Calculation\n",
+ "y2=e2*y1/e1; #part of cistern to be emptied\n",
+ "\n",
+ "#Result\n",
+ "print \"part of cistern to be emptied is\",Fraction(y2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.7, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 8.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=3; #time(minutes)\n",
+ "a2=15; #time(minutes)\n",
+ "b=10; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "T=b*(1-(a1/a2)); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.8, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 9.143 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "At=12; #alone fill time of A(minutes)\n",
+ "Bt=16; #alone fill time of B(minutes)\n",
+ "t=4; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "l=At*Bt/gcd(At,Bt); #lcm of At and Bt\n",
+ "a=l/At;\n",
+ "b=l/Bt;\n",
+ "T=(l+(t*a))/(a+b); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",round(T,3),\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.9, Page number 12.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 20.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "At=10; #time to fill cistern for A(minutes)\n",
+ "Bt=15; #time to fill cistern for B(minutes)\n",
+ "Ct=5; #time to empty cistern for C(minutes)\n",
+ "t=4; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "l1=At*Bt/gcd(At,Bt); #lcm of At and Bt\n",
+ "l=l1*Ct/gcd(l1,Ct); #lcm of At,Ct and Bt\n",
+ "a=l/At;\n",
+ "b=l/Bt;\n",
+ "c=l/Ct;\n",
+ "T=(-(t*a)-(t*b))/(a+b-c); #time to empty the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.10, Page number 12.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 3.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "At=3; #time to fill cistern for A(minutes)\n",
+ "Bt=6; #time to fill cistern for B(minutes)\n",
+ "Ct=4; #time to empty cistern for B(minutes)\n",
+ "t=2; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "x=1+(t/Ct);\n",
+ "l=At*Bt/gcd(At,Bt); #lcm of At and Bt\n",
+ "a=l/At;\n",
+ "b=l/Bt;\n",
+ "T=x*l/(a+b); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",T,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.11, Page number 12.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time to fill is 16.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=20; #time for 1st pipe(hours)\n",
+ "f2=30; #time for 2nd pipe(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "F=f1*f2/(f1+f2); \n",
+ "T=F+(F/3); #total time to fill(hours)\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print \"total time to fill is\",T,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.12, Page number 12.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "capacity of cistern is 40.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=15; #time for 1st pipe(hours)\n",
+ "f2=10; #time for 2nd pipe(hours)\n",
+ "p=7; #capacity of carrying(litres/min)\n",
+ "E=2*60; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "c=p/((1/f1)+(1/f2)+(1/E)); #capacity of cistern(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"capacity of cistern is\",c,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.13, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 3.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ta=6; #fraction of time for A\n",
+ "t=21; #time to fill for B(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "F=t/(1+ta); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",F,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.14, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to fill the cistern is 8.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "K=4; #time(minutes)\n",
+ "L=30; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "F=K*L/(K**2-1); #time to fill the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to fill the cistern is\",F,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.15, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time to empty the cistern is 18.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f1=10; #time for 1st pipe(minutes)\n",
+ "f2=15; #time for 2nd pipe(minutes)\n",
+ "tex=2; #extra time taken to fill(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "T=f1*f2/(f1+f2); #total time to fill(minutes)\n",
+ "E=T**2/tex; #total time to empty the cistern(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time to empty the cistern is\",E,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.16, Page number 12.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of filling pipes are 4.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "f=9; #fill rate(hours)\n",
+ "e=6; #empty rate(hours)\n",
+ "F=9; #total time(hours)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(1/F)+1;\n",
+ "nf=a*f*e/(f+e); #number of filling pipes\n",
+ "\n",
+ "#Result\n",
+ "print \"number of filling pipes are\",nf"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.17, Page number 12.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average sailing rate is 5.5 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ra=2/6; #rate of admission of water(tonnes/min)\n",
+ "rp=12/60; #rate of pumping out water(tonnes/min)\n",
+ "q=80; #quantity of water(tonnes)\n",
+ "d=55; #distance(km)\n",
+ "\n",
+ "#Calculation\n",
+ "r=ra-rp; #rate of accumulation(tonnes/min)\n",
+ "T=q/(r*60); #time to accumulate water(hours)\n",
+ "Asr=d/T; #average sailing rate(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average sailing rate is\",Asr,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 12.18, Page number 12.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time before the full flow began is 4.5 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=7/8; #part1\n",
+ "p2=5/6; #part2\n",
+ "t1=12; #time(minutes)\n",
+ "t2=16; #time(minutes)\n",
+ "t=3; #time(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(p1/t1)+(p2/t2);\n",
+ "b=1-(t/t1)-(t/t2);\n",
+ "x=b/a; #time before the full flow began(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time before the full flow began is\",x,\"minutes\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter13.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter13.ipynb new file mode 100755 index 00000000..306b8075 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter13.ipynb @@ -0,0 +1,1048 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 13: Profit and Loss"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.1, Page number 13.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "loss in 1st case is 29 Rs\n",
+ "gain in 2nd case is 20 Rs\n",
+ "loss in 3rd case is 25.0 %\n",
+ "gain in 4th case is 25.0 %\n",
+ "SP in 5th case is 99.0 Rs\n",
+ "SP in 6th case is 15.0 Rs\n",
+ "CP in 7th case is 70.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "C1=125; #CP of 1st article(Rs)\n",
+ "S1=96; #SP of 1st article(Rs)\n",
+ "C2=112; #CP of 2nd article(Rs)\n",
+ "S2=132; #SP of 2nd article(Rs)\n",
+ "C3=120; #CP of 3rd article(Rs)\n",
+ "S3=90; #SP of 3rd article(Rs)\n",
+ "C4=80; #CP of 4th article(Rs)\n",
+ "S4=100; #SP of 4th article(Rs)\n",
+ "C5=90; #CP of 5th article(Rs)\n",
+ "G5=10; #gain(%)\n",
+ "L6=25; #loss(%)\n",
+ "C6=20; #CP of 6th article(Rs)\n",
+ "S7=84; #SP of 7th article(Rs)\n",
+ "G7=20; #gain(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x1=S1-C1;\n",
+ "L1=-x1; #loss in 1st case(Rs)\n",
+ "x2=S2-C2;\n",
+ "G2=x2; #gain in 2nd case\n",
+ "x3=S3-C3;\n",
+ "L3=-x3*100/C3; #loss in 3rd case(%)\n",
+ "x4=S4-C4;\n",
+ "G4=x4*100/C4; #gain in 4th case(%)\n",
+ "S5=(100+G5)*C5/100; #SP in 5th case(Rs)\n",
+ "S6=(100-L6)*C6/100; #SP in 6th case(Rs)\n",
+ "C7=S7/(1+(G7*0.01)); #CP in 7th case(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"loss in 1st case is\",L1,\"Rs\"\n",
+ "print \"gain in 2nd case is\",G2,\"Rs\"\n",
+ "print \"loss in 3rd case is\",L3,\"%\"\n",
+ "print \"gain in 4th case is\",G4,\"%\"\n",
+ "print \"SP in 5th case is\",S5,\"Rs\"\n",
+ "print \"SP in 6th case is\",S6,\"Rs\"\n",
+ "print \"CP in 7th case is\",C7,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.2, Page number 13.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "SP of 2nd article is 750.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "S1=450; #SP of 1st article(Rs)\n",
+ "x1=25; #loss(%)\n",
+ "x2=25; #gain(%)\n",
+ "\n",
+ "#Calculation\n",
+ "S2=S1*(100+x2)/(100-x1); #SP of 2nd article(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"SP of 2nd article is\",S2,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.3, Page number 13.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain in transaction is 25.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=25; #number of articles on CP\n",
+ "N=20; #number of articles on SP\n",
+ "\n",
+ "#Calculation\n",
+ "x=(n-N)*100/N; #gain in transaction(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain in transaction is\",x,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.4, Page number 13.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of oranges per rupee is 32.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "S1=1/36; #SP of 1st article(Rs)\n",
+ "x1=4; #loss(%)\n",
+ "x2=8; #gain(%)\n",
+ "\n",
+ "#Calculation\n",
+ "S2=S1*(100+x2)/(100-x1); #SP of 2nd article(Rs)\n",
+ "n=1/S2; #number of oranges per rupee\n",
+ " \n",
+ "#Result\n",
+ "print \"number of oranges per rupee is\",n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.5, Page number 13.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sale rate of rice is Rs 50.0 per kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "q1=2; #quantity(kg)\n",
+ "q2=10; #quantity(kg)\n",
+ "C=600; #cost price(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "S=C/(q1+q2); #sale rate of rice(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"sale rate of rice is Rs\",S,\"per kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.6, Page number 13.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 11.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "S1=455; #SP of 1st article(Rs)\n",
+ "S2=555; #SP of 2nd article(Rs)\n",
+ "x1=9; #loss(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x2=(S2*(100-x1)/S1)-100; #gain(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",x2,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.7, Page number 13.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "real profit is 25.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=20; #profit on SP(%)\n",
+ "\n",
+ "#Calculation\n",
+ "rp=p*100/(100-p); #real profit(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"real profit is\",rp,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.8, Page number 13.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "real loss is 9.09 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=-10; #loss on SP(%)\n",
+ "\n",
+ "#Calculation\n",
+ "rl=-l*100/(100-l); #real loss(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"real loss is\",round(rl,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.9, Page number 13.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "percentage increase of MP is 40.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=10; #discount(%)\n",
+ "g=26; #profit(%)\n",
+ "C=1; #assume\n",
+ "\n",
+ "#Calculation\n",
+ "x=C*(100+g)/(100-d); \n",
+ "M=(x-1)*100; #percentage increase of MP(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"percentage increase of MP is\",M,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.10, Page number 13.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 8.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "S1=30; #SP of 1st article(Rs)\n",
+ "x1=20; #gain(%)\n",
+ "d=10/100; #discount\n",
+ "\n",
+ "#Calculation\n",
+ "S2=S1*(1-d); #SP of 2nd article(Rs)\n",
+ "x2=(S2*(100+x1)/S1)-100; #gain(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",x2,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.11, Page number 13.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of oranges per rupee is 14.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=40; #gain(%)\n",
+ "S=1/10; #SP of article(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "y=(x/100)+1;\n",
+ "C=S/y; #CP of article(Rs)\n",
+ "n=1/C; #number of oranges per rupee\n",
+ "\n",
+ "#Result\n",
+ "print \"number of oranges per rupee is\",n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.12, Page number 13.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 50.0 %\n",
+ "number of oranges is 312.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "SP=1/4; #SP of article\n",
+ "CP=1/6; #CP of article\n",
+ "tg=26; #total gain(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "g=(SP-CP)*100/CP; #gain(%)\n",
+ "x=tg/(SP-CP); #number of oranges\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",g,\"%\"\n",
+ "print \"number of oranges is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.13, Page number 13.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 11.11 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=0;\n",
+ "Tw=1000; #true weight(kg)\n",
+ "Fw=900; #false weight(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "G=(Tw*(100+x)/Fw)-100; #gain(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",round(G,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.14, Page number 13.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "false scale length is 78.26 cm\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ts=100; #true scale(cm)\n",
+ "G=15; #gain(%)\n",
+ "x=10; #loss(%)\n",
+ "\n",
+ "#Calculation\n",
+ "l=Ts*(100-x)/(100+G); #false scale length(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"false scale length is\",round(l,2),\"cm\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.15, Page number 13.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 96.56 %\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x1=25; #gain(%)\n",
+ "x2=-20; #loss(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x=2*(100+x1)*(100+x2);\n",
+ "y=100+x1+100+x2;\n",
+ "g=(x/y)-1; #gain(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",round(g,2),\"%\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.16, Page number 13.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "overall loss is -1.44 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=12; #loss or gain(%)\n",
+ "\n",
+ "#Calculation\n",
+ "l=-(x/10)**2; #overall loss(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"overall loss is\",l,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.17, Page number 13.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cost price of 1st watch is 224.0 Rs\n",
+ "cost price of 2nd watch is 336.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "C1=10/100; #loss\n",
+ "C2=15/100; #profit\n",
+ "C=560; #cost(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "C1=C1*C/(C1+C2); #cost price of 1st watch(Rs)\n",
+ "C2=C-C1; #cost price of 2nd watch(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"cost price of 1st watch is\",C1,\"Rs\"\n",
+ "print \"cost price of 2nd watch is\",C2,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.18, Page number 13.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cost price of book is 90.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "C1=100; #CP of book(Rs)\n",
+ "p1=20/100; #profit\n",
+ "C2=80; #assume 20% less\n",
+ "p2=25/100; #profit in 2nd case\n",
+ "d=18; #given difference(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "S1=C1*(1+p1); #selling price of book(Rs)\n",
+ "S2=C2*(1+p2); #selling price in 2nd case(Rs)\n",
+ "S=S1-S2; #difference when CP=100(Rs)\n",
+ "CP=d*C1/S; #cost price of book(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"cost price of book is\",CP,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.19, Page number 13.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cost price of the book is 420.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=16; #discount(%)\n",
+ "M_S=80; #cost(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "S=(100-d)*M_S/d; #cost price of the book(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"cost price of the book is\",S,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.20, Page number 13.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain in transaction is 11.11 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=30; #number of articles on CP\n",
+ "N=27; #number of articles on SP\n",
+ "\n",
+ "#Calculation\n",
+ "x=(n-N)*100/N; #gain in transaction(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain in transaction is\",round(x,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.21, Page number 13.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "selling price of salt is 88.0 paise per kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=80; #quantity(kg)\n",
+ "y=20; #quantity(kg)\n",
+ "C=88; #cost price(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "S=C/(x+y); #selling price of salt(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"selling price of salt is\",S*100,\"paise per kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.22, Page number 13.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "profit on the article is 20.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=10; #loss(%)\n",
+ "f=3/4; #fraction \n",
+ "\n",
+ "#Calculation\n",
+ "SP=(100-l)/f; #ratio of SP to CP(%)\n",
+ "p=SP-100; #profit on the article(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"profit on the article is\",p,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.23, Page number 13.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 50.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N=66; #length of cloth(m)\n",
+ "x=22; #gain in length(m)\n",
+ "\n",
+ "#Calculation\n",
+ "g=x*100/(N-x); #gain(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",g,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.24, Page number 13.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain is 33.33 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N=66; #length of cloth(m)\n",
+ "Y=22; #gain in length(m)\n",
+ "\n",
+ "#Calculation\n",
+ "g=Y*100/N; #gain(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain is\",round(g,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 13.25, Page number 13.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "loss is 25.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=-22; #loss in length(m)\n",
+ "N=66; #length of cloth(m)\n",
+ "\n",
+ "#Calculation\n",
+ "l=-x*100/(N-x); #loss(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"loss is\",l,\"%\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter14.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter14.ipynb new file mode 100755 index 00000000..89228f7b --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter14.ipynb @@ -0,0 +1,714 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 14: Simple Interest"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.1, Page number 14.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "simple interest in 1st case is 800.0 Rs\n",
+ "simple interest in 2nd case is 10.0 Rs\n",
+ "simple interest in 3rd case is 72.0 Rs\n",
+ "simple interest in 4th case is 50.0 Rs\n",
+ "simple interest in 5th case is 8.0 Rs\n",
+ "simple interest in 6th case is 24.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P1=1000; #principal(Rs)\n",
+ "R1=20; #rate(%)\n",
+ "T1=4; #time(years)\n",
+ "P2=600; #principal(Rs)\n",
+ "R2=5; #rate(%)\n",
+ "T2=4/12; #time(years)\n",
+ "P3=200; #principal(Rs)\n",
+ "R3=6*2; #rate(%)\n",
+ "T3=3; #time(years)\n",
+ "P4=500; #principal(Rs)\n",
+ "R4=2*2; #rate(%)\n",
+ "T4=5/2; #time(years)\n",
+ "P5=400; #principal(Rs)\n",
+ "R5=3*4; #rate(%)\n",
+ "T5=2/12; #time(years)\n",
+ "P6=730; #principal(Rs)\n",
+ "R6=10; #rate(%)\n",
+ "T6=120/365; #time(years)\n",
+ "\n",
+ "#Calculation\n",
+ "SI1=P1*T1*R1/100; #simple interest in 1st case(Rs)\n",
+ "SI2=P2*T2*R2/100; #simple interest in 2nd case(Rs)\n",
+ "SI3=P3*T3*R3/100; #simple interest in 3rd case(Rs)\n",
+ "SI4=P4*T4*R4/100; #simple interest in 4th case(Rs)\n",
+ "SI5=P5*T5*R5/100; #simple interest in 5th case(Rs)\n",
+ "SI6=P6*T6*R6/100; #simple interest in 1st case(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"simple interest in 1st case is\",SI1,\"Rs\"\n",
+ "print \"simple interest in 2nd case is\",SI2,\"Rs\"\n",
+ "print \"simple interest in 3rd case is\",SI3,\"Rs\"\n",
+ "print \"simple interest in 4th case is\",SI4,\"Rs\"\n",
+ "print \"simple interest in 5th case is\",SI5,\"Rs\"\n",
+ "print \"simple interest in 6th case is\",SI6,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.2, Page number 14.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount in 1st case is 106.0 Rs\n",
+ "amount in 2nd case is 510.0 Rs\n",
+ "amount in 3rd case is 406.0 Rs\n",
+ "time in 4th case is 5.0 years\n",
+ "simple interest in 5th case is 120.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P1=100; #principal(Rs)\n",
+ "R1=3; #rate(%)\n",
+ "T1=2; #time(years)\n",
+ "P2=500; #principal(Rs)\n",
+ "R2=6; #rate(%)\n",
+ "T2=4/12; #time(years)\n",
+ "P3=400; #principal(Rs)\n",
+ "R3=3.65; #rate(%)\n",
+ "T3=150/365; #time(years)\n",
+ "A4=540; #amount(Rs)\n",
+ "R4=5; #rate(%)\n",
+ "SI4=108; #simple interest(Rs)\n",
+ "A5=1120; #amount(Rs) \n",
+ "R5=5; #rate(%)\n",
+ "T5=12/5; #time(years)\n",
+ "\n",
+ "#Calculation\n",
+ "A1=P1*(1+(R1*T1/100)); #amount in 1st case(Rs) \n",
+ "A2=P2*(1+(R2*T2/100)); #amount in 2nd case(Rs) \n",
+ "A3=P3*(1+(R3*T3/100)); #amount in 3rd case(Rs) \n",
+ "x=(A4/SI4)-1;\n",
+ "T4=100/(x*R4); #time in 4th case(years)\n",
+ "y=(100/(R5*T5))+1;\n",
+ "SI5=A5/y; #simple interest in 5th case(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount in 1st case is\",A1,\"Rs\"\n",
+ "print \"amount in 2nd case is\",A2,\"Rs\"\n",
+ "print \"amount in 3rd case is\",A3,\"Rs\"\n",
+ "print \"time in 4th case is\",T4,\"years\"\n",
+ "print \"simple interest in 5th case is\",SI5,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.3, Page number 14.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 1500.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "SI=810; #simple interest(Rs)\n",
+ "R=9; #rate(%)\n",
+ "T=6; #time(years)\n",
+ "\n",
+ "#Calculation\n",
+ "P=100*SI/(R*T); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.4, Page number 14.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate is 12 1/2 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=8; #time(years)\n",
+ "N=2; #number of times\n",
+ "\n",
+ "#Calculation\n",
+ "R=100*(N-1)/T; #rate(%)\n",
+ "x=R-int(R);\n",
+ "\n",
+ "#Result\n",
+ "print \"rate is\",int(R),Fraction(x),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.5, Page number 14.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 600.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=5/2; #rate(%)\n",
+ "T=2; #time(years)\n",
+ "A=630; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=A/(1+(R*T/100)); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.6, Page number 14.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 600.0 Rs\n",
+ "rate is 10.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T1=2; #time(years)\n",
+ "A1=720; #amount(Rs)\n",
+ "T2=2+5; #time(years)\n",
+ "A2=1020; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=((A1*T2)-(A2*T1))/(T2-T1); #principal(Rs)\n",
+ "R=(A2-A1)*100/((A1*T2)-(A2*T1)); #rate(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\"\n",
+ "print \"rate is\",R,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.7, Page number 14.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate is 8.0 %\n",
+ "time is 8.0 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=1; #assume\n",
+ "SI=16*P/25;\n",
+ "\n",
+ "#Calculation\n",
+ "#given T=R\n",
+ "R_2=SI*100;\n",
+ "R=math.sqrt(R_2); #rate(%)\n",
+ "T=R; #time(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate is\",R,\"%\"\n",
+ "print \"time is\",T,\"years\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.8, Page number 14.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum at 5% is 2125.0 Rs\n",
+ "sum at 7% is 375.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=2500; #principal(Rs)\n",
+ "SI=265; #simple interest(Rs)\n",
+ "T=2; #time(years)\n",
+ "r1=5; #rate(%)\n",
+ "r2=7; #rate(%)\n",
+ "\n",
+ "#Calculation\n",
+ "Rm=100*SI/(T*P); #rate of interest(%)\n",
+ "S1=r2-Rm; #sum borrowed at 5%\n",
+ "S2=Rm-r1; #sum borrowed at 7%\n",
+ "S_5=S1*P/(S1+S2); #sum at 5%(Rs)\n",
+ "S_7=S2*P/(S1+S2); #sum at 7%(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"sum at 5% is\",S_5,\"Rs\"\n",
+ "print \"sum at 7% is\",S_7,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.9, Page number 14.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 5000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=1/3; #1st part\n",
+ "p2=1/6; #2nd part\n",
+ "r1=3; #rate(%)\n",
+ "r2=6; #rate(%)\n",
+ "r3=8; #rate(%)\n",
+ "SI=600; #simple interest(Rs)\n",
+ "T=2; #time(years)\n",
+ "\n",
+ "#Calculation\n",
+ "p3=1-(p1+p2); #rest part\n",
+ "R=(p1*r1)+(p2*r2)+(p3*r3); #average rate(%)\n",
+ "P=100*SI/(R*T); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.10, Page number 14.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "annual installment is Rs 700.0 per year\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M=4200; #debt(Rs)\n",
+ "n=5; #number of years\n",
+ "y=1;\n",
+ "r=10; #rate(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x=n*(n-1)/2;\n",
+ "z=x*r/(100*y);\n",
+ "a=M/(n+z); #annual installment(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"annual installment is Rs\",a,\"per year\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.11, Page number 14.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate is 400.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "M=2; #debt(Rs)\n",
+ "n=3; #number of years\n",
+ "y=12;\n",
+ "a=1; #annual installment(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=n*(n-1)/2;\n",
+ "z=x*a/(100*y);\n",
+ "r=(-M+(n*a))/z; #rate(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate is\",r,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.12, Page number 14.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount is 122.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R1=R2=1; #assume\n",
+ "T1=3; #time(years)\n",
+ "A1=95; #amount(Rs)\n",
+ "T2=5; #time(years)\n",
+ "P1=85; #principal(Rs)\n",
+ "P2=102; #principal(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "A2=((A1-P1)*P2*T2*R2/(P1*R1*T1))+P2; #amount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount is\",A2,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.13, Page number 14.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 700.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R1_R2=2; #change in rate(%)\n",
+ "SI1_SI2=56; #change in simple interest(Rs)\n",
+ "T=4; #time(years)\n",
+ "\n",
+ "#Calculation\n",
+ "P=100*SI1_SI2/(R1_R2*T); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.14, Page number 14.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum lent out is 600.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R1=8; #rate(%)\n",
+ "R2=1/2; #rate(%)\n",
+ "T1=5; #time(years)\n",
+ "T2=15; #time(years)\n",
+ "P=3800; #principal(Rs) \n",
+ "\n",
+ "P1=T2; #principal(Rs)\n",
+ "P2=2*R1*T1; #principal(Rs)\n",
+ "P1=P1*P/(P1+P2); #sum lent out(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"sum lent out is\",P1,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 14.15, Page number 14.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 13.33 Rs\n",
+ "time is 100.0 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R1=5; #rate(%)\n",
+ "A1=80; #amount(Rs)\n",
+ "R2=2; #rate(%)\n",
+ "A2=40; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=((A1*R2)-(A2*R1))/(R2-R1); #principal(Rs)\n",
+ "T=(A2-A1)*100/((A1*R2)-(A2*R1)); #time(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",round(P,2),\"Rs\"\n",
+ "print \"time is\",T,\"years\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter15.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter15.ipynb new file mode 100755 index 00000000..1809068a --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter15.ipynb @@ -0,0 +1,704 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 15: Compound Interest"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.1, Page number 15.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount is 4410.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=4000; #principal(Rs)\n",
+ "R=5; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "n=1;\n",
+ "\n",
+ "#Calculation\n",
+ "A=P*(1+(R/(100*n)))**(n*T); #amount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount is\",A,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.2, Page number 15.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "compound interest is 662.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=2000; #principal(Rs)\n",
+ "R=10; #rate(%)\n",
+ "T=3; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=R/100;\n",
+ "y=(1+x)**T;\n",
+ "CI=P*(y-1); #compound interest(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"compound interest is\",CI,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.3, Page number 15.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 800.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=10; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "A=968; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=A/(1+(R/100))**T; #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.4, Page number 15.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "compound interest is 4921.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=64000; #principal(Rs)\n",
+ "R=2.5; #rate(%)\n",
+ "T=3; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=R/100;\n",
+ "y=(1+x)**T;\n",
+ "CI=P*(y-1); #compound interest(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"compound interest is\",CI,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.5, Page number 15.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "compound interest in 1st case is 122 Rs\n",
+ "compound interest in 2nd case is 121.2 Rs\n",
+ "answer given in the book is wrong\n",
+ "compound interest in 3rd case is 119.0 Rs\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=2000; #principal(Rs)\n",
+ "R=8; #rate(%)\n",
+ "T=9/12; #time(yrs)\n",
+ "n1=4;\n",
+ "n2=2;\n",
+ "n3=1;\n",
+ "\n",
+ "#Calculation\n",
+ "A1=P*(1+(R/(100*n1)))**(n1*T); #amount(Rs)\n",
+ "CI1=A1-P; #compound interest in 1st case(Rs)\n",
+ "A2=P*(1+(R/(100*n2)))**(n2*T); #amount(Rs)\n",
+ "CI2=A2-P; #compound interest in 2nd case(Rs)\n",
+ "A3=P*(1+(R/(100*n3)))**(n3*T); #amount(Rs)\n",
+ "CI3=A3-P; #compound interest in 3rd case(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"compound interest in 1st case is\",int(CI1),\"Rs\"\n",
+ "print \"compound interest in 2nd case is\",round(CI2,1),\"Rs\"\n",
+ "print \"answer given in the book is wrong\"\n",
+ "print \"compound interest in 3rd case is\",round(CI3),\"Rs\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.6, Page number 15.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum is 31250.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=4; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "CI_SI=50; #difference between CI and SI(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(R/100)**2;\n",
+ "P=CI_SI/x; #sum(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"sum is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.7, Page number 15.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "difference between CI and SI is 20.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=10; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "P=2000; #sum(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(R/100)**2;\n",
+ "CI_SI=P*x; #difference between CI and SI(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"difference between CI and SI is\",CI_SI,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.8, Page number 15.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate per annum is 9.0 %\n",
+ "sum is 1500.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "CI=282.15; #compound interest(Rs)\n",
+ "SI=270; #simple interest(Rs)\n",
+ "T=2; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "R=(CI-SI)*100*T/SI; #rate per annum(%)\n",
+ "P=100*SI/(R*T); #sum(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate per annum is\",R,\"%\"\n",
+ "print \"sum is\",P,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.9, Page number 15.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum is 500.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=10; #rate(%)\n",
+ "T=3; #time(yrs)\n",
+ "CI_SI=31/2; #difference between CI and SI(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=R/100;\n",
+ "y=(x**3)+(T*(x**2));\n",
+ "P=CI_SI/y; #sum(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"sum is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.10, Page number 15.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "ename": "ValueError",
+ "evalue": "math domain error",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
+ "\u001b[1;32m<ipython-input-26-97e4181a1568>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mDr\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m;\u001b[0m \u001b[1;31m#denominator of fraction\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[0md\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mNr\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mDr\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mNr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[1;31m#discriminant\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[0mq\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mNr\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mmath\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msqrt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0md\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mDr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m \u001b[1;31m#solution\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;31m#Result\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+ "\u001b[1;31mValueError\u001b[0m: math domain error"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=434;\n",
+ "b=272;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=a-b; #numerator of fraction\n",
+ "Dr=b; #denominator of fraction\n",
+ "d=(Nr**2)-(4*Dr*Nr); #discriminant\n",
+ "q=(-Nr-math.sqrt(d))/(2*Dr); #solution\n",
+ "\n",
+ "#Result\n",
+ "print \"value of q is\",q\n",
+ "print \"solution for the problem does not exist and the answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.11, Page number 15.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "annual payment is 18522.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=5; #rate(%)\n",
+ "A=50440; #debt amount(Rs)\n",
+ "T=3; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=100/(100+R);\n",
+ "y=x*(1+x+(x**2));\n",
+ "a=A/y; #annual payment(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"annual payment is\",a,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.12, Page number 15.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time is 5.0 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=1; #assume\n",
+ "A=1.44*P; #amount(Rs)\n",
+ "T=2; #time(yrs)\n",
+ "N=2;\n",
+ "\n",
+ "#Calculation\n",
+ "R=(math.sqrt(A/P)-1)*100; #rate(%)\n",
+ "T=(N-1)*100/R; #time(yrs)\n",
+ "\n",
+ "#Result\n",
+ "print \"time is\",T,\"years\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.13, Page number 15.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate per annum is 6.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "I2=238.50; #interest in second year(Rs)\n",
+ "I1=225; #interest in first year(Rs)\n",
+ "T=1; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "I=I2-I1; #interest on 1 year(Rs)\n",
+ "R=100*I/(I1*T); #rate per annum(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate per annum is\",R,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.14, Page number 15.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum is 8000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "CI_SI=20; #difference for 2 years(Rs)\n",
+ "CISI=61; #difference for 3 yrs(Rs)\n",
+ "T1=2; #time(yrs)\n",
+ "T2=3; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "R=((CISI/CI_SI)-T2)*100; #rate(%)\n",
+ "P=CI_SI*(100/R)**2; #sum(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"sum is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.15, Page number 15.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate per annum is 10.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=3; #time(yrs)\n",
+ "P=1000; #sum(Rs)\n",
+ "A=1331; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(A/P)**(1/T);\n",
+ "R=100*(x-1); #rate per annum(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate per annum is\",R,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 15.16, Page number 15.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time is 1.5 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=64000; #sum(Rs)\n",
+ "CI=4921; #compound interest(Rs)\n",
+ "R=5; #rate(%)\n",
+ "n=2;\n",
+ "\n",
+ "#Calculation\n",
+ "A=P+CI; #amount(Rs)\n",
+ "x=A/P;\n",
+ "y=(1+(R/(100*n)))**n;\n",
+ "T=math.log(x)/math.log(y); #time(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"time is\",T,\"years\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter16.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter16.ipynb new file mode 100755 index 00000000..5aea15e0 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter16.ipynb @@ -0,0 +1,565 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 16: True Discount"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.1, Page number 16.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "present worth is 160.0 Rs\n",
+ "true discount is 16.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=176; #principal(Rs)\n",
+ "R=6; #rate(%)\n",
+ "T=20/12; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "PW=P/(1+(R*T/100)); #present worth(Rs)\n",
+ "TD=P-PW; #true discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"present worth is\",PW,\"Rs\"\n",
+ "print \"true discount is\",TD,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.2, Page number 16.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "present worth is 2000.0 Rs\n",
+ "true discount is 420.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=2420; #principal(Rs)\n",
+ "R=10; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "PW=P/((1+(R/100))**T); #present worth(Rs)\n",
+ "TD=P-PW; #true discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"present worth is\",PW,\"Rs\"\n",
+ "print \"true discount is\",TD,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.3, Page number 16.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "present worth is 3000.0 Rs\n",
+ "amount of the bill is 3240.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=12; #rate(%)\n",
+ "T=8/12; #time(yrs)\n",
+ "TD=240; #true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "PW=100*TD/(R*T); #present worth(Rs)\n",
+ "P=PW+TD; #amount of the bill(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"present worth is\",PW,\"Rs\"\n",
+ "print \"amount of the bill is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.4, Page number 16.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "difference between simple interest and true discount is 32.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=960; #principal(Rs)\n",
+ "R=5; #rate(%)\n",
+ "T=4; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "SI_TD=(P*(R*T)**2)/(100*(100+(R*T))); #difference between simple interest and true discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"difference between simple interest and true discount is\",SI_TD,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.5, Page number 16.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 38250.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=4; #rate(%)\n",
+ "T=6/12; #time(yrs)\n",
+ "SI_TD=15; #difference between simple interest and true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=SI_TD*100*(100+(R*T))/((R*T)**2); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.6, Page number 16.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time is 4.0 months\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=2040; #principal(Rs)\n",
+ "R=6; #rate(%)\n",
+ "TD=40; #true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "T=100*TD/(R*(P-TD)); #time(yrs)\n",
+ "\n",
+ "#Result\n",
+ "print \"time is\",T*12,\"months\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.7, Page number 16.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate is 1.11 %\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=1860; #principal(Rs)\n",
+ "T=3; #time(yrs)\n",
+ "TD=60; #true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "R=100*TD/(T*(P-TD)); #rate(%) \n",
+ "\n",
+ "#Result\n",
+ "print \"rate is\",round(R,2),\"%\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.8, Page number 16.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of the bill is 1575.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=5/12; #time(yrs)\n",
+ "TD=75; #true discount(Rs)\n",
+ "R=12; #rate(%)\n",
+ "\n",
+ "#Calculation\n",
+ "P=TD*(1+(100/(R*T))); #amount of the bill(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of the bill is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.9, Page number 16.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum is 600.0 Rs\n",
+ "rate per annum is 16.67 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "TD=200; #true discount(Rs)\n",
+ "SI=300; #simple interest(Rs)\n",
+ "T=3; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=SI*TD/(SI-TD); #sum(Rs)\n",
+ "R=100*SI/(P*T); #rate per annum(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"sum is\",P,\"Rs\"\n",
+ "print \"rate per annum is\",round(R,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.10, Page number 16.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "true discount is 96.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "TD1=60; #true discount(Rs)\n",
+ "T1=1; #assume\n",
+ "T2=2*T1;\n",
+ "R1=R2=1; #assume\n",
+ "P=240; #sum(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(P-TD1)/(T2*TD1);\n",
+ "TD2=P/(x+1); #true discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"true discount is\",TD2,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.11, Page number 16.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate percent is 18.18 %\n",
+ "sum of the bill is 1636.36 Rs\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "PW1=1500; #present worth(Rs)\n",
+ "PW2=1200; #present worth(Rs)\n",
+ "T1=6/12; #time(yrs)\n",
+ "T2=2; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=PW1/PW2;\n",
+ "R=100*(x-1)/(T2-(x*T1)); #rate percent(%)\n",
+ "P=PW1*(1+(R*T1/100)); #sum of the bill(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate percent is\",round(R,2),\"%\"\n",
+ "print \"sum of the bill is\",round(P,2),\"Rs\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.12, Page number 16.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate percent is 4.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P1=600; #sum(Rs)\n",
+ "P2=720; #sum(Rs)\n",
+ "T=5; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "R=((P2*T*100/(P1*T))-100)/T; #rate percent(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate percent is\",R,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 16.13, Page number 16.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "each installment should be 2000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=8480; #sum(Rs)\n",
+ "n=4; #number of installments\n",
+ "r=16; #rate percent(%)\n",
+ "y=4;\n",
+ "\n",
+ "#Calculation\n",
+ "x=r*n*(n-1)/(100*y*2);\n",
+ "a=P/(x+n); #each installment should be(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"each installment should be\",a,\"Rs\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter17.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter17.ipynb new file mode 100755 index 00000000..9ff8c9be --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter17.ipynb @@ -0,0 +1,506 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 17: Banker's discount"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.1, Page number 17.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "true discount is 50.0 Rs\n",
+ "banker's discount is 51.0 Rs\n",
+ "banker's gain is 1.0 Re\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=2550; #principal(Rs)\n",
+ "R=8; #rate(%)\n",
+ "T=3/12; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "TD=P*R*T/(100+(R*T)); #true discount(Rs)\n",
+ "BD=P*R*T/100; #banker's discount(Rs)\n",
+ "BG=BD-TD; #banker's gain(Re)\n",
+ "\n",
+ "#Result\n",
+ "print \"true discount is\",TD,\"Rs\"\n",
+ "print \"banker's discount is\",BD,\"Rs\"\n",
+ "print \"banker's gain is\",BG,\"Re\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.2, Page number 17.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 1055.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=6; #rate(%)\n",
+ "T=11/12; #time(yrs)\n",
+ "BD=58.025; #banker's discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=BD*100/(R*T); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.3, Page number 17.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "banker's discount is 20.6 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=4; #rate(%)\n",
+ "T=9/12; #time(yrs)\n",
+ "TD=20; #true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "BD=TD*(1+(R*T/100)); #banker's discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"banker's discount is\",BD,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.4, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "banker's gain is 3.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=3; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "TD=50; #true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "BG=TD*R*T/100; #banker's gain(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"banker's gain is\",BG,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.5, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time is 1.0 yr\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P1=1000; #principal(Rs)\n",
+ "P2=1050; #principal(Rs)\n",
+ "R=5; #rate(%)\n",
+ "\n",
+ "#Calculation\n",
+ "T=((P2*R*100/(P1*R))-100)/R; #time(yrs)\n",
+ "\n",
+ "#Result\n",
+ "print \"time is\",T,\"yr\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.6, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "banker's discount is 108.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "TD=90; #true discount(Rs)\n",
+ "P=540; #principal(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "BD=((TD**2)/(P-TD))+TD; #banker's discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"banker's discount is\",BD,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.7, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "principal is 1650.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=5; #rate(%)\n",
+ "T=2; #time(yrs)\n",
+ "BG=15; #banker's gain(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=BG*100*(100+(R*T))/((R*T)**2); #principal(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"principal is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.8, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "present worth of bill is 2000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "R=2; #rate(%)\n",
+ "T=5; #time(yrs)\n",
+ "BG=20; #banker's gain(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "PW=BG*(100**2)/((R*T)**2); #present worth of bill(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"present worth of bill is\",PW,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.9, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "true discount is 500.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "BG=25; #banker's gain(Rs)\n",
+ "PW=10000; #present worth of bill(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "TD=math.sqrt(PW*BG); #true discount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"true discount is\",TD,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.10, Page number 17.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sum is 120.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "BD=40; #banker's discount(Rs) \n",
+ "TD=30; #true discount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "P=BD*TD/(BD-TD); #sum(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"sum is\",P,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.11, Page number 17.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate is 7.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "BD=1; #assume\n",
+ "BG=(7/57)*BD; #banker's gain(Rs)\n",
+ "T=2; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "R=BG*100/((BD-BG)*T); #rate(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate is\",R,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 17.12, Page number 17.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate is 2.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "BDbyTD=21/20; #ratio of BD and TD\n",
+ "T=5/2; #time(yrs)\n",
+ "\n",
+ "#Calculation\n",
+ "R=(BDbyTD-1)*100/T; #rate(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate is\",R,\"%\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter18.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter18.ipynb new file mode 100755 index 00000000..d667f507 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter18.ipynb @@ -0,0 +1,823 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 18: Shares and Debentures"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.1, Page number 18.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cost of purchase in 1st case is 4750.0 Rs\n",
+ "cost of purchase in 2nd case is 3000 Rs\n",
+ "cost of purchase in 3rd case is 2750.0 Rs\n",
+ "cost of purchase in 4th case is 920.0 Rs\n",
+ "cost of purchase in 5th case is 2202.0 Rs\n",
+ "cost of purchase in 6th case is 2110.0 Rs\n",
+ "cost of purchase in 7th case is 945.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=5000; #amount(Rs)\n",
+ "mv1=95; #market value\n",
+ "a2=3000; #amount(Rs)\n",
+ "a3=2500; #amount(Rs)\n",
+ "mv2=100+10; #market value\n",
+ "a4=1000; #amount(Rs)\n",
+ "d1=8; #discount(%)\n",
+ "a5=2200; #amount(Rs)\n",
+ "b1=1/11; #brokerage(%)\n",
+ "a6=2000; #amount(Rs)\n",
+ "mv3=100+5; #market value\n",
+ "b2=1/2; #brokerage(%)\n",
+ "d2=6; #discount\n",
+ "a7=1000; #amount(Rs)\n",
+ "b3=1/2; #brokerage(%)\n",
+ "\n",
+ "#Calculation\n",
+ "cp1=a1*mv1/100; #cost of purchase in 1st case(Rs)\n",
+ "cp2=a2; #cost of purchase in 2nd case(Rs)\n",
+ "cp3=a3*mv2/100; #cost of purchase in 3rd case(Rs) \n",
+ "cp4=a4*(100-d1)/100; #cost of purchase in 4th case(Rs) \n",
+ "cp5=a5*(100+b1)/100; #cost of purchase in 5th case(Rs) \n",
+ "cp6=a6*(mv3+b2)/100; #cost of purchase in 6th case(Rs) \n",
+ "mv4=100-d2; #market value\n",
+ "cp7=a7*(mv4+b3)/100; #cost of purchase in 7th case(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"cost of purchase in 1st case is\",cp1,\"Rs\"\n",
+ "print \"cost of purchase in 2nd case is\",cp2,\"Rs\"\n",
+ "print \"cost of purchase in 3rd case is\",cp3,\"Rs\"\n",
+ "print \"cost of purchase in 4th case is\",cp4,\"Rs\"\n",
+ "print \"cost of purchase in 5th case is\",cp5,\"Rs\"\n",
+ "print \"cost of purchase in 6th case is\",cp6,\"Rs\"\n",
+ "print \"cost of purchase in 7th case is\",cp7,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.2, Page number 18.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sale realisation is 2110.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2000; #amount(Rs)\n",
+ "mv=100+6; #market value\n",
+ "b=1/2; #brokerage(%)\n",
+ "\n",
+ "#Calculation\n",
+ "sr=a*(mv-b)/100; #sale realisation(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"sale realisation is\",sr,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.3, Page number 18.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of stock is 1200.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "mv=100+(9/4); #market value\n",
+ "b=1/2; #brokerage(%)\n",
+ "sr=1221; #sale realisation(Rs) \n",
+ " \n",
+ "#Calculation\n",
+ "a=sr*100/(mv-b); #amount of stock(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"amount of stock is\",a,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.4, Page number 18.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of stock is 2000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "b=1/2; #brokerage(%)\n",
+ "d=8; #discount(%)\n",
+ "pc=1850; #purchase cost(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "a=pc*100/(100-d+b); #amount of stock(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"amount of stock is\",a,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.5, Page number 18.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "annual income is 112.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2800; #amount of stock(Rs) \n",
+ "r=4/100; #rate of stock(%)\n",
+ "\n",
+ "#Calculation\n",
+ "I=a*r #annual income(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"annual income is\",I,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.6, Page number 18.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "annual income is 100.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=2800; #investment(Rs)\n",
+ "r=4; #rate of stock(%)\n",
+ "mvb=112; \n",
+ "\n",
+ "#Calculation\n",
+ "I=i*r/mvb; #annual income(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"annual income is\",I,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.7, Page number 18.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate percent obtained is 7.35 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=100; #investment(Rs)\n",
+ "r=7; #rate of stock(%)\n",
+ "b=1/(4*100); #brokerage(%)\n",
+ "mv=1-(5/100); #market value\n",
+ "\n",
+ "#Calculation\n",
+ "R=i*r/(mv+b); #rate percent obtained(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate percent obtained is\",round(R/100,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.8, Page number 18.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "market value is 29.75\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=1220; #investment(Rs)\n",
+ "r=6; #rate of stock(%)\n",
+ "b=1/4; #brokerage(%)\n",
+ "I=244; #annual income(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "mv=(i*r/I)-b; #market value\n",
+ "\n",
+ "#Result\n",
+ "print \"market value is\",mv"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.9, Page number 18.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "investment is 4950.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "r=20/3; #rate of stock(%)\n",
+ "mvb=110;\n",
+ "b=1/4; #brokerage(%)\n",
+ "i=300; #annual income(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "I=i*mvb/r; #investment(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"investment is\",I,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.10, Page number 18.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain by share holder is 13500 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "fv=20; #face value(Rs)\n",
+ "mv=74; #market value(Rs)\n",
+ "n=250; #number of shares\n",
+ "\n",
+ "#Calculation\n",
+ "a=mv*n; #amount paid by buyer(Rs)\n",
+ "cp=fv*n; #purchase cose(Rs)\n",
+ "g=a-cp; #gain by share holder(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain by share holder is\",g,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.11, Page number 18.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sale realisation is 4180.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "pc=4220; #purchase cost(Rs)\n",
+ "mv=105; #market value\n",
+ "b=1/2; #brokerage(%)\n",
+ "\n",
+ "#Calculation\n",
+ "sr=pc*(mv-b)/(mv+b); #sale realisation(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"sale realisation is\",sr,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.12, Page number 18.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cost of 80 shares is 780.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "fv=10; #face value(Rs)\n",
+ "d=3/8; #discount\n",
+ "b=1/8; #brokerage(%)\n",
+ "n=80; #number of shares\n",
+ "\n",
+ "#Calculation\n",
+ "c1=fv-d+b; #cost of 1 share(Rs)\n",
+ "C=n*c1; #cost of 80 shares(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"cost of 80 shares is\",C,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.13, Page number 18.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount invested in 3% stock is 540.0 Rs\n",
+ "amount invested in 8% stock is 4860.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "mvb=120;\n",
+ "a=4500; #amount(Rs)\n",
+ "r=5; #rate of stock(%)\n",
+ "i=75; #income(Rs)\n",
+ "x1=99;\n",
+ "x2=132; \n",
+ "r1=3; #rate(%) \n",
+ "r2=8; #rate(%)\n",
+ "\n",
+ "#Calculation\n",
+ "sr=mvb*a/100; #sale realisation(Rs) \n",
+ "Is=a*r/100; #income before selling(Rs)\n",
+ "Ias=Is+i; #income after sale(Rs)\n",
+ "\n",
+ "\n",
+ "l=x1*x2/gcd(x1,x2); #lcm of x1 and x2\n",
+ "X=l*Ias;\n",
+ "f1=l/x1;\n",
+ "f2=l/x2;\n",
+ "c1=r2*f1; #c1=r2*f1\n",
+ "c2=r1*f1;\n",
+ "c=l*r2*sr/x2;\n",
+ "x=(c-X)/(c1-c2); #amount invested in 3% stock(Rs)\n",
+ "y=sr-x; #amount invested in 8% stock(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount invested in 3% stock is\",x,\"Rs\"\n",
+ "print \"amount invested in 8% stock is\",y,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.14, Page number 18.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "income derived is 300.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=2592; #investment(Rs)\n",
+ "mvb=108;\n",
+ "fv=100; #face value(Rs)\n",
+ "d=25/2; #dividend(%)\n",
+ "\n",
+ "#Calculation\n",
+ "I=i*d*fv/(mvb*100); #income derived(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"income derived is\",I,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.15, Page number 18.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate of interest on investment is 3.37 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "r=17/4; #rate(%)\n",
+ "fv=20; #face value(Rs)\n",
+ "n=88; #number of shares\n",
+ "p=5; #premium\n",
+ "b=1/4; #brokerage(%)\n",
+ "\n",
+ "#Calculation\n",
+ "d=r*fv*n/100; #dividend(Rs)\n",
+ "pc=fv+p+b; #purchase cost(Rs)\n",
+ "R=r*fv/pc; #rate of interest on investment(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate of interest on investment is\",round(R,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.16, Page number 18.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "market value of each share is 110.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=4444; #investment(Rs)\n",
+ "I=600; #annual income(Rs)\n",
+ "fv=100; #face value(Rs)\n",
+ "d=15; #dividend(%)\n",
+ "b=1/100; #brokerage(%)\n",
+ "\n",
+ "#Calculation\n",
+ "M=i*d*fv/(I*100*(1+b)); #market value of each share(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"market value of each share is\",M,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.17, Page number 18.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "investment is 10504.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "I=1500; #annual income(Rs)\n",
+ "fv=100; #face value(Rs)\n",
+ "d=15; #dividend(%)\n",
+ "b=1/100; #brokerage(%)\n",
+ "M=104; #market value(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "i=I*100*M*(1+b)/(d*fv); #investment(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"investment is\",i,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 18.18, Page number 18.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "investment is better\n",
+ "investment in 1st case is 1440 Rs\n",
+ "investment in 2nd case is 1512 Rs\n",
+ "answer given in the book for 2nd case is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "d1=15; #debenture(%)\n",
+ "d2=14; #debenture(%)\n",
+ "p=8; #premium(%)\n",
+ "d=4; #discount(%)\n",
+ "\n",
+ "#Calculation\n",
+ "M1=100-d; #market value(Rs)\n",
+ "M2=100+p; #market value(Rs)\n",
+ "x=d1*M1; #investment(Rs)\n",
+ "y=d2*M2; #investment(Rs)\n",
+ "if(x<y):\n",
+ " print \"investment is better\"\n",
+ "else:\n",
+ " print \"investment is not better\"\n",
+ " \n",
+ "#Result\n",
+ "print \"investment in 1st case is\",x,\"Rs\"\n",
+ "print \"investment in 2nd case is\",y,\"Rs\"\n",
+ "print \"answer given in the book for 2nd case is wrong\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb new file mode 100755 index 00000000..61831463 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter19.ipynb @@ -0,0 +1,866 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 19: Time and Distance"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.1, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance covered is 700.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=3.5; #speed(km/h)\n",
+ "t=12/60; #time(hr)\n",
+ "\n",
+ "#Calculation\n",
+ "d=s*t*1000; #distance covered(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance covered is\",d,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.2, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken is 2 hour 45 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=124; #distance(km)\n",
+ "s=45; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "t=d/s; #time(hr)\n",
+ "tm=(t-int(t))*60; #time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken is\",int(t),\"hour\",int(tm),\"minutes\" "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.3, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken is 5.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=360*1000; #distance(m)\n",
+ "v=20; #velocity(m/s)\n",
+ "\n",
+ "#Calculation\n",
+ "t=d/v; #time taken(min)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken is\",t/(60*60),\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.4, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time taken is 50.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=4; #number of rests\n",
+ "tr=5; #time for each rest(min)\n",
+ "d=5; #distance(km)\n",
+ "s=10; #speed(km/hr)\n",
+ "\n",
+ "#Calculation\n",
+ "rt=n*tr; #rest time(min)\n",
+ "t=(d*60/s)+rt; #total time taken(min)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time taken is\",t,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.5, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "usual time is 15.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=5/7; #factor\n",
+ "deltat=6; #change in time(min)\n",
+ "\n",
+ "#Calculation\n",
+ "bbya=1/abyb; \n",
+ "t=deltat/(bbya-1); #usual time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"usual time is\",t,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.6, Page number 19.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "usual time is 28.0 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=7/6; #factor\n",
+ "deltat=4; #change in time(min)\n",
+ "\n",
+ "#Calculation\n",
+ "bbya=1/abyb; \n",
+ "t=deltat/(1-bbya); #usual time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"usual time is\",t,\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.7, Page number 19.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance is 5.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t=10+5; #difference in time(min)\n",
+ "v1=4; #speed(km/h)\n",
+ "v2=5; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "d=v1*v2*t/60; #distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.8, Page number 19.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "slower speed of train is 25.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t1=8; #time(hr)\n",
+ "t2=6+(40/60); #time(hr)\n",
+ "d=5; #distance(km)\n",
+ "\n",
+ "#Calculation\n",
+ "v=d/((t1/t2)-1); #slower speed of train(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"slower speed of train is\",v,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.9, Page number 19.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "train stops at 15.0 minutes/hour\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s1=80; #speed(km/h)\n",
+ "s2=60; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "st=(s1-s2)/s1; #stoppage time(hr)\n",
+ "\n",
+ "#Result\n",
+ "print \"train stops at\",st*60,\"minutes/hour\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.10, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance is 60.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=4; #speed(km/h)\n",
+ "a=30/60; #time(hr)\n",
+ "y=2; #speed(km/h)\n",
+ "b=20/60; #time(hr)\n",
+ "\n",
+ "#Calculation\n",
+ "d=(x+y)*(a+b)*a*b*x*y/((b*x)-(a*y))**2; #distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.11, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance ran by theif is 800.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=400; #distance(m)\n",
+ "s1=10; #speed(km/h)\n",
+ "s2=15; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "x=d*s1/(s2-s1); #distance ran by theif(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance ran by theif is\",x,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.12, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed is 70.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d1=450; #distance(km)\n",
+ "d2=740; #distance(km)\n",
+ "t1=7; #time(hrs)\n",
+ "t2=10; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=(d1+d2)/(t1+t2); #average speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed is\",Va,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.13, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed is 48.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V1=60; #speed(km/h)\n",
+ "V2=40; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=2*V1*V2/(V1+V2); #average speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed is\",Va,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.14, Page number 19.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed is 63 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V1=40; #speed(km/h)\n",
+ "V2=60; #speed(km/h)\n",
+ "V3=70; #speed(km/h)\n",
+ "t1=30/60; #time(hrs)\n",
+ "t2=45/60; #time(hrs)\n",
+ "t3=2; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=((V1*t1)+(V2*t2)+(V3*t3))/(t1+t2+t3); #average speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed is\",int(Va),\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.15, Page number 19.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken to travel is 2.0 hours\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V1=60; #speed(km/h)\n",
+ "V2=30; #speed(km/h)\n",
+ "d=240; #distance(km)\n",
+ "t=6; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "Va=d/t; #average speed(km/h)\n",
+ "t60=Va-V2;\n",
+ "t30=V1-Va;\n",
+ "T=t60*t/(t60+t30); #time taken to travel(hours)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken to travel is\",T,\"hours\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.16, Page number 19.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance travelled by car is 140 km\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t=2; #time(hrs)\n",
+ "v1=100; #speed(km/h)\n",
+ "v2=50; #speed(km/h)\n",
+ "d=170; #distance(km)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(t*d)-(t*v1); #distance travelled by car(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance travelled by car is\",x,\"km\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.17, Page number 19.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total distance is 3.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=42; #total time(min)\n",
+ "v1=4; #speed(km/h)\n",
+ "v2=5; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "d=T/(v1+(2*v2)); #total distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"total distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.18, Page number 19.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "original speed is 60.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=840; #distance(km)\n",
+ "t=2; #time(hrs)\n",
+ "s=10; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "x=d*s/(s*t); \n",
+ "y=x/(t*(t+1));\n",
+ "V=d*s/(t*y); #original speed(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"original speed is\",V,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.19, Page number 19.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time taken is 6 1/4 hrs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "tx=4+(30/60); #time(hrs)\n",
+ "ty=1+(45/60); #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "T=tx+ty; #total time taken(hrs)\n",
+ "x=T-int(T);\n",
+ "\n",
+ "#Result\n",
+ "print \"total time taken is\",int(T),Fraction(x),\"hrs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.20, Page number 19.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by A is 100 min\n",
+ "time taken by B is 80 min\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "rA=4;\n",
+ "rB=5; #rates of A and B\n",
+ "t=20; #time(min)\n",
+ "\n",
+ "#Calculation\n",
+ "tB=rA*t; #time taken by B(min)\n",
+ "tA=t*rB; #time taken by A(min)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by A is\",tA,\"min\"\n",
+ "print \"time taken by B is\",tB,\"min\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 19.21, Page number 19.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time taken is 4.33 hrs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "t=6+(30/60); #time(hrs)\n",
+ "tl=2+(10/60); #time lost(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "T=t-tl; #total time taken(hrs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time taken is\",round(T,2),\"hrs\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter2.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter2.ipynb new file mode 100755 index 00000000..c0146fd8 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter2.ipynb @@ -0,0 +1,786 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 2: HCF and LCM of numbers"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.1, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "greatest number that will exactly divide is 40\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=200;\n",
+ "b=320; #given two numbers\n",
+ "\n",
+ "#Calculation\n",
+ "n=gcd(a,b); #required number\n",
+ "\n",
+ "#Result\n",
+ "print \"greatest number that will exactly divide is\",n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.2, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "greatest number that will exactly divide is 12\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=148;\n",
+ "b=246;\n",
+ "c=623; #given three numbers\n",
+ "a1=4;\n",
+ "b1=6;\n",
+ "c1=11; #remainders left\n",
+ "\n",
+ "#Calculation\n",
+ "A=a-a1;\n",
+ "B=b-b1;\n",
+ "C=c-c1; #obtained three numbers\n",
+ "n=gcd(A,B); #GCD of A and B\n",
+ "rn=gcd(n,C); #GCD of all the 3 numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"greatest number that will exactly divide is\",rn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.3, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required least number is 6621.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=27;\n",
+ "n2=35;\n",
+ "n3=45;\n",
+ "n4=49; #given numbers\n",
+ "r=6; #remainder\n",
+ "\n",
+ "#Calculation\n",
+ "l1=n1*n2/gcd(n1,n2); #lcm of n1 and n2\n",
+ "l2=n3*n4/gcd(n3,n4); #lcm of n3 and n4\n",
+ "l=l1*l2/gcd(l1,l2); #lcm of the given 4 numbers\n",
+ "L=l+6; #required least number\n",
+ "\n",
+ "#Result\n",
+ "print \"required least number is\",L"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.4, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required least number is 565.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=36;\n",
+ "b=48;\n",
+ "c=64; #given three numbers\n",
+ "a1=25;\n",
+ "b1=37;\n",
+ "c1=53; #remainders left\n",
+ "\n",
+ "#Calculation\n",
+ "A=a-a1;\n",
+ "B=b-b1;\n",
+ "C=c-c1; #obtained three numbers\n",
+ "l1=a*b/gcd(a,b); #lcm of a and b\n",
+ "l2=l1*c/gcd(l1,c); #lcm of the given 3 numbers\n",
+ "L=l2-A; #required least number\n",
+ "\n",
+ "#Result\n",
+ "print \"required least number is\",L"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.5, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "greatest possible length of scale is 30 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=300;\n",
+ "b=510;\n",
+ "c=1290; #given three numbers(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "n=gcd(a,b); #gcd of a and b\n",
+ "rn=gcd(n,c); #gcd of all the numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"greatest possible length of scale is\",rn,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.6, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required least number when increased by change is 202.0\n",
+ "required least number when decreased by change is 218.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=15;\n",
+ "b=21;\n",
+ "c=30; #given three numbers\n",
+ "r=8; #change\n",
+ "\n",
+ "#Calculation\n",
+ "l1=a*b/gcd(a,b); #lcm of a and b\n",
+ "l2=l1*c/gcd(l1,c); #lcm of the given 3 numbers\n",
+ "L1=l2-r; #required least number when increased by change\n",
+ "L2=l2+r; #required least number when decreased by change\n",
+ "\n",
+ "#Result\n",
+ "print \"required least number when increased by change is\",L1\n",
+ "print \"required least number when decreased by change is\",L2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.7, Page number 2.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "greatest 4 digit number divisible by given numbers is 9660.0\n",
+ "answer given in the book is wrong\n",
+ "smallest 4 digit number divisible by given numbers is 1260.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=9999; #greatest 4 digit number\n",
+ "n0=1000; #smallest 4 digit number\n",
+ "n1=12;\n",
+ "n2=15;\n",
+ "n3=20;\n",
+ "n4=35; #given four numbers\n",
+ "\n",
+ "#Calculation\n",
+ "l1=n1*n2/gcd(n1,n2); #lcm of n1 and n2\n",
+ "l2=n3*n4/gcd(n3,n4); #lcm of n3 and n4\n",
+ "l=l1*l2/gcd(l1,l2); #lcm of the given 4 numbers\n",
+ "a=n%l; \n",
+ "A=n-a; #greatest 4 digit number divisible by given numbers\n",
+ "b=n0%l;\n",
+ "B=n0+l-b; #smallest 4 digit number divisible by given numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"greatest 4 digit number divisible by given numbers is\",A\n",
+ "print \"answer given in the book is wrong\"\n",
+ "print \"smallest 4 digit number divisible by given numbers is\",B"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.8, Page number 2.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "all bells toll together after an interval of 504.0 seconds\n",
+ "number of times they toll together in 2 hours is 14 times\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=6;\n",
+ "n2=7;\n",
+ "n3=8;\n",
+ "n4=9; #intervals(sec)\n",
+ "n=2; #number of hours\n",
+ "\n",
+ "#Calculation\n",
+ "l1=n1*n2/gcd(n1,n2); #lcm of n1 and n2\n",
+ "l2=n3*n4/gcd(n3,n4); #lcm of n3 and n4\n",
+ "l=l1*l2/gcd(l1,l2); #lcm of the given 4 numbers\n",
+ "t=n*60*60/l; #number of times they toll together\n",
+ "\n",
+ "print \"all bells toll together after an interval of\",l,\"seconds\"\n",
+ "print \"number of times they toll together in 2 hours is\",int(t),\"times\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.9, Page number 2.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "greatest 4 digit number divisible by given numbers is 9831.0\n",
+ "answer given in the book is wrong\n",
+ "smallest 4 digit number divisible by given numbers is 1011.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=9999; #greatest 4 digit number\n",
+ "n0=1000; #smallest 4 digit number\n",
+ "n1=12;\n",
+ "n2=18;\n",
+ "n3=21;\n",
+ "n4=28; #given four numbers\n",
+ "r=3; #remainder\n",
+ "\n",
+ "#Calculation\n",
+ "l1=n1*n2/gcd(n1,n2); #lcm of n1 and n2\n",
+ "l2=n3*n4/gcd(n3,n4); #lcm of n3 and n4\n",
+ "l=l1*l2/gcd(l1,l2); #lcm of the given 4 numbers\n",
+ "a=n%l; \n",
+ "A=n-a+r; #greatest 4 digit number divisible by given numbers\n",
+ "b=n0%l;\n",
+ "B=n0+l-b+r; #smallest 4 digit number divisible by given numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"greatest 4 digit number divisible by given numbers is\",A\n",
+ "print \"answer given in the book is wrong\"\n",
+ "print \"smallest 4 digit number divisible by given numbers is\",B"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.10, Page number 2.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required numbers are 221.0 and 293.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=6;\n",
+ "b=8;\n",
+ "c=9; #given three numbers\n",
+ "r=5; #remainder\n",
+ "\n",
+ "#Calculation\n",
+ "l1=a*b/gcd(a,b); #lcm of a and b\n",
+ "l2=l1*c/gcd(l1,c); #lcm of the given 3 numbers\n",
+ "n1=(l2*3)+r;\n",
+ "n2=(l2*4)+r; #required numbers \n",
+ "\n",
+ "#Result\n",
+ "print \"required numbers are\",n1,\"and\",n2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.11, Page number 2.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of Aluminium wire pieces is 15.0\n",
+ "number of Copper wire pieces is 8.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=960;\n",
+ "b=512; #length of wires(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "hcf=gcd(a,b); #HCF of two lengths\n",
+ "n1=a/hcf; #number of Aluminium wire pieces\n",
+ "n2=b/hcf; #number of Copper wire pieces\n",
+ "\n",
+ "#Result\n",
+ "print \"number of Aluminium wire pieces is\",n1\n",
+ "print \"number of Copper wire pieces is\",n2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.12, Page number 2.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the other number is 80.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "hcf=16; #HCF 0f two numbers \n",
+ "lcm=240; #LCM of two numbers\n",
+ "a=48; #one of the numbers\n",
+ "\n",
+ "#Calculation\n",
+ "b=hcf*lcm/a; #the other number\n",
+ "\n",
+ "#Result\n",
+ "print \"the other number is\",b"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.13, Page number 2.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of students is 35\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=105; #number of oranges\n",
+ "b=175; #number of bananas\n",
+ "\n",
+ "#Calculation\n",
+ "hcf=gcd(a,b); #number of students\n",
+ "\n",
+ "#Result\n",
+ "print \"number of students is\",hcf"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.14, Page number 2.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resultant HCF is 0.0011\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=11;\n",
+ "b=121;\n",
+ "c=1331; #given three numbers(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "n=gcd(a,b); #gcd of a and b\n",
+ "rn=gcd(n,c); #gcd of all the numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"resultant HCF is\",rn/10**4"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.15, Page number 2.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resultant LCM is 594.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=22;\n",
+ "b=540;\n",
+ "c=108; #given three numbers\n",
+ "\n",
+ "#Calculation\n",
+ "l1=a*b/gcd(a,b); #lcm of a and b\n",
+ "l=l1*c/gcd(l1,c); #lcm of the given 3 numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"resultant LCM is\",l/10"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.16, Page number 2.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resultant HCF is 243 or 3 ** 5\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3**5;\n",
+ "b=3**9;\n",
+ "c=3**14; #given three numbers(cm)\n",
+ "base=3;\n",
+ "i=[5, 9, 14] #indices\n",
+ "\n",
+ "#Calculation\n",
+ "n=gcd(a,b); #gcd of a and b\n",
+ "rn=gcd(n,c); #gcd of all the numbers\n",
+ "hcf=min(i);\n",
+ "\n",
+ "#Result\n",
+ "print \"resultant HCF is\",rn,\"or\",base,\"**\",hcf"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 2.17, Page number 2.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "resultant LCM is 4 ** 12\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=4**5;\n",
+ "b=4**-81;\n",
+ "c=4**12;\n",
+ "d=4**7; #given three numbers(cm)\n",
+ "base=4;\n",
+ "i=[5, -81, 12, 7] #indices\n",
+ "\n",
+ "#Calculation\n",
+ "lcm=max(i); #resultant LCM\n",
+ "\n",
+ "#Result\n",
+ "print \"resultant LCM is\",base,\"**\",lcm"
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter20.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter20.ipynb new file mode 100755 index 00000000..aa2212ac --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter20.ipynb @@ -0,0 +1,534 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#20: Trains"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.1, Page number 20.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken to cross a telegraph post is 6.6 s\n",
+ "time taken to cross a man running in same direction is 7.33 s\n",
+ "time taken to cross a man running in opposite direction is 6.0 s\n",
+ "time taken to cross a platform is 21.0 s\n",
+ "time taken to cross a train is 16.8 s\n",
+ "time taken to cross another train is 2 minutes 48.0 s\n",
+ "time taken to cross another train is 7.2 s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=60; #speed(km/h)\n",
+ "Lt=110; #length of train(m)\n",
+ "L1=0; \n",
+ "L2=240; #length of pplatform(m)\n",
+ "L3=170; #length of train(m)\n",
+ "v1=6; #speed of man(km/h)\n",
+ "v2=54; #speed of another train(km/hr)\n",
+ "v3=80; #speed of another train(km/hr)\n",
+ "\n",
+ "#Calculation\n",
+ "Vt=s*5/18; #speed of train(m/s)\n",
+ "V1=v1*5/18; #speed of man(m/s)\n",
+ "V2=v2*5/18; #speed of another train(m/s)\n",
+ "V3=v3*5/18; #speed of another train(m/s)\n",
+ "t1=(Lt+L1)/Vt; #time taken to cross a telegraph post(s)\n",
+ "t2=(Lt+L1)/(Vt-V1); #time taken to cross a man running in same direction(s)\n",
+ "t3=(Lt+L1)/(Vt+V1); #time taken to cross a man running in opposite direction(s) \n",
+ "t4=(Lt+L2)/Vt; #time taken to cross a platform(s)\n",
+ "t5=(Lt+L3)/Vt; #time taken to cross a train(s)\n",
+ "t6=(Lt+L3)/(Vt-V2); #time taken to cross another train(s)\n",
+ "t6m=int(t6/60); #time(m)\n",
+ "t6s=t6-(t6m*60);\n",
+ "t7=(Lt+L3)/(Vt+V3); #time taken to cross another train(s)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken to cross a telegraph post is\",t1,\"s\"\n",
+ "print \"time taken to cross a man running in same direction is\",round(t2,2),\"s\"\n",
+ "print \"time taken to cross a man running in opposite direction is\",t3,\"s\"\n",
+ "print \"time taken to cross a platform is\",t4,\"s\"\n",
+ "print \"time taken to cross a train is\",t5,\"s\"\n",
+ "print \"time taken to cross another train is\",t6m,\"minutes\",t6s,\"s\"\n",
+ "print \"time taken to cross another train is\",t7,\"s\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.2, Page number 20.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of platform is 240.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=54; #speed of train(km/hr)\n",
+ "t1=36; #time(s)\n",
+ "t2=20; #time(s)\n",
+ "V1=0;\n",
+ "V2=0;\n",
+ "L2=0;\n",
+ "\n",
+ "#Calculation\n",
+ "Vt=s*5/18; #speed of train(m/s)\n",
+ "a=Vt*(t1-t2);\n",
+ "L1=a+L2-(V1*t1)-(V2*t2); #length of platform(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of platform is\",L1,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.3, Page number 20.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of train is 12.5 m/s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L1=0; #length of man(m)\n",
+ "L2=150; #length of platform(m)\n",
+ "t1=10; #time(s)\n",
+ "t2=22; #time(s)\n",
+ "V1=0;\n",
+ "V2=0;\n",
+ "\n",
+ "#Calculation\n",
+ "a=(L1+(V1*t1))-(L2+(V2*t2));\n",
+ "Vt=a/(t1-t2); #speed of train(m/s)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of train is\",Vt,\"m/s\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.4, Page number 20.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of train is 50.0 m\n",
+ "length of platform is 75.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L2=0; #length of man(m)\n",
+ "t1=18; #time(s)\n",
+ "t2=10; #time(s)\n",
+ "V1=0;\n",
+ "V2=7*5/18; #speed(m/s)\n",
+ "Vt=25*5/18; #speed of train(m/s)\n",
+ "\n",
+ "#Calculation\n",
+ "Lt=((Vt-V2)*t2)-L2; #length of train(m)\n",
+ "L1=((Vt-V1)*t1)-Lt; #length of platform(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of train is\",Lt,\"m\"\n",
+ "print \"length of platform is\",L1,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.5, Page number 20.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of train is 45.0 m\n",
+ "length of platform is 75.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L2=0; #length of man(m)\n",
+ "t1=12; #time(s)\n",
+ "t2=6; #time(s)\n",
+ "V1=0;\n",
+ "V2=-9*5/18; #speed(m/s)\n",
+ "Vt=36*5/18; #speed of train(m/s)\n",
+ "\n",
+ "#Calculation\n",
+ "Lt=((Vt-V1)*t1)-L1; #length of train(m)\n",
+ "L1=((Vt-V1)*t1)-Lt; #length of platform(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of train is\",Lt,\"m\"\n",
+ "print \"length of platform is\",L1,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.6, Page number 20.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of train is 11.0 m/s\n",
+ "length of train is 65.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L1=210; #length of tunnel(m) \n",
+ "L2=122; #length of tunnel(m)\n",
+ "t1=25; #time(s)\n",
+ "t2=17; #time(s)\n",
+ "V1=0;\n",
+ "V2=0; #speed(m/s)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(L1+(V1*t1))-(L2+(V2*t2));\n",
+ "Vt=a/(t1-t2); #speed of train(m/s)\n",
+ "Lt=((Vt-V1)*t1)-L1; #length of train(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of train is\",Vt,\"m/s\"\n",
+ "print \"length of train is\",Lt,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.7, Page number 20.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by the train to cross the platform is 21.0 s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L1=250; #length of bridge(m) \n",
+ "L2=130; #length of platform(m)\n",
+ "Lt=150; #length of train(m)\n",
+ "t1=30; #time(s)\n",
+ "V1=0;\n",
+ "V2=0; #speed(m/s)\n",
+ "\n",
+ "#Calculation\n",
+ "t2=(Lt+L2)*t1/(Lt+L1); #time taken by the train to cross the platform(s)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by the train to cross the platform is\",t2,\"s\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.8, Page number 20.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken by the second train is 64.0 s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Lt1_Lt2=100; #difference in length(m)\n",
+ "Vt1=90*5/18; #speed of 1st train(m/s)\n",
+ "Vt2=45*5/18; #speed of 2nd train(m/s)\n",
+ "t1=36; #time(s)\n",
+ "\n",
+ "#Calculation\n",
+ "t2=((Vt1*t1)-Lt1_Lt2)/Vt2; #time taken by the second train(s)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken by the second train is\",t2,\"s\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.9, Page number 20.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of train is 94.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Lt=100; #length of train(m)\n",
+ "V=-6; #speed of train(m/s)\n",
+ "t=18/5; #time(s)\n",
+ "L=0;\n",
+ "\n",
+ "#Calculation\n",
+ "x=t*1/t;\n",
+ "Vt=(Lt+L+(x*V))/x; #speed of train(m/s)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of train is\",Vt,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "##Example number 20.10, Page number 20.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of second person is 3.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Lt=75; #length of train(m)\n",
+ "L1=L2=0;\n",
+ "t1=18; #time(s)\n",
+ "t2=15; #time(s)\n",
+ "V1=6*5/18; #speed(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(Lt+L1)/t1;\n",
+ "b=(Lt+L2)/t2;\n",
+ "V2=(a+V1-b)*18/5; #speed of second person(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of second person is\",V2,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 20.11, Page number 20.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of faster train is 42.0 m/s\n",
+ "speed of slower train is 38.0 m/s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L1=130; #length of train(m)\n",
+ "L2=110; #length of train(m)\n",
+ "t1=3;\n",
+ "t2=60; #time(s)\n",
+ "\n",
+ "#Calculation\n",
+ "s1=((L1+L2)/2)*((1/t1)+(1/t2)); #speed of faster train(m/s)\n",
+ "s2=((L1+L2)/2)*((1/t1)-(1/t2)); #speed of slower train(m/s)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of faster train is\",s1,\"m/s\"\n",
+ "print \"speed of slower train is\",s2,\"m/s\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter21.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter21.ipynb new file mode 100755 index 00000000..eaa1c595 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter21.ipynb @@ -0,0 +1,399 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#21: Boats and Streams"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.1, Page number 21.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "rate in still water is 5.0 km/h\n",
+ "speed of current is 3.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ds=8; #speed downstream(km/h)\n",
+ "us=2; #speed upstream(km/h)\n",
+ "\n",
+ "#Calculation\n",
+ "r=(ds+us)/2; #rate in still water(km/h)\n",
+ "s=(ds-us)/2; #speed of current(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"rate in still water is\",r,\"km/h\"\n",
+ "print \"speed of current is\",s,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.2, Page number 21.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of current is 1.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ddn=30; #distance downstream(km)\n",
+ "dup=20; #distance upstream(km)\n",
+ "tdn=5; #time downstream(hrs)\n",
+ "tup=5; #time upstream(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "s=(1/2)*((ddn/tdn)-(dup/tup)); #speed of current(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of current is\",s,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.3, Page number 21.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed in still water is 7.0 km/hr\n",
+ "speed of current is 1.0 km/hr\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=2; #distance(km)\n",
+ "tdn=20; #time downstream(min)\n",
+ "tup=15; #time upstream(min)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(d/2)*((1/tdn)+(1/tup)); #speed in still water(km/min)\n",
+ "x=x*60; #speed in still water(km/hr)\n",
+ "y=(d/2)*(-(1/tdn)+(1/tup)); #speed of current(km/min)\n",
+ "y=y*60; #speed of current(km/hr)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed in still water is\",x,\"km/hr\"\n",
+ "print \"speed of current is\",y,\"km/hr\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.4, Page number 21.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of stream is 1.3 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "r=4; #rate in still water(km/hr)\n",
+ "tdn=1; #assume\n",
+ "\n",
+ "#Calculation\n",
+ "tup=2*tdn; \n",
+ "d=(tdn+tup)/(tup-tdn);\n",
+ "s=r/d; #speed of stream(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of stream is\",round(s,1),\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.5, Page number 21.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance is 8.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=6; #speed in still water(km/hr)\n",
+ "y=2; #speed of river(km/hr)\n",
+ "t=3; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "d=t*(x+y)/(1+y); #distance(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"distance is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.6, Page number 21.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "distance in downstream is 7.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=15; #speed in still water(km/hr)\n",
+ "y=13; #rate of current(km/hr)\n",
+ "t=15/60; #time(hrs)\n",
+ "\n",
+ "#Calculation\n",
+ "d=(x+y)*t; #distance in downstream(km) \n",
+ "\n",
+ "#Result\n",
+ "print \"distance in downstream is\",d,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.7, Page number 21.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average speed for total journey is 4.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=4.5; #speed in still water(km/hr)\n",
+ "y=1.5; #rate of current(km/hr)\n",
+ "\n",
+ "#Calculation\n",
+ "avgs=(x+y)*(x-y)/x; #average speed for total journey(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"average speed for total journey is\",avgs,\"km/h\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.8, Page number 21.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of rowing in still water is 22\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=55; #time(min)\n",
+ "c=60; #conversion factor from min to h\n",
+ "y=2; #speed of stream(km/h)\n",
+ "d=10; #distance upstream(km)\n",
+ "\n",
+ "#Calculation\n",
+ "a=T/5; #coefficient of x**2\n",
+ "b=-c*y**2; #coefficient of x\n",
+ "c=-a*y**2; #constant\n",
+ "x=(b**2)-(4*a*c);\n",
+ "x1=-b+math.sqrt(x)/(2*a);\n",
+ "x2=-b-math.sqrt(x)/(2*a);\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of rowing in still water is\",int(x2/10)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 21.9, Page number 21.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "flow of river is 3.0 km/h\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=10; #speed in still water(km/h)\n",
+ "td=91; #total distance(km)\n",
+ "t=20; #time(h)\n",
+ "\n",
+ "#Calculation\n",
+ "d=t/s; #distance(km)\n",
+ "y2=(s**2)-td; \n",
+ "y=math.sqrt(y2); #flow of river(km/h)\n",
+ "\n",
+ "#Result\n",
+ "print \"flow of river is\",y,\"km/h\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter22.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter22.ipynb new file mode 100755 index 00000000..b0dd3f11 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter22.ipynb @@ -0,0 +1,534 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 22: Races "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.1, Page number 22.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A's time over the course is 241.0 sec\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "bt=9; #beat time(sec)\n",
+ "st=0; #start time(sec)\n",
+ "bd=36; #beat distance(m)\n",
+ "sd=0; #start distance(m)\n",
+ "L=1000-36; #loser's distance(m)\n",
+ "\n",
+ "#Calculation\n",
+ "At=(bt+st)*L/(bd+sd); #A's time over the course(sec)\n",
+ "\n",
+ "#Result\n",
+ "print \"A's time over the course is\",At,\"sec\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.2, Page number 22.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of race of winning post is 120.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V=1; #assume\n",
+ "A=4/3; #speed of A relative to B\n",
+ "d=30; #distance(m)\n",
+ "\n",
+ "#Calculation\n",
+ "L=d/(V-(1/A)); #length of race of winning post(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of race of winning post is\",L,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.3, Page number 22.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "start distance is 40.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "bt=0; #beat time(sec)\n",
+ "st=10; #start time(sec)\n",
+ "bd=0; #beat distance(m)\n",
+ "L=250; #loser's distance(m)\n",
+ "W=1000; #winner's distance(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x=L/W;\n",
+ "sd=((bt+st)/x)-bd; #start distance(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"start distance is\",sd,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.4, Page number 22.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "beat distance is 3.33 m\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "bt=10; #beat time(sec)\n",
+ "st=0; #start time(sec)\n",
+ "sd=0; #start distance(m)\n",
+ "L=300; #loser's distance(m)\n",
+ "W=100; #winner's distance(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x=L/W;\n",
+ "bd=((bt+st)/x)-sd; #beat distance(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"beat distance is\",round(bd,2),\"m\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.5, Page number 22.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "C would beat B by 2.04 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=100; #length of race(m)\n",
+ "x12=2; #A beats C by(m)\n",
+ "x13=4; #A beats B by(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x23=L*(x13-x12)/(L-x12); #C would beat B by(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"C would beat B by\",round(x23,2),\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.6, Page number 22.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "C would beat B by 20.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=1000; #length of race(m)\n",
+ "x12=50; #A beats C by(m)\n",
+ "x13=69; #A beats B by(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x23=L*(x13-x12)/(L-x12); #C would beat B by(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"C would beat B by\",x23,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.7, Page number 22.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of B is 1.6 m/s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ad=100; #distance of A(m)\n",
+ "Bd=Ad-4; #distance of B(m)\n",
+ "As=2; #speed of A(m/s)\n",
+ "bt=10; #beat time(sec)\n",
+ "st=0; #start time(sec)\n",
+ "\n",
+ "#Calculation\n",
+ "t=bt+st;\n",
+ "Bs=Bd/(t+(Ad/As)); #speed of B(m/s)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of B is\",Bs,\"m/s\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.8, Page number 22.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "B wins by 1.0 s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Bd=330; #distance of B(m)\n",
+ "Bt=44; #time of B(sec)\n",
+ "sd=30; #start distance(m)\n",
+ "A=41; #time taken for A(sec)\n",
+ "\n",
+ "#Calculation\n",
+ "B=Bt*(Bd-sd)/Bd; #time taken for B(sec)\n",
+ "T=A-B; #B wins by(s)\n",
+ "\n",
+ "#Result\n",
+ "print \"B wins by\",T,\"s\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.9, Page number 22.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time taken for A is 24.0 sec\n",
+ "answer given in the book is wrong\n",
+ "time taken for B is 30.0 sec\n",
+ "time taken for C is 32.0 sec\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=200; #length of race(m)\n",
+ "x12=40; #A beats C by(m)\n",
+ "x13=50; #A beats B by(m)\n",
+ "Tc=2; #time for C(sec)\n",
+ "\n",
+ "#Calculation\n",
+ "x23=L*(x13-x12)/(L-x12); #C would beat B by(m)\n",
+ "C=Tc*L/x23; #time taken for C(sec)\n",
+ "B=C-Tc; #time taken for B(sec)\n",
+ "A=B*(L-x12)/L; #time taken for A(sec)\n",
+ "\n",
+ "#Result\n",
+ "print \"time taken for A is\",A,\"sec\"\n",
+ "print \"answer given in the book is wrong\"\n",
+ "print \"time taken for B is\",B,\"sec\"\n",
+ "print \"time taken for C is\",C,\"sec\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.10, Page number 22.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A can give C a start of 64.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=1000; #length of race(m)\n",
+ "x12=40; #A beats C by(m)\n",
+ "x23=25; #A beats B by(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x13=(x23*(L-x12)/L)+x12; #A can give C a start of(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"A can give C a start of\",x13,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.11, Page number 22.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "A will beat C by 58.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=400; #length of race(m)\n",
+ "L1=600; #full length of race(m)\n",
+ "L2=500; #length of another race(m)\n",
+ "x12=60; #A beats B by(m)\n",
+ "x23=25; #A beats C by(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x12=x12*L/L1; #A beats B by(m)\n",
+ "x23=x23*L/L2; #A beats C by(m)\n",
+ "x13=(x23*(L-x12)/L)+x12; #A will beat C by(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"A will beat C by\",x13,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 22.12, Page number 22.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "speed of A is 8.0 m/s\n",
+ "speed of B is 7.0 m/s\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=400; #length of race(m)\n",
+ "Bt1=50/7; #time taken by B more than A(sec)\n",
+ "Bt2=5; #time taken by B with lesser distance(sec)\n",
+ "d=15; #lesser distance(m)\n",
+ "\n",
+ "#Calculation\n",
+ "Bt=Bt1-Bt2; #time taken for B(sec)\n",
+ "Bs=d/Bt; #speed of B(m/s)\n",
+ "VA=L/((L/Bs)-Bt1); #speed of A(m/s)\n",
+ "\n",
+ "#Result\n",
+ "print \"speed of A is\",VA,\"m/s\"\n",
+ "print \"speed of B is\",Bs,\"m/s\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter23.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter23.ipynb new file mode 100755 index 00000000..0046f9dc --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter23.ipynb @@ -0,0 +1,392 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 23: Clocks"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.1, Page number 23.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required time is 16.36 minutes past 3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=3; #initial position of hour hand\n",
+ "A=0; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T=(2/11)*((H*30)+A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"required time is\",round(T,2),\"minutes past\",H"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.2, Page number 23.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "one timing is 38.18 minutes past 4\n",
+ "another timing is 5.45 minutes past 4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=4; #initial position of hour hand\n",
+ "A=90; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T1=(2/11)*((H*30)+A); #required time(minutes)\n",
+ "T2=(2/11)*((H*30)-A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"one timing is\",round(T1,2),\"minutes past\",H\n",
+ "print \"another timing is\",round(T2,2),\"minutes past\",H"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.3, Page number 23.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "one timing is 54.545 minutes past 7\n",
+ "another timing is 21.818 minutes past 7\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=7; #initial position of hour hand\n",
+ "A=90; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T1=(2/11)*((H*30)+A); #required time(minutes)\n",
+ "T2=(2/11)*((H*30)-A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"one timing is\",round(T1,3),\"minutes past\",H\n",
+ "print \"another timing is\",round(T2,3),\"minutes past\",H"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.4, Page number 23.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required time is 5.45 minutes past 7\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=7; #initial position of hour hand\n",
+ "A=180; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T=(2/11)*((H*30)-A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"required time is\",round(T,2),\"minutes past\",H\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.5, Page number 23.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "one timing is 34.909 minutes past 5\n",
+ "another timing is 19.636 minutes past 5\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=5; #initial position of hour hand\n",
+ "A=42; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T1=(2/11)*((H*30)+A); #required time(minutes)\n",
+ "T2=(2/11)*((H*30)-A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"one timing is\",round(T1,3),\"minutes past\",H\n",
+ "print \"another timing is\",round(T2,3),\"minutes past\",H"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.6, Page number 23.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "true time is 55.08 minutes past 5 p.m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ti=6-1; #time interval(hours)\n",
+ "h=1/60; #hour gained(hour)\n",
+ "\n",
+ "\n",
+ "#Calculation\n",
+ "Tti=Ti/(1+h); #true time interval(hours)\n",
+ "Tt=1+Tti; #true time(hours)\n",
+ "H=int(Tt); #hour hand(p.m)\n",
+ "m=(Tt-H)*60; #true time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"true time is\",round(m,2),\"minutes past\",H,\"p.m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.7, Page number 23.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required time is 27.27 minutes past 2 and at 3 o' clock\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=2; #initial position of hour hand\n",
+ "A=90; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T1=(2/11)*((H*30)+A); #required time(minutes)\n",
+ "T2=(2/11)*((H*30)-A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"required time is\",round(T1,2),\"minutes past\",H,\"and at\",H+1,\"o' clock\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.8, Page number 23.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total time gained is 5.035 minutes\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "T=12; #time(hours)\n",
+ "x=65; #time(minutes)\n",
+ "y=65+(5/11); #time interval(minutes)\n",
+ "\n",
+ "#Calculation\n",
+ "Ttg=(T*60)*(y-x)/x; #total time gained(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"total time gained is\",round(Ttg,3),\"minutes\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 23.9, Page number 23.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required time is 16.36 minutes and 49.09 minutes past 12\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "H=0; #initial position of hour hand\n",
+ "A=90; #required angle(degrees)\n",
+ "\n",
+ "#Calculation\n",
+ "T1=(2/11)*((H*30)+A); #required time(minutes)\n",
+ "T2=(2/11)*(360+(H*30)-A); #required time(minutes)\n",
+ "\n",
+ "#Result\n",
+ "print \"required time is\",round(T1,2),\"minutes and\",round(T2,2),\"minutes past 12\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter24.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter24.ipynb new file mode 100755 index 00000000..fae1af80 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter24.ipynb @@ -0,0 +1,1109 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 24: Area of plane figures"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.1, Page number 24.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of triangle is 150.0 cm**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "b=15; #base(cm)\n",
+ "h=20; #altitude(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=b*h/2; #area of triangle(cm**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of triangle is\",A,\"cm**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.2, Page number 24.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "perpendicular length is 10.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "A=205; #area of triangle(cm**2)\n",
+ "s=41; #side(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "p=2*A/s; #perpendicular length(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"perpendicular length is\",p,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.3, Page number 24.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area is 6 *math.sqrt(6) cm**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=5;\n",
+ "b=6;\n",
+ "c=7; #sides of triangle(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "s=(a+b+c)/2; #semi perimeter(cm)\n",
+ "A=math.sqrt(s*(s-a)*(s-b)*(s-c)); #base area(cm**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area is\",int(A/math.sqrt(6)),\"*math.sqrt(6) cm**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.4, Page number 24.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area is 6.928 cm**2\n",
+ "perimeter is 12 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=4; #side of triangle(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=math.sqrt(3)*a**2/4; #area(cm**2)\n",
+ "P=3*a; #perimeter(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"area is\",round(A,3),\"cm**2\"\n",
+ "print \"perimeter is\",P,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.5, Page number 24.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area is 60.0 cm**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "b=10; #base(cm)\n",
+ "a=13; #side(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=b*math.sqrt((4*a**2)-(b**2))/4; #area(cm**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area is\",A,\"cm**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.6, Page number 24.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of each side is 32.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=100; #perimeter(cm)\n",
+ "b=36; #base(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(P-b)/2; #length of each side(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of each side is\",a,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.7, Page number 24.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of triangle is 200.0 cm**2\n",
+ "perimeter of triangle is 68.3 cm\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=20; #length of one leg(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=l**2/2; #area of triangle(cm**2)\n",
+ "P=l*(2+math.sqrt(2)); #perimeter of triangle(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of triangle is\",A,\"cm**2\"\n",
+ "print \"perimeter of triangle is\",round(P,1),\"cm\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.8, Page number 24.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of hypotenuse is 13.0 cm\n",
+ "area of triangle is 30.0 cm**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l1=12; #length of one leg(cm)\n",
+ "l2=5; #length of another leg(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "h=math.sqrt(l1**2+l2**2); #length of hypotenuse(cm)\n",
+ "A=l1*l2/2; #area of triangle(cm**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of hypotenuse is\",h,\"cm\"\n",
+ "print \"area of triangle is\",A,\"cm**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.9, Page number 24.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of rectangle is 720 cm**2\n",
+ "perimeter of rectangle is 112 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=36; #length(cm)\n",
+ "b=20; #breadth(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=l*b; #area of rectangle(cm**2)\n",
+ "P=2*(l+b); #perimeter of rectangle(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of rectangle is\",A,\"cm**2\"\n",
+ "print \"perimeter of rectangle is\",P,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.10, Page number 24.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of rectangle is 60.0 cm**2\n",
+ "perimeter of rectangle is 34.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=12; #length of rectangle(cm)\n",
+ "d=13; #diagonal of rectangle(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=l*math.sqrt(d**2-l**2); #area of rectangle(cm**2)\n",
+ "P=2*(l+math.sqrt(d**2-l**2)); #perimeter of rectangle(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of rectangle is\",A,\"cm**2\"\n",
+ "print \"perimeter of rectangle is\",P,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.11, Page number 24.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "diagonal of rectangle is 25.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=20; #length(cm)\n",
+ "b=15; #breadth(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "d=math.sqrt(l**2+b**2); #diagonal of rectangle(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"diagonal of rectangle is\",d,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.12, Page number 24.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of rectangle is 12.0 cm**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=14; #perimeter of rectangle(cm)\n",
+ "d=5; #diagonal(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=((P**2/4)-(d**2))/2; #area of rectangle(cm**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of rectangle is\",A,\"cm**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.13, Page number 24.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of rectangle is 24.0 cm\n",
+ "breadth of rectangle is 10.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "P=68; #perimeter of rectangle(cm)\n",
+ "A=240; #area of rectangle(cm**2)\n",
+ "\n",
+ "#Calculation\n",
+ "l=A/10; #length of rectangle(cm)\n",
+ "y=P/2;\n",
+ "b=y-l; #breadth of rectangle(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of rectangle is\",l,\"cm\"\n",
+ "print \"breadth of rectangle is\",b,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.14, Page number 24.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area is 100 cm**2\n",
+ "perimeter is 40 cm\n",
+ "diagonal is 14.14 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=10; #side of square(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=a**2; #area(cm**2)\n",
+ "P=4*a; #perimeter(cm)\n",
+ "d=a*math.sqrt(2); #diagonal(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"area is\",A,\"cm**2\"\n",
+ "print \"perimeter is\",P,\"cm\"\n",
+ "print \"diagonal is\",round(d,2),\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.15, Page number 24.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "diagonal is 900 m\n",
+ "perimeter is 120.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "A=900; #area(m**2)\n",
+ "\n",
+ "#Calculation\n",
+ "d=math.sqrt(2*A); #diagonal(m)\n",
+ "P=math.sqrt(16*A); #perimeter(m) \n",
+ "\n",
+ "#Result\n",
+ "print \"diagonal is\",A,\"m\"\n",
+ "print \"perimeter is\",P,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.16, Page number 24.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area is 200.0 cm**2\n",
+ "perimeter is 56.569 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=20; #diagonal(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=d**2/2; #area(cm**2)\n",
+ "P=math.sqrt(16*A); #perimeter(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"area is\",A,\"cm**2\"\n",
+ "print \"perimeter is\",round(P,3),\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.17, Page number 24.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area is 600.0 m**2\n",
+ "perimeter is 100.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d1=40; #first diagonal(m)\n",
+ "d2=30; #second diagonal(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=d1*d2/2; #area(m**2)\n",
+ "P2=4*(d1**2+d2**2); \n",
+ "p=math.sqrt(P2); #perimeter(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"area is\",A,\"m**2\"\n",
+ "print \"perimeter is\",p,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.18, Page number 24.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of rhombus is 260 cm**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=13; #side of rhombus(cm)\n",
+ "h=20; #height of rhombus(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=a*h; #area of rhombus(cm**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of rhombus is\",A,\"cm**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.19, Page number 24.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of rhombus is 300.0 m**2\n",
+ "perimeter of rhombus is 100.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=25; #side of rhombus(m)\n",
+ "h=40; #height of rhombus(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=d*math.sqrt((a**2)-((h/2)**2)); ##area of rhombus(m**2)\n",
+ "P=4*a; #perimeter of rhombus(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of rhombus is\",A,\"m**2\"\n",
+ "print \"perimeter of rhombus is\",p,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.20, Page number 24.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of quadrilateral is 120.0 m**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=12; #diagonal(cm)\n",
+ "p1=13; #length of offset 1(cm)\n",
+ "p2=7; #length of offset 2(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "A=d*(p1+p2)/2; #area of quadrilateral(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of quadrilateral is\",A,\"m**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.21, Page number 24.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of parallelogram is 600 m**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=30; #length of diagonal(m)\n",
+ "l=20; #length of perpendicular(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=d*l; #area of parallelogram(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of parallelogram is\",A,\"m**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.22, Page number 24.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of parallelogram is 151.789 m**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=12; #length of side 1(m)\n",
+ "b=14; #length of side 2(m)\n",
+ "d=22; #length of diagonal(m)\n",
+ "\n",
+ "#Calculation\n",
+ "S=(a+b+d)/2; #semi perimeter(m)\n",
+ "A=2*math.sqrt(S*(S-a)*(S-b)*(S-d)); #area of parallelogram(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of parallelogram is\",round(A,3),\"m**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.23, Page number 24.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of second diagonal is 18.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=13; #length of side 1(m)\n",
+ "b=11; #length of side 2(m)\n",
+ "d1=16; #length of diagonal 1(m)\n",
+ "\n",
+ "#Calculation\n",
+ "d22=(2*(a**2+b**2))-(d1**2); \n",
+ "d2=math.sqrt(d22); #length of second diagonal(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of second diagonal is\",d2,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.24, Page number 24.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of trapezium is 270.0 m**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=20; #length of parallel side 1(m)\n",
+ "b=25; #length of parallel side 2(m) \n",
+ "h=12; #distance(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=(a+b)*h/2; #area of trapezium(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of trapezium is\",A,\"m**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.25, Page number 24.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of trapezium is 5673.66 m**2\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=120; #length of parallel side 1(m)\n",
+ "b=75; #length of parallel side 2(m) \n",
+ "c=105; #length of non parallel side 1(m)\n",
+ "d=72; #length of non parallel side 2(m) \n",
+ "\n",
+ "#Calculation\n",
+ "K=a-b; #difference of parallel sides(m)\n",
+ "S=(K+c+d)/2; #semi perimeter(m)\n",
+ "x=S*(S-K)*(S-c)*(S-d); \n",
+ "A=(a+b)*math.sqrt(x)/K; #area of trapezium(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of trapezium is\",round(A,2),\"m**2\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.26, Page number 24.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of circle is 616.0 m**2\n",
+ "circumference of circle is 88.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "r=14; #radius(m)\n",
+ "\n",
+ "#Calculation\n",
+ "C=2*math.pi*r; #circumference of circle(m)\n",
+ "A=math.pi*r**2; #area of circle(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of circle is\",round(A),\"m**2\"\n",
+ "print \"circumference of circle is\",round(C),\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 24.27, Page number 24.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of circle is 154.0 m**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "C=44; #circumference of circle(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=C**2/(4*math.pi); #area of circle(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of circle is\",round(A),\"m**2\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter25.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter25.ipynb new file mode 100755 index 00000000..15760b75 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter25.ipynb @@ -0,0 +1,611 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 25: Volume and area of solid figures"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.1, Page number 25.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of diagonal is 23.75 m\n",
+ "surface area is 880 m**2\n",
+ "volume is 1600 m**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=20; #length of cuboid(m)\n",
+ "b=10; #breadth of cuboid(m)\n",
+ "h=8; #height of cuboid(m)\n",
+ "\n",
+ "#Calculation\n",
+ "d=math.sqrt(l**2+b**2+h**2); #length of diagonal(m)\n",
+ "S=2*((l*b)+(b*h)+(l*h)); #surface area(m**2)\n",
+ "V=l*b*h; #volume(m**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of diagonal is\",round(d,2),\"m\"\n",
+ "print \"surface area is\",S,\"m**2\"\n",
+ "print \"volume is\",V,\"m**3\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.2, Page number 25.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of diagonal is 20.78 m\n",
+ "surface area is 864 m**2\n",
+ "volume is 1728 m**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "e=12; #edge(m)\n",
+ "\n",
+ "#Calculation\n",
+ "d=e*math.sqrt(3); #length of diagonal(m)\n",
+ "S=6*(e**2); #surface area(m**2)\n",
+ "V=e**3; #volume(m**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"length of diagonal is\",round(d,2),\"m\"\n",
+ "print \"surface area is\",S,\"m**2\"\n",
+ "print \"volume is\",V,\"m**3\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.3, Page number 25.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "volume is 1331.0 m**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "S=726; #surface area(m**2)\n",
+ "\n",
+ "#Calculation\n",
+ "V=(math.sqrt(S/6))**3; #volume(m**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"volume is\",V,\"m**3\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.4, Page number 25.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "volume is 7999.0 m**3\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=34.64; #length of diagonal(m)\n",
+ "\n",
+ "#Calculation\n",
+ "V=(d/math.sqrt(3))**3; #volume(m**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"volume is\",round(V),\"m**3\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.5, Page number 25.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "volume of wood is 82125.0 cm**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l=115; #length of box(cm)\n",
+ "b=75; #breadth of box(cm)\n",
+ "h=35; #height of box(cm)\n",
+ "t=2.5; #thickness(cm)\n",
+ "\n",
+ "#Calculation\n",
+ "IV=l*b*h; #internal volume(cm**3)\n",
+ "EV=(l+(2*t))*(b+(2*t))*(h+(2*t)); #external volume(cm**3)\n",
+ "V=EV-IV; #volume of wood(cm**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"volume of wood is\",V,\"cm**3\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.6, Page number 25.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "thickness is 0.01 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V=1; #volume(m**3)\n",
+ "A=10000; #area(m**2)\n",
+ "\n",
+ "#Calculation\n",
+ "x=V*100/A; #thickness(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"thickness is\",x,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.7, Page number 25.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "time to empty is 116.71 hours\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V=54*44*10; #volume of reservoir(m**3)\n",
+ "R=3/100; #radius(m)\n",
+ "r=20; #empty rate(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=math.pi*R**2; #area of pipe(m**2)\n",
+ "t=V/(A*r); #time to empty(sec)\n",
+ "\n",
+ "#Result\n",
+ "print \"time to empty is\",round(t/3600,2),\"hours\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.8, Page number 25.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "depth of rain is 2.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "V=3000; #volume of water(m**3)\n",
+ "A=500*300; #surface area(m**2)\n",
+ "\n",
+ "#Calculation\n",
+ "x=V*100/A; #depth of rain(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"depth of rain is\",x,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.9, Page number 25.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "base area is 6.0 m**2\n",
+ "volume is 60.0 m**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3;\n",
+ "b=4;\n",
+ "c=5; #sides of a triangle(m)\n",
+ "h=10; #height of prism(m)\n",
+ "\n",
+ "#Calculation\n",
+ "s=(a+b+c)/2; #semi perimeter(m)\n",
+ "A=math.sqrt(s*(s-a)*(s-b)*(s-c)); #base area(m**2)\n",
+ "V=A*h; #volume(m**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"base area is\",A,\"m**2\"\n",
+ "print \"volume is\",V,\"m**3\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.10, Page number 25.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "volume is 509 m**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=7; #base of triangle(m)\n",
+ "h=24; #height(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=math.sqrt(3)*(a**2)/4; #base area(m**2)\n",
+ "V=A*h; #volume(m**3)\n",
+ "\n",
+ "#Result\n",
+ "print \"volume is\",int(V),\"m**3\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.11, Page number 25.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of wire is 2909.0 kg\n",
+ "answer varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "h=300*10**3; #height(m)\n",
+ "d=1/9*10**-2; #diameter(m)\n",
+ "w=270; #weight of copper wire(kg)\n",
+ "v=0.027; #per m**3\n",
+ "\n",
+ "#Calculation\n",
+ "A=math.pi*(d**2)/4; #area(m**2)\n",
+ "V=A*h; #volume of wire(m**3)\n",
+ "W=V*w/v; #weight of wire(kg) \n",
+ "\n",
+ "#Result\n",
+ "print \"weight of wire is\",round(W),\"kg\"\n",
+ "print \"answer varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.12, Page number 25.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of discharge pipes is 4.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "r1=6/2; #radius of 1 pipe(cm)\n",
+ "r2=3/2; #radius of another pipe(cm)\n",
+ "h=1; #assume\n",
+ "\n",
+ "#Calculation\n",
+ "V1=math.pi*r1**2*h; #volume of water in supply pipe(cm**3)\n",
+ "V2=math.pi*r2**2*h; #volume of water in discharge pipe(cm**3)\n",
+ "N=V1/V2; #number of discharge pipes\n",
+ "\n",
+ "#Result\n",
+ "print \"number of discharge pipes is\",N"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.13, Page number 25.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of iron is 108.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "di=10/100; #internal diameter(m)\n",
+ "de=12/100; #external diameter(m)\n",
+ "l=4; #length(m)\n",
+ "w=7800; #weight of iron(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "V=math.pi*l*(de**2-di**2)/4; #volume of iron(m**3)\n",
+ "W=V*w; #weight of iron(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of iron is\",round(W),\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 25.14, Page number 25.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "volume of pyramid is 166.67 m**3\n",
+ "lateral surface is 150.0 m**2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "h=10; #height of pyramid(m)\n",
+ "d=10; #length of diagonal(m)\n",
+ "\n",
+ "#Calculation\n",
+ "A=d**2/2; #base area(m**2)\n",
+ "V=A*h/3; #volume of pyramid(m**3)\n",
+ "a=d/math.sqrt(2); #side of square(m)\n",
+ "p=4*a; #base perimeter(m)\n",
+ "x=(h**2)+(a/2)**2; \n",
+ "l=math.sqrt(x); #slant height(m)\n",
+ "Ls=p*l/2; #lateral surface(m**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"volume of pyramid is\",round(V,2),\"m**3\"\n",
+ "print \"lateral surface is\",Ls,\"m**2\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter3.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter3.ipynb new file mode 100755 index 00000000..dee2bda5 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter3.ipynb @@ -0,0 +1,738 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 3: Fraction"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.1, Page number 3.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the descending order for 1st case is [0.8571428571428571, 0.8333333333333334, 0.75, 0.625]\n",
+ "the descending order for 2nd case is [0.6, 0.5, 0.42, 0.3]\n",
+ "the descending order for 3rd case is [0.5833333333333334, 0.4722222222222222, 0.3333333333333333, 0.3125]\n",
+ "the descending order for 4th case is [0.9326923076923077, 0.8125, 0.7142857142857143, 0.6]\n",
+ "the descending order for 5th case is [0.02824858757062147, 0.023297491039426525, 0.02197802197802198, 0.02016498625114574]\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "numbers1=[5/6,3/4,5/8,6/7];\n",
+ "numbers2=[1/2,3/5,3/10,21/50];\n",
+ "numbers3=[7/12,5/16,17/36,1/3];\n",
+ "numbers4=[3/5,5/7,13/16,97/104];\n",
+ "numbers5=[2/91,5/177,22/1091,13/558];\n",
+ "\n",
+ "#Calculation\n",
+ "a1=sorted(numbers1,reverse=True); #descending order for 1st case\n",
+ "a2=sorted(numbers2,reverse=True); #descending order for 2nd case\n",
+ "a3=sorted(numbers3,reverse=True); #descending order for 3rd case\n",
+ "a4=sorted(numbers4,reverse=True); #descending order for 4th case\n",
+ "a5=sorted(numbers5,reverse=True); #descending order for 5th case\n",
+ "\n",
+ "#Result\n",
+ "print \"the descending order for 1st case is\",a1\n",
+ "print \"the descending order for 2nd case is\",a2\n",
+ "print \"the descending order for 3rd case is\",a3\n",
+ "print \"the descending order for 4th case is\",a4\n",
+ "print \"the descending order for 5th case is\",a5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.2, Page number 3.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required amount is 900.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=5/12; #part\n",
+ "p2=3+(3/4); #part\n",
+ "a=100; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=p2*a/p1; #required amount(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"required amount is\",x,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.3, Page number 3.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required fraction is 0.1\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=5*12; #number of bananas\n",
+ "fp=6; #fraction part\n",
+ "\n",
+ "#Calculation\n",
+ "rf=fp/n; #required fraction\n",
+ "\n",
+ "#Result\n",
+ "print \"required fraction is\",rf"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.4, Page number 3.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of absentees is 12.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=40; #number of students\n",
+ "np=7/10; #number of students present\n",
+ "\n",
+ "#Calculation\n",
+ "na=(1-np)*n; #number of absentees\n",
+ "\n",
+ "#Result\n",
+ "print \"number of absentees is\",na"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.5, Page number 3.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "savings is 1400.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "ps=2/7; #part of savings\n",
+ "al=1000; #amount left(Rs) \n",
+ "\n",
+ "#Calculation\n",
+ "s=al/(1-ps); #savings(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"savings is\",s,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.6, Page number 3.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total number of pages is 320.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=3/8; \n",
+ "xbyy=4/5;\n",
+ "pl=40; #pages left\n",
+ "\n",
+ "#Calculation\n",
+ "p=pl/((1-abyb)*(1-xbyy)); #total number of pages\n",
+ "\n",
+ "#Result\n",
+ "print \"total number of pages is\",p"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.7, Page number 3.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total salary is 8000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=2/5; \n",
+ "xbyy=3/10;\n",
+ "mbyn=1/8;\n",
+ "ba=1400; #balance amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "ts=ba/(1-(abyb+xbyy+mbyn)); #total salary(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total salary is\",ts,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.8, Page number 3.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total salary is 4400.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=1/3; \n",
+ "xbyy=1/4;\n",
+ "mbyn=1/5;\n",
+ "ba=1760; #balance amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "ts=ba/((1-abyb)*(1-xbyy)*(1-mbyn)); #total salary(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total salary is\",ts,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.9, Page number 3.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total salary is 4800.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=1/3; \n",
+ "xbyy=1/4;\n",
+ "mbyn=1/5;\n",
+ "ba=1760; #balance amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "ts=ba/((1-abyb)*(1-(xbyy+mbyn))); #total salary(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total salary is\",ts,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.10, Page number 3.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total length of pole is 1050.0 cm\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "L=250; #length in mud(Rs)\n",
+ "p=(4/7)-(1/3); #part in mud\n",
+ "\n",
+ "#Calculation\n",
+ "Tl=L/p; #total length of pole(cm)\n",
+ "\n",
+ "#Result\n",
+ "print \"total length of pole is\",Tl,\"cm\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.11, Page number 3.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "journey still left is 36.0 km\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "dt=60; #distance travelled(km)\n",
+ "dp=5/8; #part travelled \n",
+ "\n",
+ "#Calculation\n",
+ "x=dt*(1-dp)/dp; #journey still left(km)\n",
+ "\n",
+ "#Result\n",
+ "print \"journey still left is\",x,\"km\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.12, Page number 3.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount to be added is 77.375\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.685;\n",
+ "b=325;\n",
+ "c=300;\n",
+ "\n",
+ "#Calculation\n",
+ "x=c-(a*b); #amount to be added\n",
+ "\n",
+ "#Result\n",
+ "print \"amount to be added is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.13, Page number 3.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length above water is 4.0 m\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=0.15; \n",
+ "xbyy=0.65;\n",
+ "l=20; #length of pole(m)\n",
+ "\n",
+ "#Calculation\n",
+ "L=l*(1-(abyb+xbyy)); #length above water(m)\n",
+ "\n",
+ "#Result\n",
+ "print \"length above water is\",L,\"m\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.14, Page number 3.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "wife's share of money is 5625.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "abyb=0.375; \n",
+ "xbyy=0.4;\n",
+ "ba=3375; #balance amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "ts=ba/(1-(abyb+xbyy)); #total salary(Rs)\n",
+ "ws=abyb*ts; #wife's share of money(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"wife's share of money is\",ws,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.15, Page number 3.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "fraction between 1/3 and 4/5 is 5/8\n",
+ "fraction between 2 and 7/2 is 3.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "#a=1/3\n",
+ "a1=1;\n",
+ "a2=3;\n",
+ "#b=4/5\n",
+ "b1=4;\n",
+ "b2=5;\n",
+ "x1=2;\n",
+ "x2=1;\n",
+ "#y=7/2\n",
+ "y1=7;\n",
+ "y2=2;\n",
+ "\n",
+ "#Calculation\n",
+ "f1=(a1+b1)/(a2+b2); #fraction between 1/3 and 4/5\n",
+ "f2=(x1+y1)/(x2+y2); #fraction between 2 and 7/2\n",
+ "\n",
+ "#Result\n",
+ "print \"fraction between 1/3 and 4/5 is\",Fraction(f1)\n",
+ "print \"fraction between 2 and 7/2 is\",f2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.16, Page number 3.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the three fractions are 0.545454545455 5/8 0.692307692308\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "#a=1/3\n",
+ "a1=1;\n",
+ "a2=3;\n",
+ "#b=4/5\n",
+ "b1=4;\n",
+ "b2=5;\n",
+ "\n",
+ "#Calculation\n",
+ "f11=a1+b1; #numerator of 1st fraction\n",
+ "f12=a2+b2; #denominator of 1st fraction\n",
+ "f1=f11/f12; #1st fraction\n",
+ "f21=a1+f11; #numerator of 2nd fraction\n",
+ "f22=a2+f12; #denominator of 2nd fraction\n",
+ "f2=f21/f22; #2nd fraction\n",
+ "f31=f11+b1; #numerator of 3rd fraction\n",
+ "f32=f12+b2; #denominator of 3rd fraction \n",
+ "f3=f31/f32; #3rd fraction \n",
+ "\n",
+ "#Result\n",
+ "print \"the three fractions are\",f2,Fraction(f1),f3"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 3.17, Page number 3.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "15/46 is lesser than 1/3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=22/63;\n",
+ "b=4/11;\n",
+ "c=15/46;\n",
+ "d=33/98;\n",
+ "e=1/3;\n",
+ "\n",
+ "#Calculation\n",
+ "if(a<e):\n",
+ " print \"22/63 is lesser than 1/3\"\n",
+ "if(b<e):\n",
+ " print \"4/11 is lesser than 1/3\"\n",
+ "if(c<e):\n",
+ " print \"15/46 is lesser than 1/3\"\n",
+ "if(d<e):\n",
+ " print \"33/98 is lesser than 1/3\" "
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter4.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter4.ipynb new file mode 100755 index 00000000..edb5d12d --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter4.ipynb @@ -0,0 +1,2803 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#4: Simplification"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.1, Page number 4.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=10+(1/2);\n",
+ "b=8+(1/2);\n",
+ "c=6;\n",
+ "d=7;\n",
+ "e=6;\n",
+ "f=4;\n",
+ "\n",
+ "#Calculation\n",
+ "result=a-(b+(c-(d-(e-f))));\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.2, Page number 4.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.75;\n",
+ "b=0.25;\n",
+ "\n",
+ "#Calculation\n",
+ "#given question is (a*a)+(b*b)+(2*a*b) which can be solved using (a+b)**2\n",
+ "result=(a+b)**2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.3, Page number 4.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.87;\n",
+ "b=0.13;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(a**3)+(b**3);\n",
+ "Dr=(a**2)+(b**2)-(a*b);\n",
+ "result=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.4, Page number 4.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 576.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=9840;\n",
+ "b=410;\n",
+ "\n",
+ "#Calculation\n",
+ "result=(a/b)**2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.5, Page number 4.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required number is 70.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=40;\n",
+ "b=30;\n",
+ "c=10;\n",
+ "\n",
+ "#Calculation\n",
+ "x=((a**2)-(b**2))/c; #required number\n",
+ "\n",
+ "#Result\n",
+ "print \"required number is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.6, Page number 4.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required number is 3\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3;\n",
+ "b=4;\n",
+ "c=6;\n",
+ "d=9;\n",
+ "\n",
+ "#Calculation\n",
+ "p=b+c-d;\n",
+ "x=a**p; #required number\n",
+ "\n",
+ "#Result\n",
+ "print \"required number is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.7, Page number 4.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2;\n",
+ "b=math.sqrt(2);\n",
+ "\n",
+ "#Calculation\n",
+ "c=1/(a+b);\n",
+ "d=1/(b-a);\n",
+ "result=a+b+c+d;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.8, Page number 4.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 243\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=7;\n",
+ "y=5;\n",
+ "z=2;\n",
+ "\n",
+ "#Calculation\n",
+ "xstary=((x+z)**2)*(y-z);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",xstary "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.9, Page number 4.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1000.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=121;\n",
+ "\n",
+ "#Calculation\n",
+ "m=math.sqrt(a);\n",
+ "#since we are considering square root, value of n will be 2\n",
+ "n=2;\n",
+ "result=(m-1)**(n+1); \n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.10, Page number 4.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "k=1;\n",
+ "x=3*k;\n",
+ "y=4*k;\n",
+ "\n",
+ "#Calculation\n",
+ "result=(6/7)+((y-x)/(y+x));\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.11, Page number 4.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 72.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "rootxminusrooty=1;\n",
+ "rootxplusrooty=17;\n",
+ "\n",
+ "#Calculation\n",
+ "#we get value of rootx and rooty by adding and subtracting the 2 equations\n",
+ "rootx=(rootxminusrooty+rootxplusrooty)/2;\n",
+ "rooty=(rootxplusrooty-rootxminusrooty)/2;\n",
+ "result=rootx*rooty;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.12, Page number 4.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 17.28\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=12;\n",
+ "b=0.2;\n",
+ "c=3.6;\n",
+ "d=2;\n",
+ "\n",
+ "#Calculation\n",
+ "x=a*b*c*d;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.13, Page number 4.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 3.11\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=7;\n",
+ "b=18;\n",
+ "c=84;\n",
+ "\n",
+ "#Calculation\n",
+ "x=((c/b)**2)/7; \n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",round(x,2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.15, Page number 4.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 3.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=256;\n",
+ "b=2;\n",
+ "\n",
+ "#Calculation\n",
+ "c=math.log(a)/math.log(b);\n",
+ "x=math.log(c)/math.log(b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.16, Page number 4.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 9.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=13;\n",
+ "b=2;\n",
+ "c=4;\n",
+ "\n",
+ "#Calculation\n",
+ "d=math.log(c)/math.log(b);\n",
+ "e=d*b;\n",
+ "x=(a-e); \n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.17, Page number 4.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 6.0 *math.sqrt(3)\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3*math.sqrt(27);\n",
+ "b=math.sqrt(75);\n",
+ "c=math.sqrt(12);\n",
+ "\n",
+ "#Calculation\n",
+ "x=a-b+c; \n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x/math.sqrt(3),\"*math.sqrt(3)\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.19, Page number 4.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 3 3/8\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=8+(1/4);\n",
+ "b=8+(1/2);\n",
+ "c=20+(1/8);\n",
+ "\n",
+ "#Calculation\n",
+ "x=c-(a+b);\n",
+ "y=x-int(x);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",int(x),Fraction(y)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.20, Page number 4.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 9.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=math.sqrt(1296);\n",
+ "b=2.25;\n",
+ "\n",
+ "#Calculation\n",
+ "c=a*b;\n",
+ "x=math.sqrt(c);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.21, Page number 4.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 95.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=124.9;\n",
+ "b=63.15;\n",
+ "c=65/100;\n",
+ "\n",
+ "#Calculation\n",
+ "d=a-b;\n",
+ "x=d/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.22, Page number 4.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.09090909091\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=17;\n",
+ "aplusb=23;\n",
+ "\n",
+ "#Calculation\n",
+ "b=aplusb-a;\n",
+ "result=aplusb/(a-b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.23, Page number 4.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=math.sqrt(24);\n",
+ "b=math.sqrt(216);\n",
+ "c=math.sqrt(96);\n",
+ "\n",
+ "#Calculation\n",
+ "x=(a+b)/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.25, Page number 4.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.333333333333\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=5;\n",
+ "y=-2;\n",
+ "\n",
+ "#Calculation\n",
+ "result=(x-(2*y))**(1/y);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.26, Page number 4.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 20.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2+(2/3);\n",
+ "b=4/5;\n",
+ "c=1/6;\n",
+ "\n",
+ "#Calculation\n",
+ "result=a/(b*c); \n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.27, Page number 4.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value of 5/6 of 1/20 of 24 rupees is 1.0 rupee\n",
+ "value of 4/7 of 14 of 2 1/4 kg is 18.0 kg\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=5/6;\n",
+ "b=1/20;\n",
+ "c=24;\n",
+ "d=4/7;\n",
+ "e=14;\n",
+ "f=2+(1/4);\n",
+ "\n",
+ "#Calculation\n",
+ "r1=a*b*c; #value of 5/6 of 1/20 of 24 rupees(rupee)\n",
+ "r2=d*e*f; #value of 4/7 of 14 of 2 1/4 kg(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"value of 5/6 of 1/20 of 24 rupees is\",r1,\"rupee\"\n",
+ "print \"value of 4/7 of 14 of 2 1/4 kg is\",r2,\"kg\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.28, Page number 4.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 3.68181818182\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=11;\n",
+ "b=2+(1/5);\n",
+ "c=11/5;\n",
+ "d=2+(1/2);\n",
+ "e=2;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=a/b;\n",
+ "r2=r1/c;\n",
+ "result=(r2*d)-e;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.29, Page number 4.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.27777777778\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2/3;\n",
+ "b=1/5;\n",
+ "c=1/10;\n",
+ "d=4/5;\n",
+ "e=1/8;\n",
+ "f=1/2;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=a+b-c;\n",
+ "Dr=(d*e)+f;\n",
+ "result=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.30, Page number 4.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 54.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=18;\n",
+ "b=162;\n",
+ "c=1;\n",
+ "\n",
+ "#Calculation\n",
+ "x2=a*b*c;\n",
+ "x=math.sqrt(x2);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.31, Page number 4.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 100.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.55;\n",
+ "b=0.07;\n",
+ "c=0.027;\n",
+ "d=0.01;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(a**2)+(b**2)+(c**2);\n",
+ "Dr=d*Nr;\n",
+ "result=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.32, Page number 4.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 270.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=137;\n",
+ "b=133;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(a**3)+(b**3);\n",
+ "Dr=(a**2)-(a*b)+(b**2);\n",
+ "result=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.33, Page number 4.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=20.25;\n",
+ "b=2.8;\n",
+ "c=28.35;\n",
+ "\n",
+ "#Calculation\n",
+ "result=a*b/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.34, Page number 4.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.0247933884298\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=54;\n",
+ "b=66;\n",
+ "c=33;\n",
+ "\n",
+ "#Calculation\n",
+ "r=a/b;\n",
+ "result=r/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.35, Page number 4.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 43,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 229.0\n",
+ "hence middle digit is 2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=916;\n",
+ "b=16;\n",
+ "c=4;\n",
+ "\n",
+ "#Calculation\n",
+ "r=a*c/b;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",r\n",
+ "print \"hence middle digit is 2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.36, Page number 4.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.00121\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.011;\n",
+ "b=10;\n",
+ "\n",
+ "#Calculation\n",
+ "x=b*(a**2);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.37, Page number 4.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 45,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1000.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=67.6;\n",
+ "b=0.26;\n",
+ "\n",
+ "#Calculation\n",
+ "x=a/(b**2); \n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.38, Page number 4.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 46,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.18\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.324;\n",
+ "b=10;\n",
+ "\n",
+ "#Calculation\n",
+ "x=math.sqrt(a/b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.39, Page number 4.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 47,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=63;\n",
+ "b=36;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=(a+b)**2;\n",
+ "r2=(a-b)**2;\n",
+ "Nr=r1+r2;\n",
+ "Dr=(a**2)+(b**2)\n",
+ "x=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.40, Page number 4.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 48,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 111.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=44.6;\n",
+ "b=2.5;\n",
+ "\n",
+ "#Calculation\n",
+ "x=a*b;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.41, Page number 4.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 3.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=14;\n",
+ "b=46;\n",
+ "c=11;\n",
+ "d=6;\n",
+ "e=4;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(a**2)-b;\n",
+ "Dr=(c*d)-(e**2);\n",
+ "x=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.42, Page number 4.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 52,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1803\n",
+ "answer given in the book varies due to rounding off errors\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2002;\n",
+ "b=10.10;\n",
+ "\n",
+ "#Calculation\n",
+ "x=a-(a/b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",int(x)\n",
+ "print \"answer given in the book varies due to rounding off errors\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.43, Page number 4.16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.333333333333\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=8;\n",
+ "b=3;\n",
+ "c=4;\n",
+ "d=2;\n",
+ "e=6;\n",
+ "f=5;\n",
+ "g=8;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=a-(b*c)+d;\n",
+ "Dr=-(e*f)+(b*g);\n",
+ "x=Nr/Dr;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.45, Page number 4.16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 61,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 4096 or 4 ** 6\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=4;\n",
+ "b=3;\n",
+ "c=2;\n",
+ "d=5;\n",
+ "e=0;\n",
+ "\n",
+ "#Calculation\n",
+ "p=(a*b)-(b*c)+(d*e); #power is calculated using indices\n",
+ "x=a**p;\n",
+ "y=math.log(x)/math.log(a);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x,\"or\",a,\"**\",int(y)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.46, Page number 4.16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 62,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1;\n",
+ "b=25/144;\n",
+ "c=12;\n",
+ "\n",
+ "#Calculation\n",
+ "r=math.sqrt(a+b);\n",
+ "x=(r-a)*c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.47, Page number 4.16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 63,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "b=1;\n",
+ "a=2;\n",
+ "\n",
+ "#Calculation\n",
+ "x1=a-b;\n",
+ "x2=a+b;\n",
+ "result=(x1/x2)+(2/3);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.48, Page number 4.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 64,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 28.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=18;\n",
+ "b=14;\n",
+ "c=84;\n",
+ "\n",
+ "#Calculation\n",
+ "x=(c**2)/(a*b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.49, Page number 4.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 65,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 9.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=243;\n",
+ "b=0.8;\n",
+ "c=0.4;\n",
+ "\n",
+ "#Calculation\n",
+ "p=b-c;\n",
+ "x=a**p;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.50, Page number 4.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 66,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 4.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1.2;\n",
+ "b=0.8;\n",
+ "\n",
+ "#Calculation\n",
+ "x=(a**2)+(b**2)+(2*a*b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.51, Page number 4.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 67,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.352272727273\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=64/121;\n",
+ "b=9/64;\n",
+ "c=8/11;\n",
+ "d=3/8;\n",
+ "\n",
+ "#Calculation\n",
+ "x=(a-b)/(c+d);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.52, Page number 4.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 68,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.1;\n",
+ "b=0.75;\n",
+ "c=2.5;\n",
+ "d=0.05;\n",
+ "e=0.125;\n",
+ "f=1/4.8;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=(a+b)/(c+d);\n",
+ "x=r1/(e+f);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.53, Page number 4.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 70,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 8731552810114645/18014398509481984\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1/246;\n",
+ "b=2/3;\n",
+ "c=1/27;\n",
+ "d=4/3;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=a**(-b);\n",
+ "r2=c**(-d);\n",
+ "x=r1/r2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.54, Page number 4.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 71,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 800.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=8;\n",
+ "b=5/3;\n",
+ "c=125;\n",
+ "d=2/3;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=a**b;\n",
+ "r2=c**(-d);\n",
+ "x=r1/r2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.55, Page number 4.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 74,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.33333333333\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=6;\n",
+ "b=-2;\n",
+ "c=81;\n",
+ "d=-3/4;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=1/(a**b);\n",
+ "r2=c**d;\n",
+ "x=r1*r2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.56, Page number 4.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 75,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 10.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=math.sqrt(147);\n",
+ "b=math.sqrt(27);\n",
+ "c=math.sqrt(3);\n",
+ "\n",
+ "#Calculation\n",
+ "x=(a+b)/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.57, Page number 4.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 77,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=math.sqrt(98);\n",
+ "b=math.sqrt(50);\n",
+ "c=math.sqrt(2);\n",
+ "\n",
+ "#Calculation\n",
+ "x=(a-b)/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.58, Page number 4.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 78,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.35\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=math.sqrt(9/25);\n",
+ "b=3+(1/16);\n",
+ "c=math.sqrt(b);\n",
+ "\n",
+ "#Calculation\n",
+ "x=a+c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.59, Page number 4.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 80,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.18\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=math.sqrt(0.01);\n",
+ "b=math.sqrt(0.0064);\n",
+ "\n",
+ "#Calculation\n",
+ "x=a+b;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.60, Page number 4.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 81,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 0.688995215311\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=25.6;\n",
+ "b=36.1;\n",
+ "c=12.1;\n",
+ "d=81;\n",
+ "e=0.1;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=math.sqrt(a/b);\n",
+ "r2=math.sqrt(c/(d*e));\n",
+ "x=r1/r2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.61, Page number 4.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 83,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "51 can be expressed as 26 **2 - 25 **2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "N=51;\n",
+ "\n",
+ "#Calculation\n",
+ "#to express a number as the difference of squares of 2 numbers, we use the formula N=((N+1)/2)**2-((N-1)/2)**2\n",
+ "a=(N+1)/2;\n",
+ "b=(N-1)/2;\n",
+ "#N can be expressed as (a**2)-(b**2)\n",
+ "\n",
+ "#Result\n",
+ "print \"51 can be expressed as\",int(a),\"**2 - \",int(b),\"**2\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.62, Page number 4.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 84,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 308.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=7;\n",
+ "b=11;\n",
+ "c=1232;\n",
+ "\n",
+ "#Calculation\n",
+ "x2=a*b*c;\n",
+ "x=math.sqrt(x2);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.63, Page number 4.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 85,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 5.41666666667\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3+(1/4);\n",
+ "b=4+(1/3);\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(a**4)-(b**4);\n",
+ "Dr=(a**2)-(b**2);\n",
+ "result=math.sqrt(Nr/Dr);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.64, Page number 4.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 86,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total score in innings is 162.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2/9;\n",
+ "b=8;\n",
+ "\n",
+ "#Calculation\n",
+ "x=b/(a**2); #total score in innings\n",
+ "\n",
+ "#Result\n",
+ "print \"total score in innings is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.65, Page number 4.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 90,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 17.125\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=64;\n",
+ "b=32;\n",
+ "c=-1/2;\n",
+ "d=4/5;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=(1/a)**0;\n",
+ "r2=a**c;\n",
+ "r3=b**d;\n",
+ "result=r1+r2+r3;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.66, Page number 4.21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 91,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 3.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=243;\n",
+ "b=0.12;\n",
+ "c=0.08;\n",
+ "\n",
+ "#Calculation\n",
+ "p=b+c;\n",
+ "result=a**p;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",result"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.67, Page number 4.21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 92,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 12.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2;\n",
+ "b=64;\n",
+ "\n",
+ "#Calculation\n",
+ "c=math.log(b)/math.log(a);\n",
+ "n=c*a;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.68, Page number 4.21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 96,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 36.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1/216;\n",
+ "b=2/3;\n",
+ "\n",
+ "#Calculation\n",
+ "x=1/(a**b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.69, Page number 4.21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 97,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 16.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=-2;\n",
+ "\n",
+ "#Calculation\n",
+ "b=a**a;\n",
+ "x=b**a;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.70, Page number 4.21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 98,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 2.4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=11+(1/3);\n",
+ "b=4+(8/10);\n",
+ "c=22+(2/3);\n",
+ "\n",
+ "#Calculation\n",
+ "x=a*b/c;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.71, Page number 4.22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 99,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.0404\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1.06;\n",
+ "b=0.04;\n",
+ "c=4;\n",
+ "\n",
+ "#Calculation\n",
+ "r1=(a+b)**2;\n",
+ "x=r1-(4*a*b);\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.72, Page number 4.22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 102,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is +/- 1/2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "a2plusb2=45;\n",
+ "ab=18;\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=math.sqrt(a2plusb2+(2*ab));\n",
+ "result=Nr/ab;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is +/-\",Fraction(result)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 4.75, Page number 4.23"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 103,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "#by comparing the equations we get\n",
+ "rootx=2;\n",
+ "\n",
+ "#Calculation\n",
+ "x=rootx**2;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter5.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter5.ipynb new file mode 100755 index 00000000..8b6286d1 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter5.ipynb @@ -0,0 +1,1841 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#5: Percentage"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.1, Page number 5.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "0.4 in terms of percentage is 40.0 %\n",
+ "1.0 in terms of percentage is 100.0 %\n",
+ "5/3 in terms of percentage is 166.67 %\n",
+ "7x/y in terms of percentage is 700 x/y %\n",
+ "1.23 in terms of percentage is 123.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.4;\n",
+ "b=1.0;\n",
+ "c=5/3;\n",
+ "d=7;\n",
+ "e=1.23;\n",
+ "\n",
+ "#Calculation\n",
+ "A=a*100; #in terms of percentage(%)\n",
+ "B=b*100; #in terms of percentage(%)\n",
+ "C=c*100; #in terms of percentage(%)\n",
+ "D=d*100; #in terms of percentage(%)\n",
+ "E=e*100; #in terms of percentage(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"0.4 in terms of percentage is\",A,\"%\"\n",
+ "print \"1.0 in terms of percentage is\",B,\"%\"\n",
+ "print \"5/3 in terms of percentage is\",round(C,2),\"%\"\n",
+ "print \"7x/y in terms of percentage is\",D,\"x/y %\"\n",
+ "print \"1.23 in terms of percentage is\",E,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.2, Page number 5.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "22 1/2 in terms of fraction is 0.225\n",
+ "35 in terms of fraction is 0.35\n",
+ "a**2/b in terms of fraction is a**2/100b\n",
+ "0.3 in terms of fraction is 0.003\n",
+ "2/7 in terms of fraction is 0.0029\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=22+(1/2);\n",
+ "b=35;\n",
+ "c=0.3;\n",
+ "d=2/7;\n",
+ "\n",
+ "#Calculation\n",
+ "A=a/100; #in terms of fraction\n",
+ "B=b/100; #in terms of fraction\n",
+ "C=c/100; #in terms of fraction\n",
+ "D=d/100; #in terms of fraction\n",
+ "\n",
+ "#Result\n",
+ "print \"22 1/2 in terms of fraction is\",A\n",
+ "print \"35 in terms of fraction is\",B\n",
+ "print \"a**2/b in terms of fraction is a**2/100b\"\n",
+ "print \"0.3 in terms of fraction is\",C\n",
+ "print \"2/7 in terms of fraction is\",round(D,4)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.3, Page number 5.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value in 1st case is 2.43\n",
+ "value in 2nd case is 1.3\n",
+ "value in 3rd case is 2.8\n",
+ "value in 4th case is 80.0\n",
+ "value in 5th case is 1.6\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=9; \n",
+ "a1=27;\n",
+ "p2=0.02;\n",
+ "a2=6500;\n",
+ "p3=7/2;\n",
+ "a3=80;\n",
+ "p4=125;\n",
+ "a4=64;\n",
+ "p5=10;\n",
+ "P5=5;\n",
+ "a5=320;\n",
+ "\n",
+ "#Calculation\n",
+ "A1=p1*a1/100;\n",
+ "A2=p2*a2/100;\n",
+ "A3=p3*a3/100;\n",
+ "A4=p4*a4/100;\n",
+ "A5=p5*P5*a5/(100*100);\n",
+ "\n",
+ "#Result\n",
+ "print \"value in 1st case is\",A1\n",
+ "print \"value in 2nd case is\",A2\n",
+ "print \"value in 3rd case is\",A3\n",
+ "print \"value in 4th case is\",A4\n",
+ "print \"value in 5th case is\",A5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.4, Page number 5.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value in 1st case is 25.0 %\n",
+ "value in 2nd case is 116.67 %\n",
+ "value in 3rd case is 20.0 %\n",
+ "value in 4th case is 50.0 %\n",
+ "value in 5th case is 36.0 %\n",
+ "value in 6th case is 100R/N %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=36;\n",
+ "b1=144;\n",
+ "a2=7/8;\n",
+ "b2=3/4;\n",
+ "a3=16;\n",
+ "b3=80;\n",
+ "a4=0.625;\n",
+ "b4=1+(7/28);\n",
+ "a5=36*14;\n",
+ "b5=1400;\n",
+ "\n",
+ "#Calculation\n",
+ "v1=a1*100/b1; #value(%)\n",
+ "v2=a2*100/b2; #value(%)\n",
+ "v3=a3*100/b3; #value(%)\n",
+ "v4=a4*100/b4; #value(%)\n",
+ "v5=a5*100/b5; #value(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"value in 1st case is\",v1,\"%\"\n",
+ "print \"value in 2nd case is\",round(v2,2),\"%\"\n",
+ "print \"value in 3rd case is\",v3,\"%\"\n",
+ "print \"value in 4th case is\",v4,\"%\"\n",
+ "print \"value in 5th case is\",v5,\"%\"\n",
+ "print \"value in 6th case is 100R/N %\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.5, Page number 5.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value in 1st case is 600.0\n",
+ "value in 2nd case is 50.0\n",
+ "value in 3rd case is 240.0\n",
+ "value in 4th case is 4.08\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=6; \n",
+ "a1=36;\n",
+ "p2=5;\n",
+ "a2=2.5;\n",
+ "p3=25;\n",
+ "P3=20;\n",
+ "a3=12;\n",
+ "p4=14;\n",
+ "a4=4/7;\n",
+ "\n",
+ "#Calculation\n",
+ "A1=a1*100/p1;\n",
+ "A2=a2*100/p2;\n",
+ "A3=a3*100*100/(p3*P3);\n",
+ "A4=a4*100/p4;\n",
+ "\n",
+ "#Result\n",
+ "print \"value in 1st case is\",A1\n",
+ "print \"value in 2nd case is\",A2\n",
+ "print \"value in 3rd case is\",A3\n",
+ "print \"value in 4th case is\",round(A4,2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.6, Page number 5.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "40% of number is 32.0\n",
+ "original number is 80.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=25;\n",
+ "p2=40;\n",
+ "x1=20;\n",
+ "\n",
+ "#Calculation\n",
+ "x2=x1*p2/p1; #40% of number \n",
+ "N=x1*100/p1; #original number\n",
+ "\n",
+ "#Result\n",
+ "print \"40% of number is\",x2\n",
+ "print \"original number is\",N"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.8, Page number 5.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "B is short of A by 20.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "e=25; #% excess\n",
+ "\n",
+ "#Calculation\n",
+ "s=e*100/(100+e); #%short\n",
+ "\n",
+ "#Result\n",
+ "print \"B is short of A by\",s"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.9, Page number 5.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Y is excess of X by 66.67\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=40; #%short\n",
+ "\n",
+ "#Calculation\n",
+ "e=s*100/(100-s); #% excess\n",
+ "\n",
+ "#Result\n",
+ "print \"Y is excess of X by\",round(e,2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.10, Page number 5.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "salary of july more than that of june is 11.11 %\n",
+ "salary of june less than that of july is 10.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "J=2+(1/2);\n",
+ "j=2+(1/4);\n",
+ "\n",
+ "#Calculation\n",
+ "d=J-j; #difference\n",
+ "s1=d*100/j; #salary more(%)\n",
+ "s2=d*100/J; #salary less(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"salary of july more than that of june is\",round(s1,2),\"%\"\n",
+ "print \"salary of june less than that of july is\",s2,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.11, Page number 5.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "enrollment in 1988 is 1650.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "e=1500; #total enrollment\n",
+ "p=10; #percentage increment\n",
+ "\n",
+ "#Calculation\n",
+ "E=e*(100+p)/100; #enrollment in 1988\n",
+ "\n",
+ "#Result\n",
+ "print \"enrollment in 1988 is\",E"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.13, Page number 5.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "area of rectangle decreases by 22.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x=-40; #% decrease\n",
+ "y=30; #% increase\n",
+ "\n",
+ "#Calculation\n",
+ "n=x+y+((x*y)/100); #area of rectangle decreases by(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"area of rectangle decreases by\",-n,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.14, Page number 5.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "original daily wage is 20.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=23; #increased daily wage(%)\n",
+ "pi=15; #percentage increase(%)\n",
+ "\n",
+ "#Calculation\n",
+ "o=i*100/(100+pi); #original daily wage\n",
+ "\n",
+ "#Result\n",
+ "print \"original daily wage is\",o"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.16, Page number 5.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Y gets 42.0 % above minimum\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Y=710; #marks of Y\n",
+ "X=515; #marks of X\n",
+ "px=3; #% above\n",
+ "\n",
+ "#Calculation\n",
+ "py=(Y*(100+px)/X)-100; #Y gets % above minimum\n",
+ "\n",
+ "#Result\n",
+ "print \"Y gets\",py,\"% above minimum\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.18, Page number 5.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "% of scholarship holders is 22.0\n",
+ "% of non scholarship holders is 78.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "b=3; #boys in ratio\n",
+ "g=2; #girls in ratio\n",
+ "pb=20; #% of boys\n",
+ "pg=25; #% of girls\n",
+ "\n",
+ "#Calculation\n",
+ "B=b/(b+g); #number of boys\n",
+ "G=g/(b+g); #number of girls\n",
+ "ps=(B*pb)+(G*pg); #% of scholarship holders\n",
+ "pns=(B*(100-pb))+(G*(100-pg)); #% of non scholarship holders\n",
+ "\n",
+ "#Result\n",
+ "print \"% of scholarship holders is\",ps\n",
+ "print \"% of non scholarship holders is\",pns"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.19, Page number 5.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "% change in consumption is 11.11 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Nr=27; #new rate(Rs)\n",
+ "Or=24; #original rate(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "pc=(Nr-Or)*100/Or; #% change in rate\n",
+ "pcc=pc*100/(100+pc); #% change in consumption\n",
+ "\n",
+ "#Result\n",
+ "print \"% change in consumption is\",round(pcc,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.20, Page number 5.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "original price of sugar is Rs 4.0 per kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "e=16; #expenditure(Rs)\n",
+ "rc=2; #rate change(Rs)\n",
+ "qc=4; #change in quantity available(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "b=-rc; #coefficient of x\n",
+ "a=1; #coefficient of x**2\n",
+ "c=-e*rc/qc; #constant term\n",
+ "x=(b**2)-(4*a*c);\n",
+ "x1=(-b+math.sqrt(x))/(2*a); \n",
+ "x2=(-b-math.sqrt(x))/(2*a); \n",
+ "\n",
+ "#Result\n",
+ "print \"original price of sugar is Rs\",x1,\"per kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.21, Page number 5.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "original price is Rs 8.0 per kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "e=120; #expenditure(Rs)\n",
+ "rc=0.25; #rate change(Rs)\n",
+ "qc=5; #change in quantity available(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "x=e*rc/(qc*(1-rc)); #original price(Rs/kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"original price is Rs\",x,\"per kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.22, Page number 5.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "% decrease in consumption is 2.913 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "cr=3; #change in rate(%)\n",
+ "\n",
+ "#Calculation\n",
+ "dc=cr*100/(100+cr); #% decrease in consumption\n",
+ "\n",
+ "#Result\n",
+ "print \"% decrease in consumption is\",round(dc,3),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.24, Page number 5.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "salary is 5000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=10; #deduction(%)\n",
+ "p2=20; #deduction(%)\n",
+ "p3=25; #deduction(%)\n",
+ "l=2700; #left with amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(100-p1)*(100-p2)*(100-p3)/(100*100*100);\n",
+ "s=l/x; #salary(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"salary is\",s,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.25, Page number 5.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "new consumption is 25.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=10; #% increase\n",
+ "q=30; #quantity(kg)\n",
+ "p2=32; #% increase\n",
+ "\n",
+ "#Calculation\n",
+ "nc=(100+p1)*q/(100+p2); #new consumption(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"new consumption is\",nc,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.26, Page number 5.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "income after increase is Rs 7200.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1200; #amount increased(Rs)\n",
+ "p1=10; #% before\n",
+ "p2=12; #% after\n",
+ "\n",
+ "#Calculation\n",
+ "x=a*p2/(p2-p1); #income after increase(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"income after increase is Rs\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.27, Page number 5.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value in 1st case is 280.0\n",
+ "value in 2nd case is 0.5\n",
+ "value in 3rd case is 225.0\n",
+ "value in 4th case is 30.0\n",
+ "value in 5th case is 880.0\n",
+ "value in 6th case is 12.0\n",
+ "value in 7th case is 0.4 %\n",
+ "value in 8th case is 220.0\n",
+ "value in 9th case is 150.0\n",
+ "value in 10th case is 42.0\n",
+ "value in 11th case is 0.75 %\n",
+ "value in 12th case is 0.15\n",
+ "value in 13th case is 0.375\n",
+ "value in 14th case is 0.125\n",
+ "value in 15th case is 15.0\n",
+ "value in 16th case is 20.0\n",
+ "value in 17th case is 300.0\n",
+ "value in 18th case is 6.0\n",
+ "answer given in the book is wrong\n",
+ "value in 19th case is 1.05 x\n",
+ "value in 20th case is 0.93 x\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=3/4;\n",
+ "b1=48;\n",
+ "c1=62;\n",
+ "p1=35/100;\n",
+ "p2=45/100;\n",
+ "a2=5/6;\n",
+ "P2=20/100;\n",
+ "b2=4.375;\n",
+ "a3=625;\n",
+ "b3=1200;\n",
+ "c3=320;\n",
+ "p3=80/100;\n",
+ "a4=3/5;\n",
+ "b4=1450;\n",
+ "p4=200/100;\n",
+ "c4=450;\n",
+ "a5=5+(1/2);\n",
+ "b5=240;\n",
+ "p5=150/100;\n",
+ "a6=5/7;\n",
+ "b6=49;\n",
+ "c6=130;\n",
+ "p6=20/100;\n",
+ "a7=2*1000;\n",
+ "b7=800;\n",
+ "a8=534;\n",
+ "b8=105;\n",
+ "p8=(33+(1/3))/100;\n",
+ "P8=40/100;\n",
+ "p9=(26+(2/3))/100;\n",
+ "a9=40;\n",
+ "p10=(10+(1/2))/100;\n",
+ "a10=400;\n",
+ "a11=108;\n",
+ "b11=81;\n",
+ "a12=60;\n",
+ "b12=72;\n",
+ "p12=(12+(1/2))/100;\n",
+ "p13=0.025/100;\n",
+ "a13=1500;\n",
+ "p14=25/100;\n",
+ "P14=50/100;\n",
+ "a15=150;\n",
+ "a16=73;\n",
+ "p17=11/100;\n",
+ "a17=33;\n",
+ "a18=350;\n",
+ "b18=21;\n",
+ "a19=5/100;\n",
+ "a20=7/100;\n",
+ "\n",
+ "#Calculation\n",
+ "v1=((a1*b1)+c1)/p1; #value in 1st case\n",
+ "v2=(P2*b2)-(p2*a2); #value in 2nd case\n",
+ "v3=((p3*b3)-c3-a3)**2; #value in 3rd case \n",
+ "v4=(p4*c4)-(a4*b4); #value in 4th case \n",
+ "v5=a5*b5/p5; #value in 5th case \n",
+ "v6=(a6*b6)+(p6*c6)-b6; #value in 6th case \n",
+ "v7=b7/a7; #value in 7th case \n",
+ "v8=(p8*a8)+(P8*b8); #value in 8th case \n",
+ "v9=a9/p9; #value in 9th case \n",
+ "v10=p10*a10; #value in 10th case \n",
+ "v11=b11/a11; #value in 11th case \n",
+ "v12=b12*p12/a12; #value in 12th case \n",
+ "v13=p13*a13; #value in 13th case\n",
+ "v14=p14*P14; #value in 14th case\n",
+ "v15=a15*100/1000; #value in 15th case\n",
+ "v16=a16*100/365; #value in 16th case \n",
+ "v17=a17/p17; #value in 17th case\n",
+ "v18=b18*100/a18; #value in 18th case\n",
+ "v19=1+a19; #value in 19th case \n",
+ "v20=1-a20; #value in 20th case\n",
+ "\n",
+ "#Result\n",
+ "print \"value in 1st case is\",v1\n",
+ "print \"value in 2nd case is\",v2\n",
+ "print \"value in 3rd case is\",v3\n",
+ "print \"value in 4th case is\",v4\n",
+ "print \"value in 5th case is\",v5\n",
+ "print \"value in 6th case is\",v6\n",
+ "print \"value in 7th case is\",v7,\"%\"\n",
+ "print \"value in 8th case is\",v8\n",
+ "print \"value in 9th case is\",v9\n",
+ "print \"value in 10th case is\",v10\n",
+ "print \"value in 11th case is\",v11,\"%\"\n",
+ "print \"value in 12th case is\",v12\n",
+ "print \"value in 13th case is\",v13\n",
+ "print \"value in 14th case is\",v14\n",
+ "print \"value in 15th case is\",v15\n",
+ "print \"value in 16th case is\",v16\n",
+ "print \"value in 17th case is\",v17\n",
+ "print \"value in 18th case is\",v18\n",
+ "print \"answer given in the book is wrong\"\n",
+ "print \"value in 19th case is\",v19,\"x\"\n",
+ "print \"value in 20th case is\",v20,\"x\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.28, Page number 5.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "saving increases by 25 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "si=10; #income(%)\n",
+ "Si=25; #salary increase(%)\n",
+ "\n",
+ "#Calculation\n",
+ "SI=Si; #saving increase(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"saving increases by\",SI,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.29, Page number 5.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount boy had is Rs 48.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=20; #number of books\n",
+ "a1=25/100; #amount less(Rs)\n",
+ "a2=70/100; #amount left(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "X=((n+2)*a1)-a2;\n",
+ "x=n*X/(n+2-n); #amount boy had(Rs) \n",
+ "\n",
+ "#Result\n",
+ "print \"amount boy had is Rs\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.30, Page number 5.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value of N is 20.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=80; #percentage(%)\n",
+ "n=4; #reduced number\n",
+ "\n",
+ "#Calculation\n",
+ "N=n*100/(100-p); #value of N\n",
+ "\n",
+ "#Result\n",
+ "print \"value of N is\",N"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.31, Page number 5.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value of N is 300.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=102; #percentage(%)\n",
+ "n=6; #reduced number\n",
+ "\n",
+ "#Calculation\n",
+ "N=n*100/(p-100); #value of N\n",
+ "\n",
+ "#Result\n",
+ "print \"value of N is\",N"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.32, Page number 5.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "new value for 1st case is 320.0\n",
+ "new value for 2nd case is 22.0\n",
+ "new value for 3rd case is 105.0\n",
+ "new value for 4th case is 54.0\n",
+ "new value for 5th case is 1035.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=200;\n",
+ "p1=60;\n",
+ "a2=11;\n",
+ "p2=100;\n",
+ "a3=35;\n",
+ "p3=200;\n",
+ "a4=48;\n",
+ "p4=12+(1/2);\n",
+ "a5=1000;\n",
+ "p5=3.5;\n",
+ "\n",
+ "#Calculation\n",
+ "N1=a1*(100+p1)/100; #new value for 1st case\n",
+ "N2=a2*(100+p2)/100; #new value for 2nd case\n",
+ "N3=a3*(100+p3)/100; #new value for 3rd case\n",
+ "N4=a4*(100+p4)/100; #new value for 4th case\n",
+ "N5=a5*(100+p5)/100; #new value for 5th case\n",
+ "\n",
+ "#Result\n",
+ "print \"new value for 1st case is\",N1\n",
+ "print \"new value for 2nd case is\",N2\n",
+ "print \"new value for 3rd case is\",N3\n",
+ "print \"new value for 4th case is\",N4\n",
+ "print \"new value for 5th case is\",N5"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.33, Page number 5.16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "new value for 1st case is 120.0\n",
+ "new value for 2nd case is 12.0\n",
+ "new value for 3rd case is 135.0\n",
+ "new value for 4th case is 292.5\n",
+ "new value for 5th case is 998.0\n",
+ "new value for 6th case is 43.75\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=200;\n",
+ "p1=40;\n",
+ "a2=16;\n",
+ "p2=25;\n",
+ "a3=216;\n",
+ "p3=37+(1/2);\n",
+ "a4=300;\n",
+ "p4=2.5;\n",
+ "a5=1000;\n",
+ "p5=1/5;\n",
+ "a6=50;\n",
+ "p6=12+(1/2);\n",
+ "\n",
+ "#Calculation\n",
+ "N1=a1*(100-p1)/100; #new value for 1st case\n",
+ "N2=a2*(100-p2)/100; #new value for 2nd case\n",
+ "N3=a3*(100-p3)/100; #new value for 3rd case\n",
+ "N4=a4*(100-p4)/100; #new value for 4th case\n",
+ "N5=a5*(100-p5)/100; #new value for 5th case\n",
+ "N6=a6*(100-p6)/100; #new value for 6th case\n",
+ "\n",
+ "#Result\n",
+ "print \"new value for 1st case is\",N1\n",
+ "print \"new value for 2nd case is\",N2\n",
+ "print \"new value for 3rd case is\",N3\n",
+ "print \"new value for 4th case is\",N4\n",
+ "print \"new value for 5th case is\",N5\n",
+ "print \"new value for 6th case is\",N6"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.34, Page number 5.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of bill is Rs 50.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=10; #percent(%)\n",
+ "b=45; #decreased bill(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "N=b*100/(100-p); #amount of bill(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of bill is Rs\",N"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.35, Page number 5.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of milk chocolates/month is 7000.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=30; #percent(%)\n",
+ "n=9100; #number of milk chocolates\n",
+ "\n",
+ "#Calculation\n",
+ "N=n*100/(100+p); #number of milk chocolates\n",
+ "\n",
+ "#Result\n",
+ "print \"number of milk chocolates/month is\",N"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.36, Page number 5.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "error is 2.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "fw=40.8; #false weight(kg)\n",
+ "aw=40; #actual weight(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "e=(fw-aw)*100/aw; #error(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"error is\",e,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.37, Page number 5.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "new price per kg is Rs 50.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "d=10; #difference(Rs)\n",
+ "dp=25; #difference in percent(%)\n",
+ "\n",
+ "#Calculation\n",
+ "op=d*100/dp; #original price(Rs)\n",
+ "np=op*(100+dp)/100; #new price per kg(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"new price per kg is Rs\",np"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.38, Page number 5.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ratio of change in price to old price is 1/4\n",
+ "ratio of old price to new price is 1.33\n",
+ "factor is 3/4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "cp=25; #change in price(Rs)\n",
+ "op=100; #old price(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "r1=cp/op; #ratio of change in price to old price\n",
+ "r2=op/(op-cp); #ratio of old price to new price\n",
+ "f=(100-cp)/100; #factor\n",
+ "\n",
+ "#Result\n",
+ "print \"ratio of change in price to old price is\",Fraction(r1)\n",
+ "print \"ratio of old price to new price is\",round(r2,2)\n",
+ "print \"factor is\",Fraction(f)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.39, Page number 5.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "B=A* 0.91\n",
+ "A=B* 11 /10\n",
+ "A/B = 11 /10\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=10; #percent(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x2=(100+p)/100;\n",
+ "x1=100/(100+p);\n",
+ "\n",
+ "#Result\n",
+ "print \"B=A*\",round(x1,2)\n",
+ "print \"A=B*\",int(x2*10),\"/10\"\n",
+ "print \"A/B = \",int(x2*10),\"/10\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "##Example number 5.40, Page number 5.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "X/Y = 0.8\n",
+ "Y-X/Y = 0.2\n",
+ "X/Y-X = 4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=20; #percent(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x1=(100-p)/100;\n",
+ "x2=p/100;\n",
+ "x3=(100-p)/p;\n",
+ "\n",
+ "#Result\n",
+ "print \"X/Y = \",x1\n",
+ "print \"Y-X/Y = \",x2\n",
+ "print \"X/Y-X = \",int(x3)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "##Example number 5.41, Page number 5.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of table is 9.6 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=2+(1/2); #percent(%)\n",
+ "w=0.2; #weight(kg)\n",
+ "p2=120; #percent(%)\n",
+ "\n",
+ "#Calculation\n",
+ "w=w*p2/p1; #weight of table(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of table is\",w,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.42, Page number 5.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "five times the sum of money is Rs 1740.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p=1/8; #percent(%)\n",
+ "a=43.50; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "S=a*5/p; #five times the sum of money(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"five times the sum of money is Rs\",S"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.43, Page number 5.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "q is less than p by 83.33 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "q=1;\n",
+ "p=6*q; #number of times\n",
+ "\n",
+ "#Calculation\n",
+ "x=(p-q)*100/p; #q is less than p by(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"q is less than p by\",round(x,2),\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.44, Page number 5.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "required percent is 0.25 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=0.05; #number\n",
+ "p=20/100;\n",
+ "\n",
+ "#Calculation\n",
+ "rp=n/p; #required percent(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"required percent is\",rp,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 5.45, Page number 5.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "percent of sulphur in earth is 0.222 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=5;\n",
+ "n2=2250;\n",
+ "\n",
+ "#Calculation\n",
+ "ps=n1*100/n2; #percent of sulphur in earth(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"percent of sulphur in earth is\",round(ps,3),\"%\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter6.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter6.ipynb new file mode 100755 index 00000000..7d2fb138 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter6.ipynb @@ -0,0 +1,743 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#6: Average"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.1 Page number 6.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average age of students in both sections is 10.86 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "m=40; #number of students in A\n",
+ "a=10; #average age in A\n",
+ "b=12; #average age in B\n",
+ "n=30; #number of students in B\n",
+ "\n",
+ "#Calculation\n",
+ "average=((m*a)+(n*b))/(m+n); #average age of students in both sections\n",
+ "\n",
+ "#Result\n",
+ "print \"average age of students in both sections is\",round(average,2),\"years\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.2 Page number 6.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average of 2 numbers is 9.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "m=5; #number of quantities\n",
+ "n=3; #number of quantities\n",
+ "a=6; #average of 5 quantities\n",
+ "b=4; #average of 3 quantities\n",
+ "\n",
+ "#Calculation\n",
+ "average=((m*a)-(n*b))/(m-n); #average of 2 numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"average of 2 numbers is\",average"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.3 Page number 6.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average price of pen is 12.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "m=30; #number of pens\n",
+ "n=75; #number of pencils\n",
+ "p=2; #average price of pencil\n",
+ "S=510; #cost of pens and pencils\n",
+ "\n",
+ "#Calculation\n",
+ "y=(S-(n*p))/m; #average price of pen(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"average price of pen is\",y,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.4 Page number 6.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "age of A is 22.0 years\n",
+ "age of B is 18.0 years\n",
+ "age of C is 20.0 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "aplusb=2*20; #average age of A and B\n",
+ "bplusc=2*19; #average age of B and C\n",
+ "cplusa=2*21; #average age of C and A\n",
+ "\n",
+ "#Calculation\n",
+ "aplusbplusc=(aplusb+bplusc+cplusa)/2;\n",
+ "a=aplusbplusc-bplusc; #age of A(years)\n",
+ "b=aplusbplusc-cplusa; #age of B(years)\n",
+ "c=aplusbplusc-aplusb; #age of C(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"age of A is\",a,\"years\"\n",
+ "print \"age of B is\",b,\"years\"\n",
+ "print \"age of C is\",c,\"years\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.5 Page number 6.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average monthly income is 2805.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "e1=2200; #average monthly expenditure for 3 months(Rs)\n",
+ "n1=3; #number of months in 1st case\n",
+ "e2=2550; #average monthly expenditure for 4 months(Rs)\n",
+ "n2=4; #number of months in 2nd case\n",
+ "e3=3120; #average monthly expenditure for 5 months(Rs)\n",
+ "n3=5; #number of months in 3rd case\n",
+ "s=1260; #total saving(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "I=(e1*n1)+(e2*n2)+(e3*n3)+s; #total yearly income(Rs)\n",
+ "average=I/12; #average monthly income(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"average monthly income is\",average,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.6 Page number 6.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "temperature of tuesday is 36 C\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "TWT=37; #average temperature on tuesday, wednesday, thursday(C)\n",
+ "FWT=38; #average temperature on wednesday, thursday, friday(C)\n",
+ "R=39; #temperature on friday(C)\n",
+ "n=3; #number of quantities\n",
+ "\n",
+ "#Calculation\n",
+ "T=R-((FWT-TWT)*n); #temperature of tuesday(C)\n",
+ "\n",
+ "#Result\n",
+ "print \"temperature of tuesday is\",T,\"C\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.7 Page number 6.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "temperature of september is 26 C\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=3; #number of quantities\n",
+ "J=29; #temperature of june(C)\n",
+ "JJA=31; #average temperature of june, july august(C)\n",
+ "JAS=30; #average temperature of july, august, september(C)\n",
+ "\n",
+ "#Calculation\n",
+ "S=J+((JAS-JJA)*n); #temperature of september(C)\n",
+ "\n",
+ "#Result\n",
+ "print \"temperature of september is\",S,\"C\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.8 Page number 6.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of teacher is 63.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=29; #number of students in class\n",
+ "n2=30; #number when teacher is included\n",
+ "w1=48; #average weight of 29 students(kg)\n",
+ "w=0.5; #change in average weight of 30 members(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "wt=((n2-n1)*w1)+(w*n2); #weight of teacher(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of teacher is\",wt,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.9 Page number 6.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of boy who left the class is 49.9 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=50; #number of boys in class\n",
+ "w1=45; #original average(kg)\n",
+ "n2=49; #number of boys when one leaves the class\n",
+ "dw=0.1; #reduction in average weight(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(n1-n2)*w1;\n",
+ "b=-dw*n2;\n",
+ "w=a-b; #weight of boy who left the class(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of boy who left the class is\",w,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.10 Page number 6.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average age of 10 new students is 16.0 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=40; #number of students\n",
+ "na=10; #number of students newly admitted\n",
+ "a1=15; #original average(years)\n",
+ "a=0.2; #change in average(year)\n",
+ "\n",
+ "#Calculation\n",
+ "sa=(na*a1)+(a*(n1+na)); #sum of weight(kg)\n",
+ "avga=sa/na; #average age of 10 new students(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"average age of 10 new students is\",avga,\"years\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.11 Page number 6.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average weight of 20 students is 55.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=30; #number of students\n",
+ "n=20; #number of students newly admitted\n",
+ "a1=60; #original average(kg)\n",
+ "a=-2; #change in average weight(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "s=(n*a1)+(a*(n1+n)); #sum of weight(kg)\n",
+ "aw=s/n; #average weight of 20 students(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"average weight of 20 students is\",aw,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.12 Page number 6.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value of 6th result is 56\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=6; #number of results\n",
+ "a1=49; #average of 1st six results\n",
+ "a2=52; #average of last six results\n",
+ "n2=11; \n",
+ "a3=50; #average of 11 results\n",
+ "\n",
+ "#Calculation\n",
+ "v6=(n1*a1)+(n1*a2)-(n2*a3); #value of 6th result\n",
+ "\n",
+ "#Result\n",
+ "print \"value of 6th result is\",v6"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.13 Page number 6.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average after 21 innings is 67.0 runs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n1=20; #number of innings\n",
+ "n2=21; #number of innings in 2nd case\n",
+ "r2=107; #number of runs\n",
+ "a2=2; #change in average(runs)\n",
+ "\n",
+ "#Calculation\n",
+ "a1=a2*n2;\n",
+ "A=(r2-a1)/(n2-n1); \n",
+ "A=A+2; #average after 21 innings(runs)\n",
+ "\n",
+ "#Result\n",
+ "print \"average after 21 innings is\",A,\"runs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.14 Page number 6.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "final average is 28.0 runs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Sa=6; #number of runs in last 2 innings(runs)\n",
+ "na=2; #number of innings\n",
+ "deltaA=-2; #drop in average runs\n",
+ "A1=750; #number of runs\n",
+ "\n",
+ "#Calculation\n",
+ "#from the equation 6=(2*750/N)-(2*N+4) we get a quadratic equation in N \n",
+ "a=-deltaA; #coefficient of N**2\n",
+ "b=Sa-(na*deltaA); #coefficient of N\n",
+ "c=-na*A1; #constant term\n",
+ "N=((-b)+math.sqrt((b**2)-(4*a*c)))/(2*a); #number of innings\n",
+ "A=A1/N; #original average\n",
+ "FA=A-na; #final average(runs)\n",
+ "\n",
+ "#Result\n",
+ "print \"final average is\",FA,\"runs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.15 Page number 6.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "new average of bowler is 9.0 or 9.33333333333\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "sa=52; #number of runs\n",
+ "na=3; #number of wickets\n",
+ "A1=200; #average of bowler\n",
+ "deltaA=1; #change in average\n",
+ "\n",
+ "#Calculation\n",
+ "#from the equation 52=(3*200/N)+(+1)*(N+3) we get a quadratic equation in N \n",
+ "a=deltaA; #coefficient of N**2\n",
+ "b=na-sa; #coefficient of N\n",
+ "c=na*A1; #constant term\n",
+ "N1=((-b)+math.sqrt((b**2)-(4*a*c)))/(2*a); #number of innings\n",
+ "N2=((-b)-math.sqrt((b**2)-(4*a*c)))/(2*a); #number of innings\n",
+ "NA1=(A1+sa)/(N1+na); #new average\n",
+ "NA2=(A1+sa)/(N2+na); #new average\n",
+ "x=NA2-int(NA2);\n",
+ "\n",
+ "#Result\n",
+ "print \"new average of bowler is\",NA1,\"or\",NA2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.16 Page number 6.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of new student is 62.5 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=15; #number of students\n",
+ "da=1.5; #change in average\n",
+ "wr=40; #weight of removed student(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "wn=wr+(n*da); #weight of new student(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of new student is\",wn,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 6.17 Page number 6.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "average age of 2 players is 15.5 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "n=11; #number of players\n",
+ "ac=25; #age of captain(years)\n",
+ "awk=28; #age of wicket keeper(years)\n",
+ "da=-2; #change in average(years)\n",
+ "\n",
+ "#Calculation\n",
+ "S=(ac+awk)+(n*da); #sum of age of replacing players(years)\n",
+ "A=S/2; #average age of 2 players(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"average age of 2 players is\",A,\"years\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter7.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter7.ipynb new file mode 100755 index 00000000..ff247148 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter7.ipynb @@ -0,0 +1,993 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#7: Ratio and Proportion"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.1, Page number 7.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "result is 1.2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.75;\n",
+ "b=5;\n",
+ "c=8;\n",
+ "\n",
+ "#Calculation\n",
+ "x=a*c/b;\n",
+ "\n",
+ "#Result\n",
+ "print \"result is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.2, Page number 7.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "mean proportion is 0.08\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=0.32;\n",
+ "b=0.02;\n",
+ "\n",
+ "#Calculation\n",
+ "x2=a*b;\n",
+ "x=math.sqrt(a*b); #mean proportion\n",
+ "\n",
+ "#Result\n",
+ "print \"mean proportion is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.3, Page number 7.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "third proportional is 36.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=16;\n",
+ "b=24;\n",
+ "\n",
+ "#Calculation\n",
+ "x=(b**2)/a; #third proportional\n",
+ "\n",
+ "#Result\n",
+ "print \"third proportional is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.4, Page number 7.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "third proportional is 1.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=16;\n",
+ "b=4;\n",
+ "\n",
+ "#Calculation\n",
+ "x=(b**2)/a; #third proportional\n",
+ "\n",
+ "#Result\n",
+ "print \"third proportional is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.5, Page number 7.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "part is 3/4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3/48;\n",
+ "b=1/12;\n",
+ "\n",
+ "#Calculation\n",
+ "p=a/b; #part\n",
+ "\n",
+ "#Result\n",
+ "print \"part is\",Fraction(p)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.6, Page number 7.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "part is 7/8\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import Fraction\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=7;\n",
+ "b=8;\n",
+ "\n",
+ "#Calculation\n",
+ "p=a/b; #part\n",
+ "\n",
+ "#Result\n",
+ "print \"part is\",Fraction(p)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.7, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of girls is 360.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=4/3; #ratio of number of boys and girls\n",
+ "b=480; #number of boys\n",
+ "\n",
+ "#Calculation\n",
+ "x=b/a; #number of girls\n",
+ "\n",
+ "#Result\n",
+ "print \"number of girls is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.8, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "first part is 32.0 Rs\n",
+ "second part is 40.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=4; #first ratio term\n",
+ "b=5; #second ratio term\n",
+ "c=72; #total amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "fp=a*c/(a+b); #first part(Rs)\n",
+ "sp=b*c/(a+b); #second part(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"first part is\",fp,\"Rs\"\n",
+ "print \"second part is\",sp,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.9, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of girls is 250.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2; #first ratio term\n",
+ "b=5; #second ratio term\n",
+ "c=350; #number of students\n",
+ "\n",
+ "#Calculation\n",
+ "x=b*c/(a+b); #number of girls\n",
+ "\n",
+ "#Result\n",
+ "print \"number of girls is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.10, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the numbers are 30.0 and 70.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3; #first ratio term\n",
+ "b=7; #second ratio term\n",
+ "lcm=210; #lcm of two numbers\n",
+ "\n",
+ "#Calculation\n",
+ "x=lcm/(a*b); #factor\n",
+ "n1=a*x; #first number\n",
+ "n2=b*x; #second number\n",
+ "\n",
+ "#Result\n",
+ "print \"the numbers are\",n1,\"and\",n2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.11, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "consequent is 77.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3; #first ratio term\n",
+ "b=7; #second ratio term\n",
+ "c=33; #antecedent\n",
+ "\n",
+ "#Calculation\n",
+ "x=b*c/a; #consequent\n",
+ "\n",
+ "#Result\n",
+ "print \"consequent is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.12, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the numbers are 12.0 and 20.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "aold=3; #first ratio term\n",
+ "bold=5; #second ratio term\n",
+ "c=4; #increment\n",
+ "anew=2; #first term of new ratio\n",
+ "bnew=3; #second term of new ratio\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(aold*c)-(anew*c);\n",
+ "Dr=(bold*anew)-(aold*bnew);\n",
+ "x=Nr/Dr; #factor\n",
+ "n1=x*aold;\n",
+ "n2=x*bold; \n",
+ "\n",
+ "#Result\n",
+ "print \"the numbers are\",n1,\"and\",n2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.13, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the numbers are 24.0 and 26.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "aold=12; #first ratio term\n",
+ "bold=13; #second ratio term\n",
+ "c=20; #decrement\n",
+ "anew=2; #first term of new ratio\n",
+ "bnew=3; #second term of new ratio\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(bnew*c)-(anew*c);\n",
+ "Dr=(bnew*aold)-(anew*bold);\n",
+ "x=Nr/Dr; #factor\n",
+ "n1=x*aold;\n",
+ "n2=x*bold; \n",
+ "\n",
+ "#Result\n",
+ "print \"the numbers are\",n1,\"and\",n2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.14, Page number 7.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "decrement is 0.33\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "aold=3; #first ratio term\n",
+ "bold=7; #second ratio term\n",
+ "anew=2; #first term of new ratio\n",
+ "bnew=5; #second term of new ratio\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(aold*bnew)-(anew*bold);\n",
+ "Dr=bnew-anew;\n",
+ "x=Nr/Dr; #decrement\n",
+ "\n",
+ "#Result\n",
+ "print \"decrement is\",round(x,2)\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.15, Page number 7.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of people originally present is 12.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "aold=1; #first ratio term\n",
+ "bold=2; #second ratio term\n",
+ "anew=1; #first term of new ratio\n",
+ "bnew=3; #second term of new ratio\n",
+ "g=2; #number of gents left\n",
+ "l=2; #number of ladies left\n",
+ "\n",
+ "#Calculation\n",
+ "Nr=(g*bnew)-(anew*l);\n",
+ "Dr=bnew-(anew*l);\n",
+ "x=Nr/Dr; #factor\n",
+ "n=x*(aold+bold); #number of people originally present\n",
+ "\n",
+ "#Result\n",
+ "print \"number of people originally present is\",n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.16, Page number 7.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of each type of coin is 20.0 coins\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=1; #coin value 1 rupee\n",
+ "c2=0.5; #coin value 50 paise\n",
+ "c3=0.25; #coin value 25 paise\n",
+ "t=35; #total amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "n=t/(c1+c2+c3); #number of each type of coin(coins)\n",
+ "\n",
+ "#Result\n",
+ "print \"number of each type of coin is\",n,\"coins\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.17, Page number 7.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "fraction of same ratio is 0.183673469388\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=3/7;\n",
+ "b=1/5;\n",
+ "c=7/15;\n",
+ "\n",
+ "#Calculation\n",
+ "x=a*b/c; #fraction of same ratio\n",
+ "\n",
+ "#Result\n",
+ "print \"fraction of same ratio is\",x"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.18, Page number 7.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "present age of C is 42.0 years\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=90; #sum of ages of A, B, C(years)\n",
+ "n=6; #number of years ago\n",
+ "a=1; #ratio term for age of A\n",
+ "b=2; #ratio term for age of B\n",
+ "c=3; #ratio term for age of C\n",
+ "\n",
+ "#Calculation\n",
+ "age=s-(n*c); #sum of ages of A, B, C 6 years ago(years)\n",
+ "C=c*age/(a+b+c); #age of C 6 years ago(years)\n",
+ "Cp=C+a+b+c; #present age of C(years)\n",
+ "\n",
+ "#Result\n",
+ "print \"present age of C is\",Cp,\"years\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.19, Page number 7.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "second number is 12.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "s=532; #sum of squares of 3 numbers\n",
+ "a=3; #first term of ratio\n",
+ "b=2; #second term of ratio\n",
+ "\n",
+ "#Calculation\n",
+ "n1=a*a; #first number\n",
+ "n2=a*b; #second number\n",
+ "n3=b*b; #third number\n",
+ "x2=s/((n1**2)+(n2**2)+(n3**2));\n",
+ "x=math.sqrt(x2); #factor\n",
+ "N2=n2*x; #second number\n",
+ "\n",
+ "#Result\n",
+ "print \"second number is\",N2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.20, Page number 7.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of wire is 188.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "l1=60; #length of wire(m)\n",
+ "w1=80; #weight of wire(kg)\n",
+ "l2=141; #length of another wire(m)\n",
+ "\n",
+ "#Calculation\n",
+ "x=w1*l2/l1; #weight of wire(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of wire is\",x,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.21, Page number 7.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "value of a/bc : b/ca is 4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "bc=1; #first term of ratio\n",
+ "ac=2; #second term of ratio\n",
+ "ab=3; #third term of ratio\n",
+ "\n",
+ "#Calculation\n",
+ "#abyb=ac/bc\n",
+ "a=ac;\n",
+ "b=bc;\n",
+ "result=(a**2)/(b**2); #value of a/bc : b/ca\n",
+ "\n",
+ "#Result\n",
+ "print \"value of a/bc : b/ca is\",int(result)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.23, Page number 7.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of 1 rupee coins is 5.0\n",
+ "number of 50 paise coins is 15.0\n",
+ "number of 25 paise coins is 25.0\n",
+ "number of 10 paise coins is 35.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "v1=1; #one rupee coin\n",
+ "v2=1/2; #50 paise coin\n",
+ "v3=1/4; #25 paise coin\n",
+ "v4=1/10; #10 paise coin\n",
+ "n1=1; #number of 1 rupee coins\n",
+ "n2=3; #number of 50 paise coins\n",
+ "n3=5; #number of 25 paise coins\n",
+ "n4=7; #number of 10 paise coins\n",
+ "s=22.25; #total amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "a=(v1*n1)+(v2*n2)+(v3*n3)+(v4*n4);\n",
+ "x=s/a; #factor\n",
+ "N1=x*n1; #number of 1 rupee coins\n",
+ "N2=x*n2; #number of 50 paise coins\n",
+ "N3=x*n3; #number of 25 paise coins\n",
+ "N4=x*n4; #number of 10 paise coins\n",
+ "\n",
+ "#Result\n",
+ "print \"number of 1 rupee coins is\",N1\n",
+ "print \"number of 50 paise coins is\",N2\n",
+ "print \"number of 25 paise coins is\",N3\n",
+ "print \"number of 10 paise coins is\",N4"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 7.24, Page number 7.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the person should have atleast 57.0 pens\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "from fractions import gcd\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1/3;\n",
+ "b=1/4;\n",
+ "c=1/5;\n",
+ "d=1/6;\n",
+ "\n",
+ "#Calculation\n",
+ "l1=(1/a)*(1/b)/gcd(1/a,1/b);\n",
+ "l2=(1/c)*(1/d)/gcd(1/c,1/d);\n",
+ "l=l1*l2/gcd(l1,l2); #lcm of 3,4,5,6\n",
+ "A=a*l;\n",
+ "B=b*l;\n",
+ "C=c*l;\n",
+ "D=d*l;\n",
+ "p=A+B+C+D;\n",
+ "\n",
+ "#Result\n",
+ "print \"the person should have atleast\",p,\"pens\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter8.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter8.ipynb new file mode 100755 index 00000000..ad182efa --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter8.ipynb @@ -0,0 +1,691 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#8: Partnership and Share"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 8.1, Page number 8.1"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "investment of A is 5000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "A=12000; #investment of A and B(Rs)\n",
+ "P=1800; #profit(Rs)\n",
+ "Pa=750; #profit of A(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "ratio=Pa/(P-Pa); #ratio of investments\n",
+ "Ia=Pa*A/P; #investment of A(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"investment of A is\",Ia,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 8.2, Page number 8.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "profit share of A is 1500.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ca=10000; #capital of A(Rs)\n",
+ "na=12; #number of years\n",
+ "nb=4; #number of years\n",
+ "Cb=5000; #capital of B(Rs)\n",
+ "P=2000; #total profit(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "a=Ca*na;\n",
+ "b=Cb*(na-nb);\n",
+ "r=a/b; #ratio of profits\n",
+ "Pa=a*P/(a+b); #profit share of A(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"profit share of A is\",Pa,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 8.3, Page number 8.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "profit of A is 57.0 Rs\n",
+ "profit of B is 60.0 Rs\n",
+ "profit of C is 63.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ia=380; #investment of A(Rs)\n",
+ "Ib=400; #investment of B(Rs)\n",
+ "Ic=420; #investment of C(Rs)\n",
+ "P=180; #net profit(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "I=Ia+Ib+Ic; #total investment(Rs)\n",
+ "Pa=Ia*P/I; #profit of A(Rs)\n",
+ "Pb=Ib*P/I; #profit of B(Rs)\n",
+ "Pc=Ic*P/I; #profit of C(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"profit of A is\",Pa,\"Rs\"\n",
+ "print \"profit of B is\",Pb,\"Rs\"\n",
+ "print \"profit of C is\",Pc,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 8.4, Page number 8.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "profit of A is 64.0 Rs\n",
+ "profit of B is 76.5 Rs\n",
+ "profit of C is 67.5 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Ca=320*4; #contribution of A for 4 months(Rs)\n",
+ "Cb=510*3; #contribution of B for 3 months(Rs)\n",
+ "Cc=270*5; #contribution on C for 5 months(Rs)\n",
+ "P=208; #net profit(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "C=Ca+Cb+Cc; #contribution of A,B,C(Rs)\n",
+ "Pa=Ca*P/C; #profit of A(Rs)\n",
+ "Pb=Cb*P/C; #profit of B(Rs)\n",
+ "Pc=Cc*P/C; #profit of C(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"profit of A is\",Pa,\"Rs\"\n",
+ "print \"profit of B is\",Pb,\"Rs\"\n",
+ "print \"profit of C is\",Pc,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "##Example number 8.5, Page number 8.2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "profit of B is 420.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "C=8200; #total capital(Rs)\n",
+ "a=1000;\n",
+ "b=2000;\n",
+ "Cb=(C-(b+a+a))/3; #capital of B(Rs)\n",
+ "P=2460; #total profit(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "Pb=Cb*P/C; #profit of B(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"profit of B is\",Pb,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.6, Page number 8.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "C must pay Rs 10.0 to A\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "m=50; #amount with each person(Rs)\n",
+ "mA=20; #amount left with A(Rs)\n",
+ "mB=30; #amount left with B(Rs)\n",
+ "mC=40; #amount left with C(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "Ms=m*3; #total amount started with(Rs)\n",
+ "Mr=mA+mB+mC; #total amount ending with(Rs)\n",
+ "M=Mr/3; #amount each person must have(Rs)\n",
+ "Cm=mC-M; #C must pay(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"C must pay Rs\",Cm,\"to A\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.7, Page number 8.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "share of C is 240.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=1290; #amount(Rs)\n",
+ "A=3; #value of A in the ratio A:B\n",
+ "B1=2; #value of B in the ratio A:B \n",
+ "B2=7; #value of B in the ratio B:C\n",
+ "C1=4; #value of C in the ratio B:C\n",
+ "\n",
+ "#Calculation\n",
+ "#inorder to make the value of B in the ratios same, multiply by B2\n",
+ "A=A*B2;\n",
+ "B=B1*B2;\n",
+ "C=C1*B1; #new values of the ratio A:B:C\n",
+ "Sc=C*a/(A+B+C); #share of C(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"share of C is\",Sc,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.8, Page number 8.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "balance profit of B is 360.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "A=390; #amount A receives(Rs)\n",
+ "Ap=10*12; #profit for A(Rs)\n",
+ "Ia=3000; #investment of A(Rs)\n",
+ "Ib=4000; #investment of B(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "Ba=A-Ap; #balance profit of A(Rs)\n",
+ "Bb=Ba*Ib/Ia; #balance profit of B(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"balance profit of B is\",Bb,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.9, Page number 8.3"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total amount of money is 200 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "BplusC=100; #amount with B and C(Rs)\n",
+ "AplusC=150; #amount with A and C(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "B=AplusC-BplusC; #amount with B(Rs)\n",
+ "ABC=AplusC+B; #total amount of money(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total amount of money is\",ABC,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.10, Page number 8.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "profit share of A is 330.0 Rs\n",
+ "profit share of B is 430.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "A=760; #amount(Rs)\n",
+ "Ar=4; #part of A in ratio\n",
+ "Br=5; #part of B in ratio\n",
+ "At=3; #time for A(months)\n",
+ "AT=10-3; #ending time(months)\n",
+ "\n",
+ "#Calculation\n",
+ "MEI_A=(Ar*At)+(AT*Ar*At/Ar); #monthly equivalent investment of A\n",
+ "MEI_B=(Br*At)+(AT*Br*Ar/Br); #monthly equivalent investment of B\n",
+ "PA=MEI_A*A/(MEI_A+MEI_B); #profit share of A(Rs)\n",
+ "PB=MEI_B*A/(MEI_A+MEI_B); #profit share of B(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"profit share of A is\",PA,\"Rs\"\n",
+ "print \"profit share of B is\",PB,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.11, Page number 8.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "payment for rent by A is 8550.0 Rs\n",
+ "payment for rent by B is 5950.0 Rs\n",
+ "payment for rent by C is 9200.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Fd_A=27; #floppy disks of A\n",
+ "Ad=19; #number of days for A\n",
+ "Fd_B=21; #floppy disks of B\n",
+ "Bd=17; #number of days for B\n",
+ "Fd_C=24; #floppy disks of C\n",
+ "Cd=23; #number of days for C\n",
+ "am=23700; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "A=Fd_A*Ad; #A's floppy days\n",
+ "B=Fd_B*Bd; #B's floppy days\n",
+ "C=Fd_C*Cd; #C's floppy days\n",
+ "PA=A*am/(A+B+C); #payment for rent by A(Rs)\n",
+ "PB=B*am/(A+B+C); #payment for rent by B(Rs)\n",
+ "PC=C*am/(A+B+C); #payment for rent by C(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"payment for rent by A is\",PA,\"Rs\"\n",
+ "print \"payment for rent by B is\",PB,\"Rs\"\n",
+ "print \"payment for rent by C is\",PC,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.12, Page number 8.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "capital of A is 3000.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "S=1000; #share of A(Rs)\n",
+ "IA=8; #investment of A(months)\n",
+ "IB=12; #investment of B(months)\n",
+ "PA=PB=1; \n",
+ "\n",
+ "#Calculation\n",
+ "CA=(PA/PB)*S*(IB/(IA/2)); #capital of A(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"capital of A is\",CA,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.13, Page number 8.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total profit is 1000.0 Rs\n",
+ "answer given in the book is wrong\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Sa=4000; #A's share(s)\n",
+ "Sb=5000; #B's share(Rs)\n",
+ "Sc=6000; #C's share(Rs)\n",
+ "r=1000; #ratio fraction\n",
+ "p=75/100; #profit percentage(%)\n",
+ "P=25/100;\n",
+ "A=100; #A gets less(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "TP=((Sa/r)+(Sb/r)+(Sc/r))/p; #total profit\n",
+ "As=(Sa/r)+(P*TP); #share of A\n",
+ "Bs=Sb/r; #share of B\n",
+ "Cs=Sc/r; #share of C\n",
+ "x=A/((Bs+Cs)-As);\n",
+ "Tp=TP*x; #total profit(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total profit is\",Tp,\"Rs\"\n",
+ "print \"answer given in the book is wrong\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.14, Page number 8.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total profit is 393.75 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "AP40=1250; #A's 40% profit(Rs)\n",
+ "BP40=850; #B's 40% profit(Rs)\n",
+ "A=30; #amount received more(Rs)\n",
+ "p=60/100; #distributed profit(%)\n",
+ "\n",
+ "#Calculation\n",
+ "R=(AP40+BP40)/(AP40-BP40); #applying componendo dividendo\n",
+ "P=R*A/(1-p); #total profit(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"total profit is\",P,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 8.15, Page number 8.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "share of A is 100.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "CA=1/6; #capital of A\n",
+ "CB=1/3; #capital of B\n",
+ "P=2300; #total profit(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "CC=1-CA-CB; #capital of C\n",
+ "PA=CA*CA*12; #A's profit\n",
+ "PB=CB*CB*12; #B's profit\n",
+ "PC=CC*12; #C's profit\n",
+ "SA=PA*P/(PA+PB+PC); #share of A(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"share of A is\",SA,\"Rs\""
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/Chapter9.ipynb b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter9.ipynb new file mode 100755 index 00000000..b7d05043 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/Chapter9.ipynb @@ -0,0 +1,1115 @@ +{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# 9: Mixtures"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.1, Page number 9.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "proportion to be mixed is 4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=9.5; #cost of oil per kg(Rs)\n",
+ "c2=10; #cost of another oil(Rs)\n",
+ "Cm=9.6; #cost of mixture(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "q1byq2=(c2-Cm)/(Cm-c1); #proportion to be mixed\n",
+ "\n",
+ "#Result\n",
+ "print \"proportion to be mixed is\",int(q1byq2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.2, Page number 9.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "proportion to be mixed is 0.666666666667\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=25; #percentage of alcohol(%)\n",
+ "c2=50; #percentage of alcohol(%)\n",
+ "Cm=40; #alcohol strength(%)\n",
+ "\n",
+ "#Calculation\n",
+ "q1byq2=(c2-Cm)/(Cm-c1); #proportion to be mixed\n",
+ "\n",
+ "#Result\n",
+ "print \"proportion to be mixed is\",q1byq2"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.3, Page number 9.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "quantity of money lent at 8% is 400.0 Rs\n",
+ "quantity of money lent at 10% is 600.0 Rs\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=8; #first part(%)\n",
+ "c2=10; #second part(%)\n",
+ "Cm=9.2; #yearly average(%)\n",
+ "A=1000; #amount(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "q1=c2-Cm;\n",
+ "q2=Cm-c1; \n",
+ "A1=q1*A/(q1+q2); #quantity of money lent at 8%(Rs)\n",
+ "A2=q2*A/(q1+q2); #quantity of money lent at 10%(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"quantity of money lent at 8% is\",A1,\"Rs\"\n",
+ "print \"quantity of money lent at 10% is\",A2,\"Rs\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.4, Page number 9.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of water to be added is 5.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=0; #pure milk(litres)\n",
+ "c2=3.6; #cost of pure milk(Rs)\n",
+ "Cm=3; #cost of mixture(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "q1byq2=(Cm-c1)/(c2-Cm); #amount of water to be added(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of water to be added is\",q1byq2,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.5, Page number 9.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of salt is 20.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=24; #cost of salt(paise)\n",
+ "c2=42; #cost of salt(paise)\n",
+ "c=40; #cost of mixture(paise)\n",
+ "e=25; #efficiency(%) \n",
+ "\n",
+ "#Calculation\n",
+ "Cm=c*100/(100+e); #cost price of mixture(paise)\n",
+ "q1byq2=(Cm-c1)/(c2-Cm); #proportion to be mixed\n",
+ "q=q1byq2*e; #amount of salt(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of salt is\",q,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.6, Page number 9.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 15,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "strength of alcohol is 16.6666666667 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=5; #amount of alcohol solution(litres)\n",
+ "p=20/100; #percentage of solution\n",
+ "\n",
+ "#Calculation\n",
+ "A=p*a; #amount of alcohol(litre)\n",
+ "S=A*100/(A+a); #strength of alcohol(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"strength of alcohol is\",S,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.7, Page number 9.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 16,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of water to be added is 5.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=90/100; #percentage of milk in mixture(%)\n",
+ "p2=10/100; #percentage of water in mixture(%)\n",
+ "a=40; #amount of mixture(litres)\n",
+ "p_2=20; #new percent of water(%)\n",
+ "\n",
+ "#Calculation\n",
+ "A=(p1*a*p_2/(100-p_2))-(p2*a); #amount of water to be added(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of water to be added is\",A,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.8, Page number 9.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of pure milk is 25.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=0; \n",
+ "c2=3.0; #cost of pure milk(Rs)\n",
+ "e=20/100; #efficiency(%) \n",
+ "\n",
+ "#Calculation\n",
+ "Cm=c2/(1+e); #CP of mixture(Rs)\n",
+ "q1byq2=(Cm-c1)/(c2-Cm); #proportion to be mixed\n",
+ "A=q1byq2**2; #amount of pure milk(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of pure milk is\",A,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.9, Page number 9.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "selling price of mixture is Rs 7.04 per kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=6; #amount of tea(kg)\n",
+ "p1=6; #cost of tea(Rs)\n",
+ "a2=4; #amount of tea(kg)\n",
+ "p2=7; #cost of tea(Rs)\n",
+ "p=10/100; #profit(p)\n",
+ "\n",
+ "#Calculation\n",
+ "cp=((a1*p1)+(a2*p2))/(a1+a2); #cost price of mixture(Rs)\n",
+ "sp=(1+p)*cp; #selling price of mixture(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"selling price of mixture is Rs\",sp,\"per kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.10, Page number 9.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "strength of acid in mixture is 60.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "p1=20; #percentage of sulphuric acid(%)\n",
+ "q1=5; #amount of acid(litres)\n",
+ "p2=100; #percentage of pure sulphuric acid(%)\n",
+ "q2=5; #amount of acid(litres)\n",
+ "\n",
+ "#Calculation\n",
+ "s=((p1*q1)+(p2*q2))/(q1+q2); #strength of acid in mixture(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"strength of acid in mixture is\",s,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.11, Page number 9.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "cost price of 1st liquid is Rs 10.8 per litre\n",
+ "cost price of 2nd liquid is Rs 8.8 per litre\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "q1=3\n",
+ "q2=2; \n",
+ "c=11; #cost at which mixture is sold(Rs)\n",
+ "p=10/100; #profit(%)\n",
+ "\n",
+ "#Calculation\n",
+ "Cm=c/(1+p); #cost price of mixture(Rs)\n",
+ "x=((q2*Cm)+(q1*Cm)+(q2*q2))/(q1+q2); #cost price of 1st liquid(Rs)\n",
+ "x2=x-q2; #cost price of 2nd liquid(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"cost price of 1st liquid is Rs\",x,\"per litre\"\n",
+ "print \"cost price of 2nd liquid is Rs\",x2,\"per litre\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.12, Page number 9.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "alcohol and water are in the proportion of 1.4\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=2;\n",
+ "b=1; #proportion of 1st mixture of alcohol and water\n",
+ "x=1;\n",
+ "y=1; #proportion of 2nd mixture of alcohol and water\n",
+ "\n",
+ "#Calculation\n",
+ "q1=(a/(a+b))+(x/(x+y)); #quantity of alcohol in 3rd glass\n",
+ "q2=(b/(a+b))+(y/(x+y)); #quantity of water in 3rd glass\n",
+ "\n",
+ "#Result\n",
+ "print \"alcohol and water are in the proportion of\",q1/q2 "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.13, Page number 9.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "gain made on sale of 5 quintals is Rs 110.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=2.10; #cost price of coffee(Rs)\n",
+ "q1=15; #quantity of coffee(parts)\n",
+ "c2=0.98; #cost price of chicory(Rs)\n",
+ "q2=1; #quantity of chicory(part)\n",
+ "s=2.25; #selling price per kg(Rs)\n",
+ "a=500; #amount(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "Cm=((c1*q1)+(c2*q2))/(q1+q2); #cost price of mixture(Rs)\n",
+ "p=(s-Cm)*a; #gain made on sale of 5 quintals(Rs)\n",
+ "\n",
+ "#Result\n",
+ "print \"gain made on sale of 5 quintals is Rs\",p"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.14, Page number 9.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "percentage of alcohol is 28.0 %\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "qa=35; #percentage of alcohol by weight\n",
+ "qw=25; #weight of water(gms)\n",
+ "m=100; #total mixture(g)\n",
+ "\n",
+ "#Calculation\n",
+ "p=qa*100/(m+qw); #percentage of alcohol(%)\n",
+ "\n",
+ "#Result\n",
+ "print \"percentage of alcohol is\",p,\"%\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.15, Page number 9.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 28,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "quantity of the butt stolen is 0.57\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "Cm=24; #strength of butt(%)\n",
+ "c1=18; #percentage of spirit(%)\n",
+ "c2=32; #percentage of spirit(%)\n",
+ "\n",
+ "#Calculation\n",
+ "q1=Cm-c1; #quantity of 32% spirit\n",
+ "q2=c2-Cm; #quantity of 18% spirit\n",
+ "f=q2/(q1+q2); #quantity of the butt stolen\n",
+ "\n",
+ "#Result\n",
+ "print \"quantity of the butt stolen is\",round(f,2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.16, Page number 9.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "quantity of water added is 22.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "m=66; #mixture of milk(litres)\n",
+ "a=5;\n",
+ "b=1; #ratio of milk and water\n",
+ "x=5;\n",
+ "y=3; #new ratio \n",
+ "\n",
+ "#Calculation\n",
+ "x1=a*m*y/(a+b);\n",
+ "x2=a*m/(x+b);\n",
+ "x=(x1-x2)/a; #quantity of water added(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"quantity of water added is\",x,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.17, Page number 9.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of dry fruit obtained is 35.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "qw1=72/100; #content of water in fresh fruit(%)\n",
+ "a=100; #amount of fresh fruit(kg)\n",
+ "qw2=20/100; #content of water in dry fruit(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x=(1-qw1)*a/(1-qw2); #amount of dry fruit obtained(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of dry fruit obtained is\",x,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.18, Page number 9.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "quantity of fresh water to be added is 40.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "qs=5/100; #content of salt by water(%)\n",
+ "a=60; #amount of sea water(kg)\n",
+ "q=3; #content of salt in solution(%)\n",
+ "\n",
+ "#Calculation\n",
+ "x=((qs*a*100)-(q*a))/q; #quantity of fresh water to be added(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"quantity of fresh water to be added is\",x,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.19, Page number 9.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of first alloy is 7.0 kg\n",
+ "amount of second alloy is 21.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "qa=1; #copper in 1st alloy\n",
+ "qb=1; #copper in 2nd alloy\n",
+ "x=3;\n",
+ "y=4; #ratio of copper to zinc\n",
+ "a=5;\n",
+ "b=2; #ration of copper to zinc in new alloy\n",
+ "q=28; #quantity of new alloy(kg) \n",
+ "\n",
+ "#Calculation\n",
+ "Cm=qa/(qa+qb); #copper in new alloy\n",
+ "c1=x/(x+y); #copper in 2nd alloy\n",
+ "c2=a/(a+b); #copper in 1st alloy\n",
+ "q1=(Cm-c1);\n",
+ "q2=(c2-Cm);\n",
+ "a1=q1*q/(q1+q2); #amount of 1st alloy(kg)\n",
+ "a2=q-a1; #amount of second alloy(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of first alloy is\",a1,\"kg\"\n",
+ "print \"amount of second alloy is\",a2,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.20, Page number 9.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "weight of new alloy is 35.0 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=4;\n",
+ "b1=1; #relation of copper and zinc\n",
+ "a2=1;\n",
+ "b2=3; #relation of copper and zinc\n",
+ "a3=3;\n",
+ "b3=2; #ratio of copper to zinc \n",
+ "q1=10; #amount of 1st alloy(kg)\n",
+ "q2=16; #amount of 2nd alloy(kg)\n",
+ "\n",
+ "#Calculation\n",
+ "c1=a1*q1/(a1+b1); #copper in 1st alloy\n",
+ "c2=a2*q2/(a2+b2); #copper in 2nd alloy\n",
+ "x=(a3*(q1+q2))-((a3+b3)*(c1+c2)); \n",
+ "w=(x/2)+q1+q2; #weight of new alloy(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"weight of new alloy is\",w,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.21, Page number 9.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 34,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "number of boys is 33.0\n",
+ "number of girls is 12.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=39; #amount(Rs)\n",
+ "s=45; #number of boys and girls\n",
+ "c1=50/100; #amount girl gets(Rs)\n",
+ "c2=1; #amount boy gets(Rs)\n",
+ "\n",
+ "#Calculation\n",
+ "Cm=a/s;\n",
+ "qb=(Cm-c1); #number of boys in ratio\n",
+ "qg=(c2-Cm); #number of girls in ratio\n",
+ "b=qb*s/(qb+qg); #number of boys\n",
+ "g=s-b; #number of girls\n",
+ "\n",
+ "#Result\n",
+ "print \"number of boys is\",b\n",
+ "print \"number of girls is\",g"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.22, Page number 9.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "quantity of mixture released is 2.0 litres\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "co=9/100; #content of oxygen\n",
+ "vo=16/100; #volume of oxygen\n",
+ "q=8; #quantity of cylinder(litre)\n",
+ "\n",
+ "#Calculation\n",
+ "r=math.sqrt(co*q/(vo*q));\n",
+ "R=q*(1-r); #quantity of mixture released(litres)\n",
+ "\n",
+ "#Result\n",
+ "print \"quantity of mixture released is\",R,\"litres\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.23, Page number 9.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "amount of milk left is 72.9 kg\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x0=100; #original amount of milk(kg)\n",
+ "xr=10; #amount of milk removed(kg)\n",
+ "n=3; #number of operations\n",
+ "\n",
+ "#Calculation\n",
+ "a=x0*(1-(xr/x0))**n; #amount of milk left(kg)\n",
+ "\n",
+ "#Result\n",
+ "print \"amount of milk left is\",a,\"kg\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.24, Page number 9.11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 44,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ratio of dettol and water is 0.25\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "x0=1; #quantity of dettol(litre)\n",
+ "xr=1/3; #quantity of dettol removed(litre)\n",
+ "n=4; #number of operations\n",
+ "\n",
+ "#Calculation\n",
+ "Aa=(1-(xr/x0))**n; #amount of dettol left(litre)\n",
+ "Ba=1-Aa; #amount of water left(litre)\n",
+ "r=Aa/Ba; #ratio of dettol and water \n",
+ "\n",
+ "#Result\n",
+ "print \"ratio of dettol and water is\",round(r,2)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.25, Page number 9.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "part of the mixture taken out is 0.2\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "a1=5; #parts of after shave lotion\n",
+ "b1=3; #parts of water\n",
+ "Al=1/2; #amount of after shave lotion\n",
+ "\n",
+ "#Calculation\n",
+ "Ap=a1/(a1+b1); #amount of after shave lotion present\n",
+ "R=1-(Al/Ap); #part of the mixture taken out\n",
+ "\n",
+ "#Result\n",
+ "print \"part of the mixture taken out is\",R"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example number 9.26, Page number 9.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "three kinds of rice are mixed in the ratio 11.0 : 77.0 : 7.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "#importing modules\n",
+ "import math\n",
+ "from __future__ import division\n",
+ "\n",
+ "#Variable declaration\n",
+ "c1=12; #cost price of 1st variety(Rs)\n",
+ "c2=14.40; #cost price of 2nd variety(Rs)\n",
+ "c3=17.40; #cost price of 3rd variety(Rs)\n",
+ "Cm=14.10; #cost price of mixture(Rs)\n",
+ "f=11.11; #factor to be rounded off\n",
+ "\n",
+ "#Calculation\n",
+ "q1=(c2-Cm)*(c3-Cm)*f; #quantity of 1st variety(kg)\n",
+ "q2=(Cm-c1)*(c3-Cm)*f; #quantity of 2nd variety(kg)\n",
+ "q3=(c2-Cm)*(Cm-c1)*f; #quantity of 3rd variety(kg)\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print \"three kinds of rice are mixed in the ratio\",round(q1),\":\",round(q2),\":\",round(q3)"
+ ]
+ }
+ ],
+ "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.9"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/11.png b/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/11.png Binary files differnew file mode 100755 index 00000000..7300feac --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/11.png diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/22.png b/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/22.png Binary files differnew file mode 100755 index 00000000..d4f115e8 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/22.png diff --git a/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/33.png b/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/33.png Binary files differnew file mode 100755 index 00000000..49d55765 --- /dev/null +++ b/Quantitative_Aptitude_for_Competitive_Examinations/screenshots/33.png |