Westonci.ca is the best place to get answers to your questions, provided by a community of experienced and knowledgeable experts. Discover a wealth of knowledge from experts across different disciplines on our comprehensive Q&A platform. Get quick and reliable solutions to your questions from a community of experienced experts on our platform.

Write a function called is_even that takes one parameter and returns a boolean value. It should return True if the argument is even; it should return False otherwise.

The is_even function should not print anything out or return a number. It should only take in a number and return a boolean.

Note: Be sure to include comments for all functions that you use or create.

For example, if you made a call like

is_even_number = is_even(4)
is_even_number should have the value True.

Once you’ve written this function, write a program that asks the user for integers and prints whether the number they entered is even or odd using your is_even function. You should let the user keep entering numbers until they enter the SENTINEL value.

Here is a sample run of the program:

Enter a number: 5
Odd
Enter a number 42
Even
Enter a number: -6
Even
Enter a number: 0
Done!

(CODEHS, PYTHON)

Sagot :

def is_even_number(n):

   return True if n % 2 == 0 else False

while True:

   number = int(input("Enter a number: "))

   if number == 0:

       break

   else:

       if is_even_number(number):

           print("Even")

       else:

           print("Odd")

I wrote my code in python 3.8. I hope this helps.