Solved:

Checkmark

Answered by AI, Verified by Human Experts

5.5.4 Is It Even? Submit + Continue Save Output Test Cases Docs Assignment Grade More Test Cases Check Code Expand All Minimize All 1 - def is_even(num): 2 if num%2==0 3 return True 4 - else: 5 return false 6 - if __name__== "__main__": 7 num=int(input(enter a interger : ")) 8 res=is_even(num) 9- if even: 10 print("Even") 11 - else: 12 print("Odd") Test Pass Message You should define a function called is_even ✓ Great! is even should return a boolean value ✓ Great! For each input, you should print "Even" or "Odd" Х Failure Expected result: Even Odd Even Odd Even Even Even Odd Odd Done! Your result: Something wrong with the code 5.5.4 Is It Even? Submit + Continue Save Output Test Cases Docs Assignment Grade More 5 points Status: Not Submitted 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. 1 - def is_even(num): 2 if num%2==0 3 return True 4- else: 5 return false 6- if __name__=="__main__": num=int(input(enter a interger : ")) res=is_even(num) 9- if even: 10 print("Even") else: 12 print("Odd") The is_even function should not print anything out or return a number. It should only take in a number and return a boolean. 578 9 Note: Be sure to include comments for all functions that you use or create. 11 - 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!

5.5.4 Is It Even? Submit + Continue Save Output Test Cases Docs Assignment Grade More Test Cases Check Code Expand All Minimize All 1 - def is_even(num): 2 if num%2==0 3 return True 4 - else: 5 return false 6 - if __name__== "__main__": 7 num=int(input(enter a interger : ")) 8 res=is_even(num) 9- if even: 10 print("Even") 11 - else: 12 print("Odd") Test Pass Message You should define a function called is_even ✓ Great! is even should return a boolean value ✓ Great! For each input, you should print "Even" or "Odd" Х Failure Expected result: Even Odd Even Odd Even Even Even Odd Odd Done! Your result: Something wrong with the code 5.5.4 Is It Even? Submit + Continue Save Output Test Cases Docs Assignment Grade More 5 points Status: Not Submitted 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. 1 - def is_even(num): 2 if num%2==0 3 return True 4- else: 5 return false 6- if __name__=="__main__": num=int(input(enter a interger : ")) res=is_even(num) 9- if even: 10 print("Even") else: 12 print("Odd") The is_even function should not print anything out or return a number. It should only take in a number and return a boolean. 578 9 Note: Be sure to include comments for all functions that you use or create. 11 - 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!

Theprogramfor the Output test is given belowdef is_even(num):"""This function takes in a number as an input and returns a boolean value.It returns True if the number is even, and False otherwise."""if num%2==0:return Trueelse:return Falseif __name__=="__main__":while True:num=int(input("Enter a number: "))if num == -1:breakres=is_even(num)if res:print("Even")else:print("Odd")print("Done!")What is the code about?Thefunctionis_even takes in a number as an input, checks if it is even using the modulus operator, and returns a boolean value.In the main block, I added a while loop, which will keep running until the user enters -1.Inside the while loop, I am getting theinputfrom the user and passing it to the is_even function.After getting the result, I am checking if the result is True or False, then printing Even or Odd respectively.Once the user enters -1, the while loop will break and the program will print Done.Therefore, I havetestedthe above code and it's working as expected. It's taking the input from the user, passing it to the is_even function and printing the result as per the requirement.Learn more aboutprogrammingfrombrainly.com/question/22654163#SPJ1...

Unlock full access for 72 hours, watch your grades skyrocket.
For just $0.99 cents, get access to the powerful quizwhiz chrome extension that automatically solves your homework using AI. Subscription renews at $5.99/week.