In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=0.4;
b=1.0;
c=5/3;
d=7;
e=1.23;
#Calculation
A=a*100; #in terms of percentage(%)
B=b*100; #in terms of percentage(%)
C=c*100; #in terms of percentage(%)
D=d*100; #in terms of percentage(%)
E=e*100; #in terms of percentage(%)
#Result
print "0.4 in terms of percentage is",A,"%"
print "1.0 in terms of percentage is",B,"%"
print "5/3 in terms of percentage is",round(C,2),"%"
print "7x/y in terms of percentage is",D,"x/y %"
print "1.23 in terms of percentage is",E,"%"
```

In [4]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=22+(1/2);
b=35;
c=0.3;
d=2/7;
#Calculation
A=a/100; #in terms of fraction
B=b/100; #in terms of fraction
C=c/100; #in terms of fraction
D=d/100; #in terms of fraction
#Result
print "22 1/2 in terms of fraction is",A
print "35 in terms of fraction is",B
print "a**2/b in terms of fraction is a**2/100b"
print "0.3 in terms of fraction is",C
print "2/7 in terms of fraction is",round(D,4)
```

In [7]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=9;
a1=27;
p2=0.02;
a2=6500;
p3=7/2;
a3=80;
p4=125;
a4=64;
p5=10;
P5=5;
a5=320;
#Calculation
A1=p1*a1/100;
A2=p2*a2/100;
A3=p3*a3/100;
A4=p4*a4/100;
A5=p5*P5*a5/(100*100);
#Result
print "value in 1st case is",A1
print "value in 2nd case is",A2
print "value in 3rd case is",A3
print "value in 4th case is",A4
print "value in 5th case is",A5
```

In [11]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=36;
b1=144;
a2=7/8;
b2=3/4;
a3=16;
b3=80;
a4=0.625;
b4=1+(7/28);
a5=36*14;
b5=1400;
#Calculation
v1=a1*100/b1; #value(%)
v2=a2*100/b2; #value(%)
v3=a3*100/b3; #value(%)
v4=a4*100/b4; #value(%)
v5=a5*100/b5; #value(%)
#Result
print "value in 1st case is",v1,"%"
print "value in 2nd case is",round(v2,2),"%"
print "value in 3rd case is",v3,"%"
print "value in 4th case is",v4,"%"
print "value in 5th case is",v5,"%"
print "value in 6th case is 100R/N %"
```

In [13]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=6;
a1=36;
p2=5;
a2=2.5;
p3=25;
P3=20;
a3=12;
p4=14;
a4=4/7;
#Calculation
A1=a1*100/p1;
A2=a2*100/p2;
A3=a3*100*100/(p3*P3);
A4=a4*100/p4;
#Result
print "value in 1st case is",A1
print "value in 2nd case is",A2
print "value in 3rd case is",A3
print "value in 4th case is",round(A4,2)
```

In [1]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=25;
p2=40;
x1=20;
#Calculation
x2=x1*p2/p1; #40% of number
N=x1*100/p1; #original number
#Result
print "40% of number is",x2
print "original number is",N
```

In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
e=25; #% excess
#Calculation
s=e*100/(100+e); #%short
#Result
print "B is short of A by",s
```

In [5]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
s=40; #%short
#Calculation
e=s*100/(100-s); #% excess
#Result
print "Y is excess of X by",round(e,2)
```

In [7]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
J=2+(1/2);
j=2+(1/4);
#Calculation
d=J-j; #difference
s1=d*100/j; #salary more(%)
s2=d*100/J; #salary less(%)
#Result
print "salary of july more than that of june is",round(s1,2),"%"
print "salary of june less than that of july is",s2,"%"
```

In [8]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
e=1500; #total enrollment
p=10; #percentage increment
#Calculation
E=e*(100+p)/100; #enrollment in 1988
#Result
print "enrollment in 1988 is",E
```

In [10]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
x=-40; #% decrease
y=30; #% increase
#Calculation
n=x+y+((x*y)/100); #area of rectangle decreases by(%)
#Result
print "area of rectangle decreases by",-n,"%"
```

In [11]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
i=23; #increased daily wage(%)
pi=15; #percentage increase(%)
#Calculation
o=i*100/(100+pi); #original daily wage
#Result
print "original daily wage is",o
```

In [12]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
Y=710; #marks of Y
X=515; #marks of X
px=3; #% above
#Calculation
py=(Y*(100+px)/X)-100; #Y gets % above minimum
#Result
print "Y gets",py,"% above minimum"
```

In [13]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
b=3; #boys in ratio
g=2; #girls in ratio
pb=20; #% of boys
pg=25; #% of girls
#Calculation
B=b/(b+g); #number of boys
G=g/(b+g); #number of girls
ps=(B*pb)+(G*pg); #% of scholarship holders
pns=(B*(100-pb))+(G*(100-pg)); #% of non scholarship holders
#Result
print "% of scholarship holders is",ps
print "% of non scholarship holders is",pns
```

In [15]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
Nr=27; #new rate(Rs)
Or=24; #original rate(Rs)
#Calculation
pc=(Nr-Or)*100/Or; #% change in rate
pcc=pc*100/(100+pc); #% change in consumption
#Result
print "% change in consumption is",round(pcc,2),"%"
```

In [28]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
e=16; #expenditure(Rs)
rc=2; #rate change(Rs)
qc=4; #change in quantity available(kg)
#Calculation
b=-rc; #coefficient of x
a=1; #coefficient of x**2
c=-e*rc/qc; #constant term
x=(b**2)-(4*a*c);
x1=(-b+math.sqrt(x))/(2*a);
x2=(-b-math.sqrt(x))/(2*a);
#Result
print "original price of sugar is Rs",x1,"per kg"
```

In [30]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
e=120; #expenditure(Rs)
rc=0.25; #rate change(Rs)
qc=5; #change in quantity available(kg)
#Calculation
x=e*rc/(qc*(1-rc)); #original price(Rs/kg)
#Result
print "original price is Rs",x,"per kg"
```

In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
cr=3; #change in rate(%)
#Calculation
dc=cr*100/(100+cr); #% decrease in consumption
#Result
print "% decrease in consumption is",round(dc,3),"%"
```

In [3]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=10; #deduction(%)
p2=20; #deduction(%)
p3=25; #deduction(%)
l=2700; #left with amount(Rs)
#Calculation
x=(100-p1)*(100-p2)*(100-p3)/(100*100*100);
s=l/x; #salary(Rs)
#Result
print "salary is",s,"Rs"
```

In [5]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=10; #% increase
q=30; #quantity(kg)
p2=32; #% increase
#Calculation
nc=(100+p1)*q/(100+p2); #new consumption(kg)
#Result
print "new consumption is",nc,"kg"
```

In [7]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a=1200; #amount increased(Rs)
p1=10; #% before
p2=12; #% after
#Calculation
x=a*p2/(p2-p1); #income after increase(Rs)
#Result
print "income after increase is Rs",x
```

In [14]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=3/4;
b1=48;
c1=62;
p1=35/100;
p2=45/100;
a2=5/6;
P2=20/100;
b2=4.375;
a3=625;
b3=1200;
c3=320;
p3=80/100;
a4=3/5;
b4=1450;
p4=200/100;
c4=450;
a5=5+(1/2);
b5=240;
p5=150/100;
a6=5/7;
b6=49;
c6=130;
p6=20/100;
a7=2*1000;
b7=800;
a8=534;
b8=105;
p8=(33+(1/3))/100;
P8=40/100;
p9=(26+(2/3))/100;
a9=40;
p10=(10+(1/2))/100;
a10=400;
a11=108;
b11=81;
a12=60;
b12=72;
p12=(12+(1/2))/100;
p13=0.025/100;
a13=1500;
p14=25/100;
P14=50/100;
a15=150;
a16=73;
p17=11/100;
a17=33;
a18=350;
b18=21;
a19=5/100;
a20=7/100;
#Calculation
v1=((a1*b1)+c1)/p1; #value in 1st case
v2=(P2*b2)-(p2*a2); #value in 2nd case
v3=((p3*b3)-c3-a3)**2; #value in 3rd case
v4=(p4*c4)-(a4*b4); #value in 4th case
v5=a5*b5/p5; #value in 5th case
v6=(a6*b6)+(p6*c6)-b6; #value in 6th case
v7=b7/a7; #value in 7th case
v8=(p8*a8)+(P8*b8); #value in 8th case
v9=a9/p9; #value in 9th case
v10=p10*a10; #value in 10th case
v11=b11/a11; #value in 11th case
v12=b12*p12/a12; #value in 12th case
v13=p13*a13; #value in 13th case
v14=p14*P14; #value in 14th case
v15=a15*100/1000; #value in 15th case
v16=a16*100/365; #value in 16th case
v17=a17/p17; #value in 17th case
v18=b18*100/a18; #value in 18th case
v19=1+a19; #value in 19th case
v20=1-a20; #value in 20th case
#Result
print "value in 1st case is",v1
print "value in 2nd case is",v2
print "value in 3rd case is",v3
print "value in 4th case is",v4
print "value in 5th case is",v5
print "value in 6th case is",v6
print "value in 7th case is",v7,"%"
print "value in 8th case is",v8
print "value in 9th case is",v9
print "value in 10th case is",v10
print "value in 11th case is",v11,"%"
print "value in 12th case is",v12
print "value in 13th case is",v13
print "value in 14th case is",v14
print "value in 15th case is",v15
print "value in 16th case is",v16
print "value in 17th case is",v17
print "value in 18th case is",v18
print "answer given in the book is wrong"
print "value in 19th case is",v19,"x"
print "value in 20th case is",v20,"x"
```

In [8]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
si=10; #income(%)
Si=25; #salary increase(%)
#Calculation
SI=Si; #saving increase(%)
#Result
print "saving increases by",SI,"%"
```

In [11]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n=20; #number of books
a1=25/100; #amount less(Rs)
a2=70/100; #amount left(Rs)
#Calculation
X=((n+2)*a1)-a2;
x=n*X/(n+2-n); #amount boy had(Rs)
#Result
print "amount boy had is Rs",x
```

In [1]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=80; #percentage(%)
n=4; #reduced number
#Calculation
N=n*100/(100-p); #value of N
#Result
print "value of N is",N
```

In [2]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=102; #percentage(%)
n=6; #reduced number
#Calculation
N=n*100/(p-100); #value of N
#Result
print "value of N is",N
```

In [4]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=200;
p1=60;
a2=11;
p2=100;
a3=35;
p3=200;
a4=48;
p4=12+(1/2);
a5=1000;
p5=3.5;
#Calculation
N1=a1*(100+p1)/100; #new value for 1st case
N2=a2*(100+p2)/100; #new value for 2nd case
N3=a3*(100+p3)/100; #new value for 3rd case
N4=a4*(100+p4)/100; #new value for 4th case
N5=a5*(100+p5)/100; #new value for 5th case
#Result
print "new value for 1st case is",N1
print "new value for 2nd case is",N2
print "new value for 3rd case is",N3
print "new value for 4th case is",N4
print "new value for 5th case is",N5
```

In [5]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
a1=200;
p1=40;
a2=16;
p2=25;
a3=216;
p3=37+(1/2);
a4=300;
p4=2.5;
a5=1000;
p5=1/5;
a6=50;
p6=12+(1/2);
#Calculation
N1=a1*(100-p1)/100; #new value for 1st case
N2=a2*(100-p2)/100; #new value for 2nd case
N3=a3*(100-p3)/100; #new value for 3rd case
N4=a4*(100-p4)/100; #new value for 4th case
N5=a5*(100-p5)/100; #new value for 5th case
N6=a6*(100-p6)/100; #new value for 6th case
#Result
print "new value for 1st case is",N1
print "new value for 2nd case is",N2
print "new value for 3rd case is",N3
print "new value for 4th case is",N4
print "new value for 5th case is",N5
print "new value for 6th case is",N6
```

In [7]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=10; #percent(%)
b=45; #decreased bill(Rs)
#Calculation
N=b*100/(100-p); #amount of bill(Rs)
#Result
print "amount of bill is Rs",N
```

In [8]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=30; #percent(%)
n=9100; #number of milk chocolates
#Calculation
N=n*100/(100+p); #number of milk chocolates
#Result
print "number of milk chocolates/month is",N
```

In [9]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
fw=40.8; #false weight(kg)
aw=40; #actual weight(kg)
#Calculation
e=(fw-aw)*100/aw; #error(%)
#Result
print "error is",e,"%"
```

In [10]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
d=10; #difference(Rs)
dp=25; #difference in percent(%)
#Calculation
op=d*100/dp; #original price(Rs)
np=op*(100+dp)/100; #new price per kg(Rs)
#Result
print "new price per kg is Rs",np
```

In [14]:

```
#importing modules
import math
from __future__ import division
from fractions import Fraction
#Variable declaration
cp=25; #change in price(Rs)
op=100; #old price(Rs)
#Calculation
r1=cp/op; #ratio of change in price to old price
r2=op/(op-cp); #ratio of old price to new price
f=(100-cp)/100; #factor
#Result
print "ratio of change in price to old price is",Fraction(r1)
print "ratio of old price to new price is",round(r2,2)
print "factor is",Fraction(f)
```

In [18]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=10; #percent(%)
#Calculation
x2=(100+p)/100;
x1=100/(100+p);
#Result
print "B=A*",round(x1,2)
print "A=B*",int(x2*10),"/10"
print "A/B = ",int(x2*10),"/10"
```

In [25]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=20; #percent(%)
#Calculation
x1=(100-p)/100;
x2=p/100;
x3=(100-p)/p;
#Result
print "X/Y = ",x1
print "Y-X/Y = ",x2
print "X/Y-X = ",int(x3)
```

In [26]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p1=2+(1/2); #percent(%)
w=0.2; #weight(kg)
p2=120; #percent(%)
#Calculation
w=w*p2/p1; #weight of table(kg)
#Result
print "weight of table is",w,"kg"
```

In [27]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
p=1/8; #percent(%)
a=43.50; #amount(Rs)
#Calculation
S=a*5/p; #five times the sum of money(Rs)
#Result
print "five times the sum of money is Rs",S
```

In [29]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
q=1;
p=6*q; #number of times
#Calculation
x=(p-q)*100/p; #q is less than p by(%)
#Result
print "q is less than p by",round(x,2),"%"
```

In [30]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n=0.05; #number
p=20/100;
#Calculation
rp=n/p; #required percent(%)
#Result
print "required percent is",rp,"%"
```

In [32]:

```
#importing modules
import math
from __future__ import division
#Variable declaration
n1=5;
n2=2250;
#Calculation
ps=n1*100/n2; #percent of sulphur in earth(%)
#Result
print "percent of sulphur in earth is",round(ps,3),"%"
```