This function checks whether a given number is even or not def isEven(number): """ what it takes? a number what it does? determines if a number is even what it returns? if even, return 1 if odd, return -1 """   # your code goes in here defisEven(number):   #check if the number is divisible by 2 by checking the remainder. if number % 2==0: #If remainder is 0, then its divisble by 2 and an even number #hence return-1 return1 else: #if remainder is not 0, it'll be 1, so its NOT divisible by 2 and its an odd number #hence return -1 return-1     Test case for question 6  try: if isEven(5) == -1: score['question 6'] = 'pass' else: score['question 6'] = 'fail' except: score['question 6'] = 'fail'   isEven(5)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

Question 6 

# This function checks whether a given number is even or not

def isEven(number):

"""
what it takes?
a number

what it does?
determines if a number is even

what it returns?
if even, return 1
if odd, return -1
"""
 
# your code goes in here
defisEven(number):
 
#check if the number is divisible by 2 by checking the remainder.
if number % 2==0:
#If remainder is 0, then its divisble by 2 and an even number
#hence return-1
return1


else:


#if remainder is not 0, it'll be 1, so its NOT divisible by 2 and its an odd number
#hence return -1
return-1
 
 
Test case for question 6 
try:
if isEven(5) == -1:
score['question 6'] = 'pass'
else:
score['question 6'] = 'fail'
except:
score['question 6'] = 'fail'
 
isEven(5)
 
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning