Python Program to check a number is even or odd using class and object
In this program, you will learn how to check a number is even or odd using class and object in Python.
if a % 2 == 0:
//statement
Example: How to check a number is even or odd using class and object in Python
class Test:
def check(self, a):
if a % 2 == 0:
print("Number is even:", a)
else:
print("Number is odd:", a)
a = int(input("Enter a number:"))
obj = Test()
obj.check(a)
Output:
Enter a number:12
Number is even: 12