from __future__ import division
import math
#Initializing the variables
B =4;
D = 1.2;
C = 7.6;
n = 0.025;
s = 1/1800;
#Calculations
W = B + 2*1.5*D;
A = D*(B+C)/2; # Area of parallelogram formed
P = B +2*1.2*(D**2+(1.5)**2)**0.5;
m =A/P;
i=s;
C = (23+0.00155/i+1/n)/(1+(23+0.00155/i)*n/(m)**0.5); # By Kutter formula
Q1 = C*A*(m*i)**0.5;
Q2 = A*(1/n)*m**(2/3)*(i)**0.5;
print "Q using Chezy formula with C determined from the Kutter formula (m^3/s) :",round(Q1,2)
print "Q using the Manning formula (m^3/s) :",round(Q2,2)
from __future__ import division
import math
#Initializing the variables
Q = 0.5;
C = 80;
i = 1/2000;
#Calculations
# A = D**2+(3/4)*D**2 = (7/4)*D**2
D = ((4/7)*(Q/C)*(2/i)**0.5)**(2/5)
#Result
print "Optimum depth = Optimum Width (in metres):",round(D,3)