import math
#Initialization of variables
Q = 0.5 #cfs
d1 = 8. #in
d2 = 4. #in
R = 2. #in
h = 0.59 #in
#calculations
Aa = math.pi*(d1/12)**2 /4
Va = Q/Aa
Ab = 2*math.pi*R*h/144
Vb = Q/Ab
#Results
print "Average velocity at section A = %.2f fps "%(Va)
print " Average velocity at section B = %.2f fps "%(Vb)
# rounding off error
import math
#Initialization of variables
Q = 0.5 #cfs
d1 = 8. #in
d2 = 4. #in
R = 2. #in
theta = 45. #degrees
#calculations
h = (1-math.cos(math.radians(theta))) #Multiply by r
Aa = round(2*math.pi*h,2) #Multiply by r**2
V = Q/Aa #divide by r**2
aA = 0
r = 0.167 #ft
V1 = V/r**2
dvbydx = round(V*2/r**3)
aB = V1*dvbydx
#Results
#The answer varies a bit from the text due to rounding off error
print "Acceleration at A = %d since flow is steady"%(aA)
print "Acceleration at B = %d ft/s**2"%(aB)
# rounding off error. please check.