Search for question
Question

9.5. The following function is a simple funciton that calculates the molar mass of a compound. While it is a very concise implementation, it is hard to read and understand. The code is attached below. Rewrite the code so that it is easier to read. This involves renaming variables, adding a doc string, adding code comments, and adjusting the spacing. In your docstring, talk about some of the limitations of this function and/or how the code can be improved. def calc_mm(n_H, n_C, n_N): * g = n_C 12.011 z = n_H * 1.007 u = n_N✶ 14.006 gggz + u if σσ == 0·/n9.4. Fluid in the laminar flow regime with fully developed flow loses pressure according the the Hagen-Poiseuille equation. Ap= 8μLQ πR² where Ap is the pressure drop, L is the length of the pipe, is the dynamic viscosity, Q is the volumetric flow rate, and R is the pipe radius. For this problem, the diameter, pipe length, viscosity, and pipe radius are constant at values of 1000 P = kg m3f= m.s' = 0.001 kg, L 10m, R 0.2m. Make a function to calculate the pressure drop (in Pa) given a volumetric flow rate. Make a for loop to provide the following values (in m3/s) to the function and print the returned values. [5e-4, 4e-4, 3e-4, 2e-4, 1e-4, 5e-5] 9.5. The following function is a simple funciton that calculates the molar mass of a compound. While it is a very concise implementation, it is hard to read and Python/nThe Reynolds number, Re, is an important parameter in fluid mechanics. It determines whether the flow of a liquid is laminar, transitional, or turbulent. For a smooth pipe, Re can be defined as Re = Dpv μ Where D is the diameter of the pipe, p is the density of the fluid, v is the velocity of the fluid, and μ is the dynamic viscosity of the fluid. The relationship between Re and the flow type can be seen below. Reynolds Range Re<2100 2100< Re<=4000 Re>=4000 Flow Regime laminar transitional turbulent The output should be a string saying "laminar", "transitional", or "turbulent". The fluid density ad dynamic viscosity should be default parameters equal to that of water (p 1000 0.001). Blank inputs must be left to handled by the default; arguments may be provided with keywords. m.s Add informative errors if any of the four parameters (D, v, p, μ) provided is either zero or negative. Diameter (m) Velocity (m/s) Density (kg/m3) Density (kg/m3) Viscosity (kg/ms) Viscosity (kg/ms) Returned Value/nWrite a function that converts a diameter in meters to feet, kilometers, or millimeters. The inputs to the function should be diameter (m) and one parameter to specify the units of the returned diameter. If an unsupported unit type is provided, an informative error should be raised. For any entries in the table where an error is raised, write the print lines that would generate the error into your code but then comment it out so that the page still runs. Output Units Returned Diameter Input Diameter (m) Output Units 500 5 0.0001 0.1 kilometers micrometers millimeters feet Python/nDocumentation will be worth half the points on this assignment. 9.1. The volumetric flow rate in a round pipe is Qpipe R² and the volumetric flow rate in a square duct is Q square height, and shape as input parameters and outputs the volume. = 4R2v. Write a function that takes radius, Use it to fill this calculation table. Radius (m) Velocity (m/s) Shape 0.5 2 square 0.5 2 pipe 5 0.1 pipe 0.1 5 square Volumetric flow rate (m3/s)

Fig: 1

Fig: 2

Fig: 3

Fig: 4

Fig: 5