#importing modules
import math
from __future__ import division
#Variable declaration
m=40; #number of students in A
a=10; #average age in A
b=12; #average age in B
n=30; #number of students in B
#Calculation
average=((m*a)+(n*b))/(m+n); #average age of students in both sections
#Result
print "average age of students in both sections is",round(average,2),"years"
#importing modules
import math
from __future__ import division
#Variable declaration
m=5; #number of quantities
n=3; #number of quantities
a=6; #average of 5 quantities
b=4; #average of 3 quantities
#Calculation
average=((m*a)-(n*b))/(m-n); #average of 2 numbers
#Result
print "average of 2 numbers is",average
#importing modules
import math
from __future__ import division
#Variable declaration
m=30; #number of pens
n=75; #number of pencils
p=2; #average price of pencil
S=510; #cost of pens and pencils
#Calculation
y=(S-(n*p))/m; #average price of pen(Rs)
#Result
print "average price of pen is",y,"Rs"
#importing modules
import math
from __future__ import division
#Variable declaration
aplusb=2*20; #average age of A and B
bplusc=2*19; #average age of B and C
cplusa=2*21; #average age of C and A
#Calculation
aplusbplusc=(aplusb+bplusc+cplusa)/2;
a=aplusbplusc-bplusc; #age of A(years)
b=aplusbplusc-cplusa; #age of B(years)
c=aplusbplusc-aplusb; #age of C(years)
#Result
print "age of A is",a,"years"
print "age of B is",b,"years"
print "age of C is",c,"years"
#importing modules
import math
from __future__ import division
#Variable declaration
e1=2200; #average monthly expenditure for 3 months(Rs)
n1=3; #number of months in 1st case
e2=2550; #average monthly expenditure for 4 months(Rs)
n2=4; #number of months in 2nd case
e3=3120; #average monthly expenditure for 5 months(Rs)
n3=5; #number of months in 3rd case
s=1260; #total saving(Rs)
#Calculation
I=(e1*n1)+(e2*n2)+(e3*n3)+s; #total yearly income(Rs)
average=I/12; #average monthly income(Rs)
#Result
print "average monthly income is",average,"Rs"
#importing modules
import math
from __future__ import division
#Variable declaration
TWT=37; #average temperature on tuesday, wednesday, thursday(C)
FWT=38; #average temperature on wednesday, thursday, friday(C)
R=39; #temperature on friday(C)
n=3; #number of quantities
#Calculation
T=R-((FWT-TWT)*n); #temperature of tuesday(C)
#Result
print "temperature of tuesday is",T,"C"
#importing modules
import math
from __future__ import division
#Variable declaration
n=3; #number of quantities
J=29; #temperature of june(C)
JJA=31; #average temperature of june, july august(C)
JAS=30; #average temperature of july, august, september(C)
#Calculation
S=J+((JAS-JJA)*n); #temperature of september(C)
#Result
print "temperature of september is",S,"C"
#importing modules
import math
from __future__ import division
#Variable declaration
n1=29; #number of students in class
n2=30; #number when teacher is included
w1=48; #average weight of 29 students(kg)
w=0.5; #change in average weight of 30 members(kg)
#Calculation
wt=((n2-n1)*w1)+(w*n2); #weight of teacher(kg)
#Result
print "weight of teacher is",wt,"kg"
#importing modules
import math
from __future__ import division
#Variable declaration
n1=50; #number of boys in class
w1=45; #original average(kg)
n2=49; #number of boys when one leaves the class
dw=0.1; #reduction in average weight(kg)
#Calculation
a=(n1-n2)*w1;
b=-dw*n2;
w=a-b; #weight of boy who left the class(kg)
#Result
print "weight of boy who left the class is",w,"kg"
#importing modules
import math
from __future__ import division
#Variable declaration
n1=40; #number of students
na=10; #number of students newly admitted
a1=15; #original average(years)
a=0.2; #change in average(year)
#Calculation
sa=(na*a1)+(a*(n1+na)); #sum of weight(kg)
avga=sa/na; #average age of 10 new students(years)
#Result
print "average age of 10 new students is",avga,"years"
#importing modules
import math
from __future__ import division
#Variable declaration
n1=30; #number of students
n=20; #number of students newly admitted
a1=60; #original average(kg)
a=-2; #change in average weight(kg)
#Calculation
s=(n*a1)+(a*(n1+n)); #sum of weight(kg)
aw=s/n; #average weight of 20 students(kg)
#Result
print "average weight of 20 students is",aw,"kg"
#importing modules
import math
from __future__ import division
#Variable declaration
n1=6; #number of results
a1=49; #average of 1st six results
a2=52; #average of last six results
n2=11;
a3=50; #average of 11 results
#Calculation
v6=(n1*a1)+(n1*a2)-(n2*a3); #value of 6th result
#Result
print "value of 6th result is",v6
#importing modules
import math
from __future__ import division
#Variable declaration
n1=20; #number of innings
n2=21; #number of innings in 2nd case
r2=107; #number of runs
a2=2; #change in average(runs)
#Calculation
a1=a2*n2;
A=(r2-a1)/(n2-n1);
A=A+2; #average after 21 innings(runs)
#Result
print "average after 21 innings is",A,"runs"
#importing modules
import math
from __future__ import division
#Variable declaration
Sa=6; #number of runs in last 2 innings(runs)
na=2; #number of innings
deltaA=-2; #drop in average runs
A1=750; #number of runs
#Calculation
#from the equation 6=(2*750/N)-(2*N+4) we get a quadratic equation in N
a=-deltaA; #coefficient of N**2
b=Sa-(na*deltaA); #coefficient of N
c=-na*A1; #constant term
N=((-b)+math.sqrt((b**2)-(4*a*c)))/(2*a); #number of innings
A=A1/N; #original average
FA=A-na; #final average(runs)
#Result
print "final average is",FA,"runs"
#importing modules
import math
from __future__ import division
#Variable declaration
sa=52; #number of runs
na=3; #number of wickets
A1=200; #average of bowler
deltaA=1; #change in average
#Calculation
#from the equation 52=(3*200/N)+(+1)*(N+3) we get a quadratic equation in N
a=deltaA; #coefficient of N**2
b=na-sa; #coefficient of N
c=na*A1; #constant term
N1=((-b)+math.sqrt((b**2)-(4*a*c)))/(2*a); #number of innings
N2=((-b)-math.sqrt((b**2)-(4*a*c)))/(2*a); #number of innings
NA1=(A1+sa)/(N1+na); #new average
NA2=(A1+sa)/(N2+na); #new average
x=NA2-int(NA2);
#Result
print "new average of bowler is",NA1,"or",NA2
#importing modules
import math
from __future__ import division
#Variable declaration
n=15; #number of students
da=1.5; #change in average
wr=40; #weight of removed student(kg)
#Calculation
wn=wr+(n*da); #weight of new student(kg)
#Result
print "weight of new student is",wn,"kg"
#importing modules
import math
from __future__ import division
#Variable declaration
n=11; #number of players
ac=25; #age of captain(years)
awk=28; #age of wicket keeper(years)
da=-2; #change in average(years)
#Calculation
S=(ac+awk)+(n*da); #sum of age of replacing players(years)
A=S/2; #average age of 2 players(years)
#Result
print "average age of 2 players is",A,"years"