Skip to content

Commit 63c4a27

Browse files
committed
fixed error to push to main
1 parent be3aacb commit 63c4a27

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

physics/collisions.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""
2-
Finding the type of collision and calculating final velocities after collisions are fundamental concepts in physics.
3-
This module provides functions to compute the final velocities of two masses after both inelastic and elastic collisions,
4-
as well as a function to determine the type of collision based on initial and final velocities.
5-
6-
Description: Collisions in physics refers to the interaction between two masses when they collide head-on. There are 2 types of
7-
collisions: inelastic and elastic. In an inelastic collision, the two masses stick together and move with a common velocity
8-
after the collision. In an elastic collision, both momentum and kinetic energy are conserved, and the masses bounce off each other without sticking together.
9-
Momentum is the product of mass and velocity, while kinetic energy is given by the formula (1/2) * mass * velocity^2.
10-
The type of collision can be determined by comparing the initial and final momentum and kinetic energy of the system.
2+
Finding collision types and final velocities is key in physics.
3+
This module computes final velocities for inelastic and elastic collisions.
4+
It also identifies the collision type from initial and final velocities.
5+
6+
Description: Collisions happen when two masses interact head-on.
7+
There are two types: inelastic and elastic. In inelastic collisions, the
8+
masses stick together and share one final velocity. In elastic collisions,
9+
momentum and kinetic energy stay conserved, and the masses rebound.
10+
Momentum is mass times velocity, and kinetic energy is 1/2 mv^2.
11+
The type of collision can be found by comparing the system's initial and
12+
final momentum and kinetic energy.
1113
1214
Reference: https://en.wikipedia.org/wiki/Collision
1315
"""
@@ -50,7 +52,7 @@ def elastic_collisions(mass1 :float,
5052
) -> str :
5153
"""Calculate final velocities after a perfectly elastic collision.
5254
53-
This assumes the collision is head-on and conserves both momentum and kinetic energy.
55+
The collision is head-on and conserves both momentum and kinetic energy.
5456
5557
Parameters:
5658
mass1: Mass of the first object.
@@ -115,11 +117,11 @@ def type_collision(mass1 :float,
115117
kinetic_final = 0.5 * ((mass1 * velocity_final1**2) + (mass2 * velocity_final2**2))
116118

117119
if kinetic_final == kinetic_initial and momentum_initial == momentum_final:
118-
return f'Perfectly Elastic Collision'
120+
return 'Perfectly Elastic Collision'
119121
elif not(kinetic_final == kinetic_initial) and momentum_initial == momentum_final:
120-
return f'Perfectly Inelastic Collision'
122+
return 'Perfectly Inelastic Collision'
121123
else:
122-
return f'Inelastic Collision'
124+
return 'Inelastic Collision'
123125

124126

125127
if __name__ == "__main__":

0 commit comments

Comments
 (0)