|
| 1 | +""" |
| 2 | +Description : |
| 3 | +Newton's second law of motion pertains to the behavior of objects for which |
| 4 | +all existing forces are not balanced. |
| 5 | +The second law states that the acceleration of an object is dependent upon two variables |
| 6 | +- the net force acting upon the object and the mass of the object. |
| 7 | +The acceleration of an object depends directly |
| 8 | +upon the net force acting upon the object, |
| 9 | +and inversely upon the mass of the object. |
| 10 | +As the force acting upon an object is increased, |
| 11 | +the acceleration of the object is increased. |
| 12 | +As the mass of an object is increased, the acceleration of the object is decreased. |
| 13 | +Source: https://www.physicsclassroom.com/class/newtlaws/Lesson-3/Newton-s-Second-Law |
| 14 | +Formulation: Fnet = m • a |
| 15 | +Diagrammatic Explanation: |
| 16 | + Forces are unbalanced |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + V |
| 21 | + There is acceleration |
| 22 | + /\ |
| 23 | + / \ |
| 24 | + / \ |
| 25 | + / \ |
| 26 | + / \ |
| 27 | + / \ |
| 28 | + / \ |
| 29 | + __________________ ____ ________________ |
| 30 | + |The acceleration | |The acceleration | |
| 31 | + |depends directly | |depends inversely | |
| 32 | + |on the net Force | |upon the object's | |
| 33 | + |_________________| |mass_______________| |
| 34 | +Units: |
| 35 | +1 Newton = 1 kg X meters / (seconds^2) |
| 36 | +How to use? |
| 37 | +Inputs: |
| 38 | + ___________________________________________________ |
| 39 | + |Name | Units | Type | |
| 40 | + |-------------|-------------------------|-----------| |
| 41 | + |mass | (in kgs) | float | |
| 42 | + |-------------|-------------------------|-----------| |
| 43 | + |acceleration | (in meters/(seconds^2)) | float | |
| 44 | + |_____________|_________________________|___________| |
| 45 | +
|
| 46 | +Output: |
| 47 | + ___________________________________________________ |
| 48 | + |Name | Units | Type | |
| 49 | + |-------------|-------------------------|-----------| |
| 50 | + |force | (in Newtons) | float | |
| 51 | + |_____________|_________________________|___________| |
| 52 | +
|
| 53 | +""" |
| 54 | + |
| 55 | + |
| 56 | +def newtons_second_law_of_motion(mass: float, acceleration: float) -> float: |
| 57 | + """ |
| 58 | + >>> newtons_second_law_of_motion(10, 10) |
| 59 | + 100 |
| 60 | + >>> newtons_second_law_of_motion(2.0, 1) |
| 61 | + 2.0 |
| 62 | + """ |
| 63 | + force = float() |
| 64 | + try: |
| 65 | + force = mass * acceleration |
| 66 | + except Exception: |
| 67 | + return -0.0 |
| 68 | + return force |
| 69 | + |
| 70 | + |
| 71 | +if __name__ == "__main__": |
| 72 | + import doctest |
| 73 | + |
| 74 | + # run doctest |
| 75 | + doctest.testmod() |
| 76 | + |
| 77 | + # demo |
| 78 | + mass = 12.5 |
| 79 | + acceleration = 10 |
| 80 | + force = newtons_second_law_of_motion(mass, acceleration) |
| 81 | + print("The force is ", force, "N") |
0 commit comments