Maths:
Adding Numbers:
def add(*nums: Union[int, float]) -> Union[int, float]:
"""
Adds multiple numbers.
Args:
*nums (int or float): Variable-length list of numbers to be added.
Returns:
int or float: The sum of the provided numbers.
Example:
>>> add(2, 3, 5)
10
"""
Example
from pydevtools.math import math
print(math.add(35,80)) # Output: 115
print(math.add(1, 2, 3, 4)) # Output: 10
print(math.add(1, 2.5, 3, 4.5)) # Output: 11
Subtracting Numbers:
def sub(*nums: Union[int, float]) -> Union[int, float]:
"""
Subtracts numbers.
Args:
*nums (int or float): Variable-length list of numbers.
Subtracts each subsequent number from the first.
Returns:
int or float: The result of subtraction.
Example:
>>> sub(10, 2, 3)
5
"""
Example
from pydevtools.math import math
print(math.sub(80,35)) # Output: 45
print(math.sub(1, 2, 3, 4)) # Output: -8
print(math.sub(1.5, 2.5, 3.5)) # Output: -4.5
Multipling Numbers:
def mult(*nums: Union[int, float]) -> Union[int, float]:
"""
Multiplies numbers.
Args:
*nums (int or float): Variable-length list of numbers to be multiplied.
Returns:
int or float: The product of the provided numbers.
Example:
>>> mult(2, 3, 4)
24
"""
Example
from pydevtools.math import math
print(math.mult(70,5)) # Output: 350
print(math.mult(1, 2, 3, 4)) # Output: 24
print(math.mult(1.5, 2.5, 3.5)) # Output: 13.125
Dividing Numbers:
def div(*nums: Union[int, float]) -> Union[int, float]:
"""
Divides numbers.
Args:
*nums (int or float): Variable-length list of numbers.
Divides each subsequent number by the first.
Returns:
int or float: The result of division.
Example:
>>> div(20, 2, 5)
2.0
"""
Example
from pydevtools.math import math
print(math.div(10, 2)) # Output: 5.0
print(math.div(10.5, 2.0)) # Output: 5.25
print(math.div(10, 2, 7)) # Output: 0.7142857142857143
Reminder of Division:
def rem(a: Union[int, float], b: Union[int, float]) -> Union[int, float]:
"""
Module of two numbers.
Args:
a (int or float): Number.
b (int or float): Number.
Returns:
int or float: The result of modulo operation.
Example:
>>> rem(70, 35)
0
"""
Example
from pydevtools.math import math
print(math.rem(10, 2)) # Output: 0
print(math.rem(10.5, 2.0)) # Output: 0.5
print(math.rem(10, 2.5)) # Output: 0.0
Input:
Get user-input with colored prompt:
def get_input(prompt: str, color: str = "white") -> str:
"""
Get user input with an optional colorized prompt using Colorama.
Args:
prompt (str): The prompt message to display.
color (str, optional): The color for the prompt. Should be one of the Colorama color constants.
Defaults to "white" if not specified.
Returns:
str: The user's input as a string.
"""
Example
from pydevtools.input import input
print(input.get_input("Hello", "blue"))
Get user input:
def get_strinput(prompt: str, color: str = "white") -> str:
"""
Get user input with an optional colorized prompt using Colorama and expect a string input.
Args:
prompt (str): The prompt message to display.
color (str, optional): The color for the prompt. Should be one of the Colorama color constants.
Defaults to "white" if not specified.
Returns:
str: The user's input as a string.
"""
Example
from pydevtools.input import input
print(input.get_strinput("Hello", "blue"))
Get integer input:
def get_intinput(prompt: str, color: str = "white") -> int:
"""
Get user input with an optional colorized prompt using Colorama and expect an integer input.
Args:
prompt (str): The prompt message to display.
color (str, optional): The color for the prompt. Should be one of the Colorama color constants.
Defaults to "white" if not specified.
Returns:
int: The user's input as an integer.
Raises:
ValueError: If the user input cannot be converted to an integer.
"""
Example
from pydevtools.input import input
print(input.get_intinput("Hello", "blue"))
Get decimal number input:
def get_floatinput(prompt: str, color: str = "white") -> float:
"""
Get user input with an optional colorized prompt using Colorama and expect a float input.
Args:
prompt (str): The prompt message to display.
color (str, optional): The color for the prompt. Should be one of the Colorama color constants.
Defaults to "white" if not specified.
Returns:
float: The user's input as a float.
Raises:
ValueError: If the user input cannot be converted to a float.
"""
Example
from pydevtools.input import input
print(input.get_floatinput("Hello", "blue"))
Output:
Print colored output:
def print_output(message, color="white") -> None:
"""
Print a message with optional colorization using Colorama.
Args:
message (str): The message to be displayed.
color (str, optional): The color for the message. Should be one of the Colorama color constants.
Defaults to "white" if not specified.
Returns:
None
Example:
>>> print_output("Success!", "green")
"Success!"
"""
Example
from pydevtools.output import output
output.print_output("hello world","magenta")
Print information:
def print_info(message: str) -> None:
"""
Print an informational message in green color.
Args:
message (str): The informational message to print.
Returns:
None
Example:
>>> print_info("This is an informational message.")
[INFO]: This is an informational message.
"""
Example
from pydevtools.output import output
output.print_info("hello world")
Print warning messages:
def print_warning(message: str) -> None:
"""
Print a warning message in yellow color.
Args:
message (str): The warning message to print.
Returns:
None
Example:
>>> print_warning("This is a warning message.")
[WARNING]: This is a warning message.
"""
Example
from pydevtools.output import output
output.print_warning("hello world")
Print error messages:
def print_error(message: str) -> None:
"""
Print an error message in red color.
Args:
message (str): The error message to print.
Returns:
None
Example:
>>> print_error("This is an error message.")
[ERROR]: This is an error message.
"""
Example
from pydevtools.output import output
output.print_error("hello world")