In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=9.5; #cost of oil per kg(Rs)
c2=10; #cost of another oil(Rs)
Cm=9.6; #cost of mixture(Rs)
#Calculation
q1byq2=(c2-Cm)/(Cm-c1); #proportion to be mixed
#Result
print "proportion to be mixed is",int(q1byq2)
```

In [5]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=25; #percentage of alcohol(%)
c2=50; #percentage of alcohol(%)
Cm=40; #alcohol strength(%)
#Calculation
q1byq2=(c2-Cm)/(Cm-c1); #proportion to be mixed
#Result
print "proportion to be mixed is",q1byq2
```

In [6]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=8; #first part(%)
c2=10; #second part(%)
Cm=9.2; #yearly average(%)
A=1000; #amount(Rs)
#Calculation
q1=c2-Cm;
q2=Cm-c1;
A1=q1*A/(q1+q2); #quantity of money lent at 8%(Rs)
A2=q2*A/(q1+q2); #quantity of money lent at 10%(Rs)
#Result
print "quantity of money lent at 8% is",A1,"Rs"
print "quantity of money lent at 10% is",A2,"Rs"
```

In [13]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=0; #pure milk(litres)
c2=3.6; #cost of pure milk(Rs)
Cm=3; #cost of mixture(Rs)
#Calculation
q1byq2=(Cm-c1)/(c2-Cm); #amount of water to be added(litres)
#Result
print "amount of water to be added is",q1byq2,"litres"
```

In [14]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=24; #cost of salt(paise)
c2=42; #cost of salt(paise)
c=40; #cost of mixture(paise)
e=25; #efficiency(%)
#Calculation
Cm=c*100/(100+e); #cost price of mixture(paise)
q1byq2=(Cm-c1)/(c2-Cm); #proportion to be mixed
q=q1byq2*e; #amount of salt(kg)
#Result
print "amount of salt is",q,"kg"
```

In [15]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=5; #amount of alcohol solution(litres)
p=20/100; #percentage of solution
#Calculation
A=p*a; #amount of alcohol(litre)
S=A*100/(A+a); #strength of alcohol(%)
#Result
print "strength of alcohol is",S,"%"
```

In [16]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=90/100; #percentage of milk in mixture(%)
p2=10/100; #percentage of water in mixture(%)
a=40; #amount of mixture(litres)
p_2=20; #new percent of water(%)
#Calculation
A=(p1*a*p_2/(100-p_2))-(p2*a); #amount of water to be added(litres)
#Result
print "amount of water to be added is",A,"litres"
```

In [17]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=0;
c2=3.0; #cost of pure milk(Rs)
e=20/100; #efficiency(%)
#Calculation
Cm=c2/(1+e); #CP of mixture(Rs)
q1byq2=(Cm-c1)/(c2-Cm); #proportion to be mixed
A=q1byq2**2; #amount of pure milk(litres)
#Result
print "amount of pure milk is",A,"litres"
```

In [18]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=6; #amount of tea(kg)
p1=6; #cost of tea(Rs)
a2=4; #amount of tea(kg)
p2=7; #cost of tea(Rs)
p=10/100; #profit(p)
#Calculation
cp=((a1*p1)+(a2*p2))/(a1+a2); #cost price of mixture(Rs)
sp=(1+p)*cp; #selling price of mixture(Rs)
#Result
print "selling price of mixture is Rs",sp,"per kg"
```

In [19]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=20; #percentage of sulphuric acid(%)
q1=5; #amount of acid(litres)
p2=100; #percentage of pure sulphuric acid(%)
q2=5; #amount of acid(litres)
#Calculation
s=((p1*q1)+(p2*q2))/(q1+q2); #strength of acid in mixture(%)
#Result
print "strength of acid in mixture is",s,"%"
```

In [20]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
q1=3
q2=2;
c=11; #cost at which mixture is sold(Rs)
p=10/100; #profit(%)
#Calculation
Cm=c/(1+p); #cost price of mixture(Rs)
x=((q2*Cm)+(q1*Cm)+(q2*q2))/(q1+q2); #cost price of 1st liquid(Rs)
x2=x-q2; #cost price of 2nd liquid(Rs)
#Result
print "cost price of 1st liquid is Rs",x,"per litre"
print "cost price of 2nd liquid is Rs",x2,"per litre"
```

In [23]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=2;
b=1; #proportion of 1st mixture of alcohol and water
x=1;
y=1; #proportion of 2nd mixture of alcohol and water
#Calculation
q1=(a/(a+b))+(x/(x+y)); #quantity of alcohol in 3rd glass
q2=(b/(a+b))+(y/(x+y)); #quantity of water in 3rd glass
#Result
print "alcohol and water are in the proportion of",q1/q2
```

In [24]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=2.10; #cost price of coffee(Rs)
q1=15; #quantity of coffee(parts)
c2=0.98; #cost price of chicory(Rs)
q2=1; #quantity of chicory(part)
s=2.25; #selling price per kg(Rs)
a=500; #amount(kg)
#Calculation
Cm=((c1*q1)+(c2*q2))/(q1+q2); #cost price of mixture(Rs)
p=(s-Cm)*a; #gain made on sale of 5 quintals(Rs)
#Result
print "gain made on sale of 5 quintals is Rs",p
```

In [25]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
qa=35; #percentage of alcohol by weight
qw=25; #weight of water(gms)
m=100; #total mixture(g)
#Calculation
p=qa*100/(m+qw); #percentage of alcohol(%)
#Result
print "percentage of alcohol is",p,"%"
```

In [28]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
Cm=24; #strength of butt(%)
c1=18; #percentage of spirit(%)
c2=32; #percentage of spirit(%)
#Calculation
q1=Cm-c1; #quantity of 32% spirit
q2=c2-Cm; #quantity of 18% spirit
f=q2/(q1+q2); #quantity of the butt stolen
#Result
print "quantity of the butt stolen is",round(f,2)
```

In [29]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
m=66; #mixture of milk(litres)
a=5;
b=1; #ratio of milk and water
x=5;
y=3; #new ratio
#Calculation
x1=a*m*y/(a+b);
x2=a*m/(x+b);
x=(x1-x2)/a; #quantity of water added(litres)
#Result
print "quantity of water added is",x,"litres"
```

In [30]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
qw1=72/100; #content of water in fresh fruit(%)
a=100; #amount of fresh fruit(kg)
qw2=20/100; #content of water in dry fruit(%)
#Calculation
x=(1-qw1)*a/(1-qw2); #amount of dry fruit obtained(kg)
#Result
print "amount of dry fruit obtained is",x,"kg"
```

In [31]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
qs=5/100; #content of salt by water(%)
a=60; #amount of sea water(kg)
q=3; #content of salt in solution(%)
#Calculation
x=((qs*a*100)-(q*a))/q; #quantity of fresh water to be added(kg)
#Result
print "quantity of fresh water to be added is",x,"kg"
```

In [32]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
qa=1; #copper in 1st alloy
qb=1; #copper in 2nd alloy
x=3;
y=4; #ratio of copper to zinc
a=5;
b=2; #ration of copper to zinc in new alloy
q=28; #quantity of new alloy(kg)
#Calculation
Cm=qa/(qa+qb); #copper in new alloy
c1=x/(x+y); #copper in 2nd alloy
c2=a/(a+b); #copper in 1st alloy
q1=(Cm-c1);
q2=(c2-Cm);
a1=q1*q/(q1+q2); #amount of 1st alloy(kg)
a2=q-a1; #amount of second alloy(kg)
#Result
print "amount of first alloy is",a1,"kg"
print "amount of second alloy is",a2,"kg"
```

In [33]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=4;
b1=1; #relation of copper and zinc
a2=1;
b2=3; #relation of copper and zinc
a3=3;
b3=2; #ratio of copper to zinc
q1=10; #amount of 1st alloy(kg)
q2=16; #amount of 2nd alloy(kg)
#Calculation
c1=a1*q1/(a1+b1); #copper in 1st alloy
c2=a2*q2/(a2+b2); #copper in 2nd alloy
x=(a3*(q1+q2))-((a3+b3)*(c1+c2));
w=(x/2)+q1+q2; #weight of new alloy(kg)
#Result
print "weight of new alloy is",w,"kg"
```

In [34]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=39; #amount(Rs)
s=45; #number of boys and girls
c1=50/100; #amount girl gets(Rs)
c2=1; #amount boy gets(Rs)
#Calculation
Cm=a/s;
qb=(Cm-c1); #number of boys in ratio
qg=(c2-Cm); #number of girls in ratio
b=qb*s/(qb+qg); #number of boys
g=s-b; #number of girls
#Result
print "number of boys is",b
print "number of girls is",g
```

In [35]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
co=9/100; #content of oxygen
vo=16/100; #volume of oxygen
q=8; #quantity of cylinder(litre)
#Calculation
r=math.sqrt(co*q/(vo*q));
R=q*(1-r); #quantity of mixture released(litres)
#Result
print "quantity of mixture released is",R,"litres"
```

In [36]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
x0=100; #original amount of milk(kg)
xr=10; #amount of milk removed(kg)
n=3; #number of operations
#Calculation
a=x0*(1-(xr/x0))**n; #amount of milk left(kg)
#Result
print "amount of milk left is",a,"kg"
```

In [44]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
x0=1; #quantity of dettol(litre)
xr=1/3; #quantity of dettol removed(litre)
n=4; #number of operations
#Calculation
Aa=(1-(xr/x0))**n; #amount of dettol left(litre)
Ba=1-Aa; #amount of water left(litre)
r=Aa/Ba; #ratio of dettol and water
#Result
print "ratio of dettol and water is",round(r,2)
```

In [40]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=5; #parts of after shave lotion
b1=3; #parts of water
Al=1/2; #amount of after shave lotion
#Calculation
Ap=a1/(a1+b1); #amount of after shave lotion present
R=1-(Al/Ap); #part of the mixture taken out
#Result
print "part of the mixture taken out is",R
```

In [41]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
c1=12; #cost price of 1st variety(Rs)
c2=14.40; #cost price of 2nd variety(Rs)
c3=17.40; #cost price of 3rd variety(Rs)
Cm=14.10; #cost price of mixture(Rs)
f=11.11; #factor to be rounded off
#Calculation
q1=(c2-Cm)*(c3-Cm)*f; #quantity of 1st variety(kg)
q2=(Cm-c1)*(c3-Cm)*f; #quantity of 2nd variety(kg)
q3=(c2-Cm)*(Cm-c1)*f; #quantity of 3rd variety(kg)
#Result
print "three kinds of rice are mixed in the ratio",round(q1),":",round(q2),":",round(q3)
```