{"id":20382,"date":"2021-09-11T15:37:59","date_gmt":"2021-09-11T10:07:59","guid":{"rendered":"https:\/\/python-programs.com\/?p=20382"},"modified":"2021-11-22T18:36:22","modified_gmt":"2021-11-22T13:06:22","slug":"python-program-to-check-even-or-odd-using-bitwise-operator","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-even-or-odd-using-bitwise-operator\/","title":{"rendered":"Python Program to Check Even or Odd Using Bitwise Operator"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Set nth Bit of a Number<\/a><\/p>\n

Given a Number and the task is to check if the given number is even or odd using the bitwise operator.<\/p>\n

Bitwise & Operator:<\/strong><\/p>\n

If both bits are 1, sets each bit to 1.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 251<\/pre>\n

Output:<\/strong><\/p>\n

The Number given is an Odd Number<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 54<\/pre>\n

Output:<\/strong><\/p>\n

The Number given is an Even Number<\/pre>\n

Program to Check Even or Odd Using Bitwise Operator in Python:<\/h2>\n

Below are the ways to check if the given number is even or odd using the bitwise operator in python:<\/p>\n