|
1 | | -""" |
2 | | -Description : Centripetal force is the force acting on an object in |
3 | | -curvilinear motion directed towards the axis of rotation |
4 | | -or centre of curvature. |
5 | | -
|
6 | | -The unit of centripetal force is newton. |
7 | | -
|
8 | | -The centripetal force is always directed perpendicular to the |
9 | | -direction of the object's displacement. Using Newton's second |
10 | | -law of motion, it is found that the centripetal force of an object |
11 | | -moving in a circular path always acts towards the centre of the circle. |
12 | | -The Centripetal Force Formula is given as the product of mass (in kg) |
13 | | -and tangential velocity (in meters per second) squared, divided by the |
14 | | -radius (in meters) that implies that on doubling the tangential velocity, |
15 | | -the centripetal force will be quadrupled. Mathematically it is written as: |
16 | | -F = mv²/r |
17 | | -Where, F is the Centripetal force, m is the mass of the object, v is the |
18 | | -speed or velocity of the object and r is the radius. |
19 | | -
|
20 | | -Reference: https://byjus.com/physics/centripetal-and-centrifugal-force/ |
21 | | -""" |
22 | | - |
23 | | - |
24 | | -def centripetal(mass: float, velocity: float, radius: float) -> float: |
| 1 | +def centripetal_force(mass: float, velocity: float, radius: float) -> float: |
25 | 2 | """ |
26 | | - The Centripetal Force formula is given as: (m*v*v)/r |
27 | | -
|
28 | | - >>> round(centripetal(15.5,-30,10),2) |
29 | | - 1395.0 |
30 | | - >>> round(centripetal(10,15,5),2) |
31 | | - 450.0 |
32 | | - >>> round(centripetal(20,-50,15),2) |
33 | | - 3333.33 |
34 | | - >>> round(centripetal(12.25,40,25),2) |
35 | | - 784.0 |
36 | | - >>> round(centripetal(50,100,50),2) |
37 | | - 10000.0 |
| 3 | + Calculate the centripetal force acting on an object in circular motion. |
| 4 | +
|
| 5 | + Formula: |
| 6 | + F = (m * v^2) / r |
| 7 | +
|
| 8 | + Reference: |
| 9 | + https://byjus.com/physics/centripetal-and-centrifugal-force/ |
| 10 | +
|
| 11 | + >>> centripetal_force(2, 4, 2) |
| 12 | + 16.0 |
| 13 | + >>> centripetal_force(1, 3, 1) |
| 14 | + 9.0 |
| 15 | + >>> centripetal_force(-1, 3, 2) |
| 16 | + Traceback (most recent call last): |
| 17 | + ... |
| 18 | + ValueError: The mass of the body cannot be negative |
| 19 | + >>> centripetal_force(2, 3, 0) |
| 20 | + Traceback (most recent call last): |
| 21 | + ... |
| 22 | + ValueError: The radius must be a positive non-zero number |
38 | 23 | """ |
39 | 24 | if mass < 0: |
40 | 25 | raise ValueError("The mass of the body cannot be negative") |
41 | 26 | if radius <= 0: |
42 | | - raise ValueError("The radius is always a positive non zero integer") |
43 | | - return (mass * (velocity) ** 2) / radius |
44 | | - |
45 | | - |
46 | | -if __name__ == "__main__": |
47 | | - import doctest |
| 27 | + raise ValueError("The radius must be a positive non-zero number") |
48 | 28 |
|
49 | | - doctest.testmod(verbose=True) |
| 29 | + return (mass * velocity**2) / radius |
0 commit comments