diff --git a/maths/prime_check.py b/maths/prime_check.py index a757c4108f24..c87641ff4631 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 diff --git a/physics/centripetal_force.py b/physics/centripetal_force.py index a4c624582475..3fe2457f28ed 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. +Where, F = Centripetal Force + m = Mass of the Body + v = Tangential Velocity + r = Radius of Circular Path -Reference: https://byjus.com/physics/centripetal-and-centrifugal-force/ """ diff --git a/physics/ideal_gas_law.py b/physics/ideal_gas_law.py index 09b4fb3a9c14..b2671437bc04 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)