A Python Module that answers the question that few programmers and mathematicians dares to even approach: Is it even?
Determines if a boolean value is even.
Features:
- Treats
Falseas even andTrueas odd - Validates that your input is actually a boolean
Determines if an integer is even.
Features:
- Works with integers
- Supports negative numbers too.
- Validates that your input is actually an integer (no floating point numbers here!)
Determines if a real number is even. Supports integers, floats, and mathematical constants.
Features:
- Works with integers, floats, and
fractions.Fraction - Handles mathematical constants like π and e
- Validates that your input is actually real (no imaginary numbers here!)
Determines if a complex number is even. A complex number is considered even if both its real and imaginary parts have the same parity.
Features:
- Treats complex numbers with sophisticated mathematical grace
- Knows the answer to "is
ieven?" - Validates that you actually input a complex number
Determines if a number, either integer, real, or complex, is even.
Features:
- Supports booleans, real numbers, complex numbers, and fractions
import fractions
from init import (
bool_is_even,
int_is_even,
real_is_even,
complex_is_even,
general_is_even,
)
# Integers
int_is_even(2) # True
int_is_even(-3) # False
int_is_even(0) # True
# Booleans
bool_is_even(False) # True
bool_is_even(True) # False
# Real numbers
real_is_even(2) # True
real_is_even(3.7) # False
real_is_even(2.4) # True
real_is_even(fractions.Fraction(4, 2)) # True
# Complex numbers
complex_is_even(2+2j) # True (both parts even)
complex_is_even(3+3j) # True (both parts odd)
complex_is_even(2+3j) # False (mixed parity)
# General numbers
general_is_even(7) # False
general_is_even(2+2j) # True
general_is_even(3.7) # False
general_is_even(fractions.Fraction(3, 2)) # False
general_is_even(False) # TrueRun the professional test suite with:
python tests.pyThanks to @ToglivvilgoT for invaluable technical assistance!