Even and Odd Numbers || Classes || Python
In this we are going to see a basic program to find even and odd numbers using classes in Python Programming Language.



import math
 
 
class even_odd:
    def __init__(self):
        self._n = 0
 
    def getdata(self):
        print("Enter number: ", end='')
        self.n = int(input())
 
    def checkevenodd(self):
        if math.fmod(self.n, 2) == 0:
            print("Even", end='')
        else:
            print("Odd", end='')
 
 
eo = even_odd()
eo.getdata()
eo.checkevenodd()

#Coded by SAAHIL


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post