MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / shear_stress

Function shear_stress

physics/shear_stress.py:12–53  ·  view source on GitHub ↗

This function can calculate any one of the three - 1. Shear Stress 2. Tangential Force 3. Cross-sectional Area This is calculated from the other two provided values Examples - >>> shear_stress(stress=25, tangential_force=100, area=0) ('area', 4.0) >>> shear_stres

(
    stress: float,
    tangential_force: float,
    area: float,
)

Source from the content-addressed store, hash-verified

10
11
12def shear_stress(
13 stress: float,
14 tangential_force: float,
15 area: float,
16) -> tuple[str, float]:
17 """
18 This function can calculate any one of the three -
19 1. Shear Stress
20 2. Tangential Force
21 3. Cross-sectional Area
22 This is calculated from the other two provided values
23 Examples -
24 >>> shear_stress(stress=25, tangential_force=100, area=0)
25 ('area', 4.0)
26 >>> shear_stress(stress=0, tangential_force=1600, area=200)
27 ('stress', 8.0)
28 >>> shear_stress(stress=1000, tangential_force=0, area=1200)
29 ('tangential_force', 1200000)
30 """
31 if (stress, tangential_force, area).count(0) != 1:
32 raise ValueError("You cannot supply more or less than 2 values")
33 elif stress < 0:
34 raise ValueError("Stress cannot be negative")
35 elif tangential_force < 0:
36 raise ValueError("Tangential Force cannot be negative")
37 elif area < 0:
38 raise ValueError("Area cannot be negative")
39 elif stress == 0:
40 return (
41 "stress",
42 tangential_force / area,
43 )
44 elif tangential_force == 0:
45 return (
46 "tangential_force",
47 stress * area,
48 )
49 else:
50 return (
51 "area",
52 tangential_force / stress,
53 )
54
55
56if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

countMethod · 0.80

Tested by

no test coverage detected