Put the lesson Function Arguments into practice by writing a program yourself.
A bar under a tensile force stretches by ΔL = F × L / (A × E), where F is the force (N), L the length (m), A the cross-sectional area (m²) and E the Young's modulus (Pa).
Most bars in your lab are steel (E = 200 × 10⁹ Pa) with an area of 1 × 10⁻⁴ m², so these make good default values.
bar_extension(force_n, length_m, area_m2=1e-4, modulus_pa=200e9) that returns the extension in millimetres.Steel: 1.000 mm Aluminium: 2.857 mm Aluminium, double area: 1.429 mm
Write your program below and press Run. Each run is checked against the expected output.
Press Run to see what your program prints.
One possible solution. Other programs that print the same output are correct too.
def bar_extension(force_n, length_m, area_m2=1e-4, modulus_pa=200e9): """Elastic extension in mm of a bar under tension.""" return force_n * length_m / (area_m2 * modulus_pa) * 1000print(f"Steel: {bar_extension(10000, 2.0):.3f} mm")print(f"Aluminium: {bar_extension(10000, 2.0, modulus_pa=70e9):.3f} mm")print(f"Aluminium, double area: {bar_extension(10000, 2.0, area_m2=2e-4, modulus_pa=70e9):.3f} mm")