► Python program for odd-even check

Steps followed:
1. take input from user and store in num variable
2. validate user input by converting to integer
3. check if number is exactly divisible by 2
4. print result


#python program for odd-even check

#getting input from user and storing in num variables
num=input("enter a number: ")

#validating user input
    print("you have entered valid number")    

    #divide number with 2 to check if the remainder is 0
    if num % 2 == 0:
        print("%d is an even number"%(num))
        print("%d is an odd number"%(num))
    print("you have entered invalid number")


enter a number: 80
you have entered valid number
80 is an even number

enter a number: 67
you have entered valid number
67 is an odd number

enter a number: star
you have entered invalid number

Also Read: