From ce194b0a10f7868f30282fea016611c202c8f784 Mon Sep 17 00:00:00 2001 From: HARSH VERMA Date: Sat, 7 Feb 2026 00:05:37 +0530 Subject: [PATCH 1/7] Add space and new sentences to prime check implementation --- maths/prime_check.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/maths/prime_check.py b/maths/prime_check.py index a757c4108f24..edede764ff86 100644 --- a/maths/prime_check.py +++ b/maths/prime_check.py @@ -1,4 +1,4 @@ -"""Prime Check.""" +"""PRIME CHECK.""" import math import unittest @@ -7,7 +7,8 @@ def is_prime(number: int) -> bool: - """Checks to see if a number is a prime in O(sqrt(n)). + """ + Checks to see if a number is a prime in O(sqrt(n)). A number is prime if it has exactly two factors: 1 and itself. @@ -29,14 +30,21 @@ def is_prime(number: int) -> bool: True >>> is_prime(67483) False + + If the number entered is not whole number i.e not an integer + For example- >>> is_prime(16.1) Traceback (most recent call last): ... ValueError: is_prime() only accepts positive integers + + If the number entered is negative integer + For example- >>> is_prime(-4) Traceback (most recent call last): ... ValueError: is_prime() only accepts positive integers + """ # precondition From afe9575f451e411e4e6d82cf38ba720dcd87e07d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 19:20:39 +0000 Subject: [PATCH 2/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/prime_check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/prime_check.py b/maths/prime_check.py index edede764ff86..c87641ff4631 100644 --- a/maths/prime_check.py +++ b/maths/prime_check.py @@ -44,7 +44,7 @@ def is_prime(number: int) -> bool: Traceback (most recent call last): ... ValueError: is_prime() only accepts positive integers - + """ # precondition From 49c12ec51dbf4c39deb75aec4e842ad9ee7f525c Mon Sep 17 00:00:00 2001 From: HARSH VERMA Date: Mon, 23 Feb 2026 11:31:39 +0530 Subject: [PATCH 3/7] Improving readibilty of centripetal_force.py --- physics/centripetal_force.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/physics/centripetal_force.py b/physics/centripetal_force.py index a4c624582475..514382e683d4 100644 --- a/physics/centripetal_force.py +++ b/physics/centripetal_force.py @@ -1,23 +1,11 @@ """ -Description : Centripetal force is the force acting on an object in -curvilinear motion directed towards the axis of rotation -or centre of curvature. -The unit of centripetal force is newton. - -The centripetal force is always directed perpendicular to the -direction of the object's displacement. Using Newton's second -law of motion, it is found that the centripetal force of an object -moving in a circular path always acts towards the centre of the circle. -The Centripetal Force Formula is given as the product of mass (in kg) -and tangential velocity (in meters per second) squared, divided by the -radius (in meters) that implies that on doubling the tangential velocity, -the centripetal force will be quadrupled. Mathematically it is written as: F = mv²/r -Where, F is the Centripetal force, m is the mass of the object, v is the -speed or velocity of the object and r is the radius. - -Reference: https://byjus.com/physics/centripetal-and-centrifugal-force/ +Where, F = Centripetal Force + m = Mass of the Body + v = Tangential Velocity + r = Radius of Circular Path + """ From 75f4987c7b7c62aa6b03ef4d17b453ddbadc1c95 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 06:05:03 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/centripetal_force.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/centripetal_force.py b/physics/centripetal_force.py index 514382e683d4..3fe2457f28ed 100644 --- a/physics/centripetal_force.py +++ b/physics/centripetal_force.py @@ -5,7 +5,7 @@ m = Mass of the Body v = Tangential Velocity r = Radius of Circular Path - + """ From 05ec3fd0eb446098b99f97fd0f5a54539c10bcb5 Mon Sep 17 00:00:00 2001 From: HARSH VERMA Date: Mon, 23 Feb 2026 17:49:18 +0530 Subject: [PATCH 5/7] Improvising ideal_gas_law.py --- physics/ideal_gas_law.py | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/physics/ideal_gas_law.py b/physics/ideal_gas_law.py index 09b4fb3a9c14..ac05d6ce6f27 100644 --- a/physics/ideal_gas_law.py +++ b/physics/ideal_gas_law.py @@ -1,21 +1,15 @@ """ -The ideal gas law, also called the general gas equation, is the -equation of state of a hypothetical ideal gas. It is a good approximation -of the behavior of many gases under many conditions, although it has -several limitations. It was first stated by Benoît Paul Émile Clapeyron -in 1834 as a combination of the empirical Boyle's law, Charles's law, -Avogadro's law, and Gay-Lussac's law.[1] The ideal gas law is often written -in an empirical form: - ------------ - | PV = nRT | - ------------ -P = Pressure (Pa) -V = Volume (m^3) -n = Amount of substance (mol) -R = Universal gas constant -T = Absolute temperature (Kelvin) - -(Description adapted from https://en.wikipedia.org/wiki/Ideal_gas_law ) + + PV = nRT + +Where, P = Pressure (Pa) + V = Volume (m^3) + n = Amount of substance (mol) + R = Universal gas constant + T = Absolute temperature (Kelvin) + +Description adapted from https://en.wikipedia.org/wiki/Ideal_gas_law + """ UNIVERSAL_GAS_CONSTANT = 8.314462 # Unit - J mol-1 K-1 @@ -32,9 +26,9 @@ def pressure_of_gas_system(moles: float, kelvin: float, volume: float) -> float: ... ValueError: Invalid inputs. Enter positive value. """ - if moles < 0 or kelvin < 0 or volume < 0: + if moles <= 0 or kelvin <= 0 or volume <= 0: raise ValueError("Invalid inputs. Enter positive value.") - return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume + return (moles * kelvin * UNIVERSAL_GAS_CONSTANT) / volume def volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float: @@ -48,9 +42,9 @@ def volume_of_gas_system(moles: float, kelvin: float, pressure: float) -> float: ... ValueError: Invalid inputs. Enter positive value. """ - if moles < 0 or kelvin < 0 or pressure < 0: + if moles <= 0 or kelvin <= 0 or pressure <= 0: raise ValueError("Invalid inputs. Enter positive value.") - return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure + return (moles * kelvin * UNIVERSAL_GAS_CONSTANT) / pressure def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> float: @@ -64,7 +58,7 @@ def temperature_of_gas_system(moles: float, volume: float, pressure: float) -> f ... ValueError: Invalid inputs. Enter positive value. """ - if moles < 0 or volume < 0 or pressure < 0: + if moles <= 0 or volume <= 0 or pressure <= 0: raise ValueError("Invalid inputs. Enter positive value.") return pressure * volume / (moles * UNIVERSAL_GAS_CONSTANT) @@ -81,7 +75,7 @@ def moles_of_gas_system(kelvin: float, volume: float, pressure: float) -> float: ... ValueError: Invalid inputs. Enter positive value. """ - if kelvin < 0 or volume < 0 or pressure < 0: + if kelvin <= 0 or volume <= 0 or pressure <= 0: raise ValueError("Invalid inputs. Enter positive value.") return pressure * volume / (kelvin * UNIVERSAL_GAS_CONSTANT) From bc496926b7d14a850f9246df77dfbec0e329e944 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Feb 2026 12:20:46 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- physics/ideal_gas_law.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/physics/ideal_gas_law.py b/physics/ideal_gas_law.py index ac05d6ce6f27..b2671437bc04 100644 --- a/physics/ideal_gas_law.py +++ b/physics/ideal_gas_law.py @@ -1,7 +1,7 @@ """ - PV = nRT - + PV = nRT + Where, P = Pressure (Pa) V = Volume (m^3) n = Amount of substance (mol) From a75c1c88c05b6aa432d234d56725843eb5d1d3ce Mon Sep 17 00:00:00 2001 From: HARSH VERMA Date: Fri, 6 Mar 2026 10:10:45 +0530 Subject: [PATCH 7/7] Rename parameter in factorial_recursive function --- maths/factorial.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/maths/factorial.py b/maths/factorial.py index ba61447c7564..5c84bf20cdcc 100644 --- a/maths/factorial.py +++ b/maths/factorial.py @@ -35,7 +35,7 @@ def factorial(number: int) -> int: return value -def factorial_recursive(n: int) -> int: +def factorial_recursive(num: int) -> int: """ Calculate the factorial of a positive integer https://en.wikipedia.org/wiki/Factorial @@ -52,11 +52,11 @@ def factorial_recursive(n: int) -> int: ... ValueError: factorial() not defined for negative values """ - if not isinstance(n, int): + if not isinstance(num, int): raise ValueError("factorial() only accepts integral values") - if n < 0: + if num < 0: raise ValueError("factorial() not defined for negative values") - return 1 if n in {0, 1} else n * factorial_recursive(n - 1) + return 1 if num in {0, 1} else num * factorial_recursive(num - 1) if __name__ == "__main__": @@ -64,5 +64,5 @@ def factorial_recursive(n: int) -> int: doctest.testmod() - n = int(input("Enter a positive integer: ").strip() or 0) - print(f"factorial{n} is {factorial(n)}") + num = int(input("Enter a positive integer: ").strip() or 0) + print(f"factorial{n} is {factorial(num)}")