summaryrefslogtreecommitdiff
path: root/Quantitative_Aptitude_for_Competitive_Examinations/Chapter1.ipynb
blob: c048e48860a6a390f342697a18b2b207a9a995ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
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
}