To find number is odd or even


def check_odd_or_even(num): if num % 2 == 0: print(num, "is even.") else: print(num, "is odd.") num = int(input("Enter a number: ")) check_odd_or_even(num) In this program, we define a function `check_odd_or_even` that takes a number as input. We use the modulo operator `%` to check if the number is divisible by 2. If the remainder is 0, then the number is even, otherwise it is odd. The program then prints the appropriate message based on the result of this check. Finally, we prompt the user to enter a number and call the `check_odd_or_even` function with that number.

Comments

Popular posts from this blog

Ecommerce website

Yes, Python is an object-oriented programming (OOP) language, but it is also a multi-paradigm language

Your task is to find the missing number.