Skip to content

Number Operations (num_ops.py)

The Number Operations module in NumLex offers a set of functions for various operations on numbers, including finding maximum and minimum values, checking odd/even status, and more.

Functions

  • max_num(numbers): Finds the maximum value from a list of numbers.

    max_value = max_num([1, 2, 3, 4, 5])
  • min_num(numbers): Finds the minimum value from a list of numbers.

    min_value = min_num([1, 2, 3, 4, 5])
  • total_num(numbers, option): Calculates the total of a list of numbers, with options for even and odd totals.

    total = total_num([1, 2, 3, 4, 5], 'even')
  • is_positive(num): Checks if a number is positive.

    check = is_positive(5)
  • is_negative(num): Checks if a number is negative.

    check = is_negative(-5)
  • is_odd(num): Checks if a number is odd.

    check = is_odd(5)
  • is_even(num): Checks if a number is even.

    check = is_even(4)
  • is_leap(year): Checks if a year is a leap year.

    check = is_leap(2024)
  • digit_sum(num): Calculates the sum of the digits of a number.

    total = digit_sum(1234)
  • rev_num(num): Reverses the digits of a number.

    reversed = rev_num(1234)
  • is_palindrome(num): Checks if a number is a palindrome.

    palin = is_palindrome(121)
  • num_len(num): Calculates the length of a number.

    length = num_len(1234)