Skip to content

Commit 5ad4386

Browse files
authored
Refine docstrings and comments for Boyle's law implementation
Updated formatting and improved clarity in docstrings and comments throughout the code.
1 parent 6a08e1f commit 5ad4386

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

‎physics/boyles_law.py‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Title : Implementation of Boyle's law.
2+
Title: Implementation of Boyle's law.
33
44
Description :
55
Boyle's law, also referred to as the Boyle-Mariotte law, or Mariotte's law
@@ -12,28 +12,30 @@
1212
1313
P ∝ (1/V)
1414
15-
Where P is the pressure exerted by the gas and V is the volume occupied by it. This
16-
proportionality can be converted into an equation by adding a constant, k.
15+
Where P is the pressure exerted by the gas, and V is the volume occupied by it.
16+
This proportionality can be converted into an equation by adding a constant, k.
1717
1818
P = k*(1/V) ⇒ PV = k
1919
2020
Boyle's law states that when the temperature of a given mass of confined gas is
21-
constant,the product of its pressure and volume is also constant. When comparing the
21+
constant, the product of its pressure and volume is also constant. When comparing the
2222
same substance under two different sets of conditions, the law can be expressed as:
2323
2424
P1V1 = P2V2
2525
2626
Where,
2727
2828
P1 is the initial pressure exerted by the gas in Pascals (P)
29-
V1 is the initial volume occupied by the gas Litres (L)
30-
P2 is the final pressure exerted by the gas Pascals (P)
31-
V2 is the final volume occupied by the gas Litres (L)
29+
V1 is the initial volume occupied by the gas in litres (L)
30+
P2 is the final pressure exerted by the gas in Pascals (P)
31+
V2 is the final volume occupied by the gas in litres (L)
3232
3333
This equation can be used to predict the increase in the pressure exerted by a gas
3434
on the walls of its container when the volume of its container is decreased
3535
(and its quantity and absolute temperature remain unchanged).
3636
37+
Related to: physics/ideal_gas_law.py
38+
3739
Sources :
3840
https://en.wikipedia.org/wiki/Boyle%27s_law
3941
https://byjus.com/chemistry/boyles-law/
@@ -45,8 +47,7 @@
4547
def check_validity(values: dict[str, float]) -> None:
4648
"""
4749
48-
Function takes dictionary as an input and returns nothing if the input
49-
is valid
50+
Takes a dictionary as input and returns nothing if the input is valid
5051
5152
>>> check_validity({})
5253
Traceback (most recent call last):
@@ -81,9 +82,8 @@ def check_validity(values: dict[str, float]) -> None:
8182
def find_target_variable(values: dict[str, float]) -> str:
8283
"""
8384
84-
Function is used to get the valid target variable whose value needs to be found
85-
using Boyle's Law.
86-
Function takes a dictionary as an input and returns a string
85+
Get the valid target variable whose value needs to be found using Boyle's Law.
86+
Takes a dictionary as input and returns a string
8787
8888
>>> find_target_variable({})
8989
Traceback (most recent call last):
@@ -114,10 +114,10 @@ def find_target_variable(values: dict[str, float]) -> str:
114114
def boyles_law(values: dict[str, float]) -> dict[str, str]:
115115
"""
116116
117-
Function calculates the the unknown pressure or volume using Boyle's law.
118-
Function takes a dictionary as an input. It contains values for respective
117+
Calculates the unknown pressure or volume using Boyle's law.
118+
Takes a dictionary as input that contains values for the respective
119119
pressure and volumes and computes the required value and returns it as
120-
output
120+
output.
121121
122122
>>> boyles_law({'p1':2,'v2':1})
123123
Traceback (most recent call last):

0 commit comments

Comments
 (0)