Professional Documents
Culture Documents
Laboratory 4
Functions
DIRECTIONS:
Create a python program that calculates the water flow in a rectangular, concrete, open
channel, you can use Manning's equation, which relates the flow rate to the channel geometry, slope,
and Manning's roughness coefficient. The program must prompt the user to input the channel width,
channel depth, and Manning's roughness coefficient then and calculates the flow rate.
• Defines rectangular_channel_flow () function that implements Manning's equation for rec-
tangular channels.
• Defines main () function takes user input for channel width, depth, slope, and Manning's
roughness coefficient, calculates the flow rate using the defined rectangular_channel_flow ()
function, and then prints the result.
cross_sectional_area=width×depth
wetted_perimeter=2×width+depth
Manning's Equation:
Manning’s Equation
where:
Q is the flow rate,
n is Manning's roughness coefficient,
A is the cross-sectional area of the channel,
R is the hydraulic radius, and
S is the slope of the channel.
www.batstate-u.edu.ph coe.alangilan@g.batstate-u.edu.ph
Alangilan Campus
EXAMPLE OUTPUT
def main():
width = float(input("Enter the width (m): "))
depth = float(input("Enter the depth (m): "))
slope = float(input("Enter the slope: "))
coefficient = float(input("Enter the Manning's coefficient: "))
cross_sectional_area = width * depth
wetted_perimeter = 2 * width + depth
hydraulic_radius = cross_sectional_area / wetted_perimeter
flow_rate = 1/coefficient * cross_sectional_area * (hydraulic_radius**(2/3))
* (slope**(1/2))
print("The water flow rate in the channel is approximately ", flow_rate,
"cubic meters per second.")
again = input("Determine the flow rate again? Yes or No : ")
if again == "Yes":
return main()
def rectangular_channel_flow(flow_rate):
return flow_rate
main()
www.batstate-u.edu.ph coe.alangilan@g.batstate-u.edu.ph