# 5: Percentage¶

## Example number 5.1, Page number 5.5¶

In :
#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,"%"

0.4 in terms of percentage is 40.0 %
1.0 in terms of percentage is 100.0 %
5/3 in terms of percentage is 166.67 %
7x/y in terms of percentage is 700 x/y %
1.23 in terms of percentage is 123.0 %


## Example number 5.2, Page number 5.5¶

In :
#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)

22 1/2 in terms of fraction is 0.225
35 in terms of fraction is 0.35
a**2/b in terms of fraction is a**2/100b
0.3 in terms of fraction is 0.003
2/7 in terms of fraction is 0.0029


## Example number 5.3, Page number 5.5¶

In :
#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

value in 1st case is 2.43
value in 2nd case is 1.3
value in 3rd case is 2.8
value in 4th case is 80.0
value in 5th case is 1.6


## Example number 5.4, Page number 5.6¶

In :
#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 %"

value in 1st case is 25.0 %
value in 2nd case is 116.67 %
value in 3rd case is 20.0 %
value in 4th case is 50.0 %
value in 5th case is 36.0 %
value in 6th case is 100R/N %


## Example number 5.5, Page number 5.7¶

In :
#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)

value in 1st case is 600.0
value in 2nd case is 50.0
value in 3rd case is 240.0
value in 4th case is 4.08


## Example number 5.6, Page number 5.7¶

In :
#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

40% of number is 32.0
original number is 80.0


## Example number 5.8, Page number 5.8¶

In :
#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

B is short of A by 20.0


## Example number 5.9, Page number 5.8¶

In :
#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)

Y is excess of X by 66.67


## Example number 5.10, Page number 5.8¶

In :
#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,"%"

salary of july more than that of june is 11.11 %
salary of june less than that of july is 10.0 %


## Example number 5.11, Page number 5.8¶

In :
#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

enrollment in 1988 is 1650.0


## Example number 5.13, Page number 5.9¶

In :
#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,"%"

area of rectangle decreases by 22.0 %


## Example number 5.14, Page number 5.9¶

In :
#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

original daily wage is 20.0


## Example number 5.16, Page number 5.10¶

In :
#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"

Y gets 42.0 % above minimum


## Example number 5.18, Page number 5.10¶

In :
#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

% of scholarship holders is 22.0
% of non scholarship holders is 78.0


## Example number 5.19, Page number 5.10¶

In :
#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),"%"

% change in consumption is 11.11 %


## Example number 5.20, Page number 5.11¶

In :
#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"

original price of sugar is Rs 4.0 per kg


## Example number 5.21, Page number 5.11¶

In :
#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"

original price is Rs 8.0 per kg


## Example number 5.22, Page number 5.11¶

In :
#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),"%"

% decrease in consumption is 2.913 %


## Example number 5.24, Page number 5.12¶

In :
#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"

salary is 5000.0 Rs


## Example number 5.25, Page number 5.12¶

In :
#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"

new consumption is 25.0 kg


## Example number 5.26, Page number 5.12¶

In :
#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

income after increase is Rs 7200.0


## Example number 5.27, Page number 5.12¶

In :
#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"

value in 1st case is 280.0
value in 2nd case is 0.5
value in 3rd case is 225.0
value in 4th case is 30.0
value in 5th case is 880.0
value in 6th case is 12.0
value in 7th case is 0.4 %
value in 8th case is 220.0
value in 9th case is 150.0
value in 10th case is 42.0
value in 11th case is 0.75 %
value in 12th case is 0.15
value in 13th case is 0.375
value in 14th case is 0.125
value in 15th case is 15.0
value in 16th case is 20.0
value in 17th case is 300.0
value in 18th case is 6.0
answer given in the book is wrong
value in 19th case is 1.05 x
value in 20th case is 0.93 x


## Example number 5.28, Page number 5.15¶

In :
#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,"%"

saving increases by 25 %


## Example number 5.29, Page number 5.15¶

In :
#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;

#Result
print "amount boy had is Rs",x

amount boy had is Rs 48.0


## Example number 5.30, Page number 5.15¶

In :
#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

value of N is 20.0


## Example number 5.31, Page number 5.15¶

In :
#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

value of N is 300.0


## Example number 5.32, Page number 5.15¶

In :
#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

new value for 1st case is 320.0
new value for 2nd case is 22.0
new value for 3rd case is 105.0
new value for 4th case is 54.0
new value for 5th case is 1035.0


## Example number 5.33, Page number 5.16¶

In :
#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

new value for 1st case is 120.0
new value for 2nd case is 12.0
new value for 3rd case is 135.0
new value for 4th case is 292.5
new value for 5th case is 998.0
new value for 6th case is 43.75


## Example number 5.34, Page number 5.17¶

In :
#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

amount of bill is Rs 50.0


## Example number 5.35, Page number 5.17¶

In :
#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

number of milk chocolates/month is 7000.0


## Example number 5.36, Page number 5.18¶

In :
#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,"%"

error is 2.0 %


## Example number 5.37, Page number 5.18¶

In :
#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

new price per kg is Rs 50.0


## Example number 5.38, Page number 5.18¶

In :
#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)

ratio of change in price to old price is 1/4
ratio of old price to new price is 1.33
factor is 3/4


## Example number 5.39, Page number 5.18¶

In :
#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"

B=A* 0.91
A=B* 11 /10
A/B =  11 /10


## Example number 5.40, Page number 5.19¶

In :
#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)

X/Y =  0.8
Y-X/Y =  0.2
X/Y-X =  4


## Example number 5.41, Page number 5.19¶

In :
#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"

weight of table is 9.6 kg


## Example number 5.42, Page number 5.20¶

In :
#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

five times the sum of money is Rs 1740.0


## Example number 5.43, Page number 5.20¶

In :
#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),"%"

q is less than p by 83.33 %


## Example number 5.44, Page number 5.20¶

In :
#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,"%"

required percent is 0.25 %


## Example number 5.45, Page number 5.20¶

In :
#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),"%"

percent of sulphur in earth is 0.222 %