#variable declaration
fi=10.0*10**-6 # fi-flux
inch=2.54*10**-2 # length
A=inch**2 # area
#calculation
B =fi/A
#Result
print('Flux Density B= %.1f mT'%(B*1000))
#variable Declaration
i=10*10**-3 # current in A
R=1000.0 # resistance in ohm
P=(i**2)*R # Power
err_R=10.0 # Error in Resistance measurement
err_I=(2.0/100)*25*100/10 # Error in current measurement
#calculation
err_I2=2*err_I
err_p=err_I2+err_R
#Result
print('%% error in I^2 = ± %d%%\n%% error in Power = ± %d%%'%(err_I2,err_p))
#variable Declaration
i1=37.0 # current in branch 1
i2=42.0 # current in branch 2
i3=13.0 # current in branch 3
i4=6.7 # current in branch 4
#Calculation
Imax=(i1+i2)+(i1+i2)*(3.0/100)+(i3+i4)+(i3+i4)*(1.0/100)
Imin=(i1+i2)-(i1+i2)*(3.0/100)+(i3+i4)-(i3+i4)*(1.0/100)
#result
print('Maximum level of total supply current = %.3f mA'%Imax)
print('\nMinimum level of total supply current = %.3f mA'%Imin)
import math
#(a)
#variable declaration
T=200.0 # intermediate temperature
T0=300.0 # final temperature
Ti=70.0 # initial temperature
t=3.0 # time in seconds
#calculation
x=(T-T0)/(Ti-T0)
tow=-t/math.log(x)
#result
print('(a)\nTime constant tow=%.1f s'%tow)
#(b)
#variable declaration
t1=5.0 # time in seconds
#calculation
T5=T0+((Ti-T0)*math.e**(-t1/tow))
#result
print('\n(b)\nTemperature after 5 seconds T5 = %.2f°C'%T5)
import math
#variable declaration
w=9.0 # excitation frequency
wn=6.0 # natural frequency
dr=0.6 # damping ratio
#calculations
x=w/wn
Ar=1/math.sqrt(((1-(x)**2)**2)+(2*dr*x)**2)
err=(1-Ar)*100
#Result
print('A=%.3f'%Ar)
print('\nError = %.2f%%'%err)
#variable Declaration
t=2.0 # output to be calculated after t seconds
#calculation
y=1-math.e**(-(t-1.5)/0.5)
#result
print('y(t)at t=2 will be y(t)=%.3f'%y)
import math
#variable declaration
#Temperature Readings
x1=98.5 # Reading 1
x2=99.0 # Reading 2
x3=99.5 # Reading 3
x4=100.0 # Reading 4
x5=100.5 # Reading 5
x6=101.0 # Reading 6
x7=101.5 # Reading 7
# Frequency
f1=4.0 # Reading 1
f2=13.0 # Reading 2
f3=19.0 # Reading 3
f4=35.0 # Reading 4
f5=17.0 # Reading 5
f6=10.0 # Reading 6
f7=2.0 # Reading 7
#(i) Arithmatic Mean
#calculation
x_bar=((x1*f1)+(x2*f2)+(x3*f3)+(x4*f4)+(x5*f5)+(x6*f6)+(x7*f7))/(f1+f2+f3+f4+f5+f6+f7)
#result
print('(i)\n\tArithmatic Mean = %.2f°C'%x_bar)
#(ii) Average Deviation
#calculation
D=(abs(x1-x_bar)*f1)+(abs(x2-x_bar)*f2)+(abs(x3-x_bar)*f3)+(abs(x4-x_bar)*f4)
D=D+(abs(x5-x_bar)*f5)+(abs(x6-x_bar)*f6)+(abs(x7-x_bar)*f7)
D=D/(f1+f2+f3+f4+f5+f6+f7)
#result
print('\n(ii)\n\tAverage Deviation =%.4f°C'%D)
#Standard deviation
#Calculation
sigma=((x1-x_bar)**2*f1)+((x2-x_bar)**2*f2)+((x3-x_bar)**2*f3)+((x4-x_bar)**2*f4)
sigma=sigma+((x5-x_bar)**2*f5)+((x6-x_bar)**2*f6)+((x7-x_bar)**2*f7)
sigma=math.sqrt(sigma)
sigma=sigma/math.sqrt(f1+f2+f3+f4+f5+f6+f7)
#result
print('\n(iii)\n\tStandard deviation = %.3f°C'%sigma)
#variance
#result
print('\n(iv)\n\tVariance = %.4f°C'%(sigma**2))
#Probable Error
#result
print('\n(v)\n\tProbable Error= %.4f°C'%(0.6745*sigma))
import math
#variable Declaration
wn=math.sqrt(3.0) # natural frequency of osscilation
#Calculation
x=3.2/(2*wn)
#Result
print('Damping coefficient = %.3f\nNatural frequency of Oscillation = %.3f'%(x,wn))
import math
#variable declaration
w=100.0 # natural frequency of osscilation
#calculation
fi=-math.atan(0.1*w)-math.atan(0.5*w)
A=1/(math.sqrt(1+(0.1*w)**2)*(math.sqrt(1+(0.5*w)**2)))
A=1*1000.0/math.ceil(1000*A)
err=(1-1.0/A)*100
#Result
print('A=K/%d\n%% error = %.1f%%\nfi = %.2f°'%(A,err,fi*180/math.pi))
#calculations
R=0.15*10/50 # Temperature gradient
K=1.0 # constant
tow=15.0 # time constant
#Calculations
deg=K*R*tow
#(i)
a=15-deg
#(ii)
alt_red=deg*50.0/0.15
h=5000-alt_red
#result
print('(i)The actual temperature when instrument reads 15°C is %.2f°C'%a)
print('\n The true temperature at 5000 metres = %.2f '%a)
print('\n(ii)\nThe true altitude at which 15°C occurs is %d metres'%h)