Monday, February 25, 2019

Odd and Even Number Checker Using Function in Python

This is a simple program that I wrote using the function in Python to check if the given number is odd or even. I am still learning Python programming language before I am currently working on my new book on Python programming with co-author, a mentor in programming and best friend Rollyn Moises.



Sample Program Output


Program Listing


# odd_even.py
# Rollyn M. Moises and Jake R. Pomperada
# February 25, 2019    Tuesday
# Bacolod City, Negros Occidental


def odd_even(n):
    if n % 2 == 0:
        print("\tThe number %d is an EVEN." % n)
    else:
        print("\tThe number %d is an ODD." % n)


def my_program():
    print();
    print("\tOdd and Even Number Checker Using Function");
    print();
    a= int(input("\tGive a Number : "));
    display = a;
    print();
    odd_even(display);
    print();
    repeat = input('\tDo you want to continue ? (Y/N) : ')
    if repeat.upper() == "N":
        print()
        print("\tThank You For Using This Program.")
        print();
        print("\tEND OF PROGRAM");
        quit

    if repeat.upper() == "Y":
        my_program()


if __name__ == '__main__':

    my_program()









No comments:

Post a Comment