summaryrefslogtreecommitdiff
path: root/Quantitative_Aptitude_for_Competitive_Examinations/Chapter9.ipynb
blob: b7d05043dc0ea48ce12601ad0d1efa41038627fc (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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
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
}