Math Functions

betterfunctions.mathfunctions.celsius_to_fahrenheit(celsius)

Converts celsius to fahrenheit.

Parameters:

celsius (float) – The temperature in fahrenheit.

Return type:

int

betterfunctions.mathfunctions.distance_between_points(x1, y1, x2, y2)

Calculates the distance between two points.

Parameters:
  • x1 (float) – The x-Coordinate of the first point.

  • x2 (float) – The x-Coordinate of the second point.

  • y1 (float) – The y-Coordinate of the first point.

  • y2 (float) – The y-Coordinate of the second point.

Return type:

int

betterfunctions.mathfunctions.factorial(n)

Calculates the factorial of a number.

Parameters:

n (int) – The number where the factorial should be calculated.

Return type:

int

betterfunctions.mathfunctions.fahrenheit_to_celsius(fahrenheit)

Converts fahrenheit to celsius.

Parameters:

fahrenheit (float) – The temperature in fahrenheit.

Return type:

int

betterfunctions.mathfunctions.fibonacci(n)

Generates a list with the fibonacci-numbers to n.

Parameters:

n (int) – The number to where the fibonaccis should be generated.

Return type:

list

betterfunctions.mathfunctions.format_number(number, *, decimal_places=1, trailing_zero=False)

Formats a big number into a tiny, readable format.

Parameters:
  • number (int) – The number which should be formatted.

  • decimal_places (int) – The amount of decimal places which should be displayed. Defaults to 1.

  • trailing_zero (bool) – Should trailing zeros be displayed? Default: False.

Return type:

str

betterfunctions.mathfunctions.gcd(a, b)

Calculates the gcd of two numbers.

Parameters:
  • a (int) – The first number.

  • b (int) – The second number.

Return type:

int

betterfunctions.mathfunctions.int_to_roman(num)

Converts an integer to a roman number.

Parameters:

num (int) – The number which should be converted.

Return type:

str

betterfunctions.mathfunctions.is_prime(num)

Checks if a number is a prime number.

Parameters:

num (int) – The number which should be checked.

Return type:

bool

betterfunctions.mathfunctions.lcm(a, b)

Calculates the lcm of two numbers.

Parameters:
  • a (int) – The first number.

  • b (int) – The second number.

Return type:

int

betterfunctions.mathfunctions.prime_numbers(n)

Generates a list with the prime numbers to n.

Parameters:

n (int) – The number, to where the prime numbers should be generated.

Return type:

list