In: Computer Science
ALL IN PYTHON PLEASE
Problem 3:
Define a VALUE-RETURNING function that accepts one parameter - an integer number. The function, which must be a value-returning function, returns 1 if the number is even or 0 if the number is odd. In the “main” function (i.e. def main()), capture the return value and print an appropriate message on screen (i.e. number is even or odd).
Rubric:
Correctly defined a value-returning function: 5 pts
Correctly capture and use return value from a value-returning function: 5 pts
Sample Output:
Enter n: 4
Even
def main(num): #function to find whether number is true or false
if num%2==0: #condition to check whether a number is divisible by 2 or not
return 1 #if divisible then the number is even number and returns 1
return 0 #if number is odd number then returns 0
#driver function
number = int(input("Enter n: ")) #taking input and int function convert string to integer
if main(number):
print("Even") #print if condition is true
else:
print("False") #print if condition is false
Output: