Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Python Program to Check Even or Odd Number

    Python Programming Examples


    This Python example code demonstrates a simple Python program that checks whether a given number is an even or odd number and prints the output to the screen.

    Program:

    #Taking user input
    num = int(input("Enter a number: "))
    
    if (num % 2) == 0:
       print("{0} is Even".format(num))
    else:
       print("{0} is Odd".format(num))

    Program Output:

    Enter a number: 6
    6 is Even

    If a number is evenly divisible by 2 without any remainder, then it is an even number; Otherwise, it is an odd number. The modulo operator % is used to check it in such a way as num%2 == 0.

    In the calculation part of the program, the given number is evenly divisible by 2 without remainder, so it is an even number.



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.