← Back to challenges

Bitwise Operator to Check Odd, Regular Expression to Check Even

PythonHardconditionsregexbit_operationsvalidation

Instructions

Create two functions:

  1. The first is is_odd() to check if a given number is odd using bitwise operator.
  2. The second is is_even() to check if a given input is even using regular expressions.

Use of % operator is disallowed.

Examples

is_odd(3) ➞ "Yes"
# Use Bitwise Operator

is_odd(58) ➞ "No"
# Use Bitwise Operator

is_even("0") ➞ "Yes"
# Use Regular Expression

is_even("-99") ➞ "No"
# Use Regular Expression

Notes

  • Input will only be integers (positive/negative/zero).
  • For the second function, input will be numbers in string.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.