Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Complete Is Even

A Python Module that answers the question that few programmers and mathematicians dares to even approach: Is it even?

Content

bool_is_even(boolean: bool) -> bool

Determines if a boolean value is even.

Features:

  • Treats False as even and True as odd
  • Validates that your input is actually a boolean

int_is_even(integer: int) -> bool

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!)

real_is_even(number: float | int | fractions.Fraction) -> bool

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!)

complex_is_even(number: complex) -> bool

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 i even?"
  • Validates that you actually input a complex number

general_is_even(number: bool | int | float | complex | fractions.Fraction) -> bool

Determines if a number, either integer, real, or complex, is even.

Features:

  • Supports booleans, real numbers, complex numbers, and fractions

Usage

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)    # True

Testing

Run the professional test suite with:

python tests.py

Shoutout

Thanks to @ToglivvilgoT for invaluable technical assistance!

About

Python module that extends "even or odd" functionality to all real and complex numbers.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages