summaryrefslogtreecommitdiff
path: root/Quantitative_Aptitude_for_Competitive_Examinations/Chapter3.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Quantitative_Aptitude_for_Competitive_Examinations/Chapter3.ipynb')
-rwxr-xr-xQuantitative_Aptitude_for_Competitive_Examinations/Chapter3.ipynb738
1 files changed, 738 insertions, 0 deletions
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
+}