Even-Odd In Python

Dear Sciaku Learner you are not logged in or not enrolled in this course.

Please Click on login or enroll now button.

If you have any query feel free to chat us!

Happy Coding! Happy Learning!

Lecture 33:- Even-Odd In Python

In Python, you can determine whether a given number is even or odd using conditional statements and the modulo operator (%). The modulo operator returns the remainder when a number is divided by another number. Here's how you can check if a number is even or odd:

pythonCopy code

def check_even_odd(number):    if number % 2 == 0:        print(f"{number} is even.")    else:        print(f"{number} is odd.") # Example usage: num = 7 check_even_odd(num)  # Output: 7 is odd. num = 12 check_even_odd(num)  # Output: 12 is even.

In this example, the check_even_odd() function takes a number as input and uses the modulo operator % to check if the number is divisible by 2 without any remainder. If the remainder is 0 (i.e., the number is even), the function prints "{number} is even." Otherwise, it prints "{number} is odd."

You can call the check_even_odd() function with different numbers to determine if they are even or odd. The function will return the appropriate message for each case.

5. Flow Control

Comments: 0

Frequently Asked Questions (FAQs)

How do I register on Sciaku.com?
How can I enroll in a course on Sciaku.com?
Are there free courses available on Sciaku.com?
How do I purchase a paid course on Sciaku.com?
What payment methods are accepted on Sciaku.com?
How will I access the course content after purchasing a course?
How long do I have access to a purchased course on Sciaku.com?
How do I contact the admin for assistance or support?
Can I get a refund for a course I've purchased?
How does the admin grant access to a course after payment?