Put the lesson Return Values into practice by writing a program yourself.
In a tensile test, a force of 5000 N on a sample with a cross-section of 50 mm² stretched its 50 mm gauge length by 0.05 mm.
Stress is force divided by area (N/mm² is the same as MPa), and strain is extension divided by original length. Young's modulus is stress divided by strain.
stress_and_strain(force_n, area_mm2, extension_mm, length_mm) that returns two values: the stress in MPa and the strain.Stress: 100.0 MPa Strain: 0.0010 Young's modulus: 100.0 GPa
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 stress_and_strain(force_n, area_mm2, extension_mm, length_mm): """Return the engineering stress (MPa) and strain of a tensile sample.""" stress = force_n / area_mm2 strain = extension_mm / length_mm return stress, strainstress, strain = stress_and_strain(5000, 50, 0.05, 50)print(f"Stress: {stress:.1f} MPa")print(f"Strain: {strain:.4f}")print(f"Young's modulus: {stress / strain / 1000:.1f} GPa")