from sympy import *
# variables
yo = Symbol("yo")
A = 20*yo
P = 20 + 2*yo
Rh= 20*yo/(20+2*yo)
n = 0.017 # ft
# calculations
ans = solve((1.49/n)*A*Rh**(2./3)*(0.0001)**(1./2) - 400) #*yo*Rh**(2./3)
# result
print "Yo = %.2f ft"%ans[0]
# calculations
Rh = 20*8.34/(20+2*8.34)
# result
print "Rh = %.2f ft"%Rh
from sympy import *
# variables
yo = Symbol("yo")
n = 0.017 #ft 1/6
A = 2*yo**2
Rh = yo/2
# Calculations
ans = solve((1.49/n)*A*Rh**(2./3) * (0.0001)**(1./2) - 400,yo)
Yo = ans[0]
B = 2*Yo
#result
print "Yo**(8/3) = %.f "%(Yo**(8./3))
print "Yo = %.2f ft "%(Yo)
print "B = %.2f ft "%(B)
# note : answer are slightly differenet because of solve method of sympy
import math
from sympy import Symbol, solve
# variables
q = 500./40 # cfs/ft
ye = ((12.5)**2 / 32.2)**(1./3)
n = 0.017
So = Symbol("So")
# calculations
Sc = 32.2 * n**2 / (2.2 * ye**(1./3))
ans = solve((1.49/n)*160*(3.33)**(2./3)*So**(1./2) - 500)
So = ans[0]
# result
print "Sc = %.4f"%Sc
print "So = %f"%So
print "So is a mild slope since it is less than Se"
from sympy import solve,Symbol
import math
# variables
y = Symbol("y")
A = 10*y + 2*y**2
n = 0.017
b = 10 + 4*y
P = 10 + 2*math.sqrt(5)*y
# calculations
ans = solve(A**3/b *32.2/1000**2 - 1)
yo = ans[1]
Ae = 97.3 # sqft
be = 29.65 # ft
Rhe = Ae/32 # ft
Sc = 32.2*n**2/2.2 * (Ae/(be*Rhe**(4./3)))
# result
print "Yo = %.2f ft"%yo
print "Sc = %.5f"%Sc
from sympy import Symbol,solve
# variables
Q = round((1.49/0.015)*50*(50./20)**(2./3)*(0.001)**(1./2)) # cfs
E = 5.52 # ft
# calculations and results
Ye = ((Q/10)**2/32.2)**(1./3)
Emin = 3 * Ye/2
print "Ye = %.2f ft"%Ye
print "Minimum height of hump : Emin = %.2f ft"%Emin
Ye = 2 * 5.52/3
b = Symbol("b")
ans = solve( ( (289/b)**2 / 32.2 )**(1./3) - Ye)
b = ans[1]
print "Ye = %.2f ft"%Ye
print "Maximum width of contraction : b = %.1f ft"%b