@@ -40,10 +40,10 @@ def gravitational_potential_energy(mass: float, height: float) -> float:
4040
4141 Returns:
4242 The value of energy in Joules
43-
43+
4444 Complexity:
4545 Time Complexity: O(1) - Constant execution time for evaluation logic.
46- Space Complexity: O(1) - Constant memory allocation.
46+ Space Complexity: O(1) - Constant memory allocation.
4747
4848 Examples:
4949 >>> gravitational_potential_energy(10,10)
@@ -70,6 +70,7 @@ def gravitational_potential_energy(mass: float, height: float) -> float:
7070
7171 return mass * g * height
7272
73+
7374def spring_potential_energy (spr_con : float , dspl : float ) -> float :
7475 """
7576 Function calculates the spring potential energy of an object.
@@ -80,10 +81,10 @@ def spring_potential_energy(spr_con: float, dspl: float) -> float:
8081
8182 Returns:
8283 The value of energy in Joules
83-
84+
8485 Complexity:
8586 Time Complexity: O(1) - Constant execution time for evaluation logic.
86- Space Complexity: O(1) - Constant memory allocation.
87+ Space Complexity: O(1) - Constant memory allocation.
8788
8889 Examples:
8990 >>> spring_potential_energy(100,2)
@@ -97,14 +98,14 @@ def spring_potential_energy(spr_con: float, dspl: float) -> float:
9798 >>> spring_potential_energy(17,4.5)
9899 172.125
99100 """
100- if spr_con < 0 :
101+ if spr_con < 0 :
101102 raise ValueError ("The values for spring_constant cannot be negative" )
102-
103- return 0.5 * spr_con * (dspl ** 2 )
104103
104+ return 0.5 * spr_con * (dspl ** 2 )
105105
106106
107107if __name__ == "__main__" :
108108 from doctest import testmod
109- print (spring_potential_energy (17 ,4.5 ))
109+
110+ print (spring_potential_energy (17 , 4.5 ))
110111 testmod (name = "gravitational_potential_energy" )
0 commit comments