Question: Suppose that we want to write a function to test of a number is positive number or not. Lets name the function isPositive(n), which takes
Suppose that we want to write a function to test of a number is positive number or not. Lets name the function isPositive(n), which takes an integer as an argument and returns True if the argument is a positive number and False if it is negative or zero. Test the program by providing different inputs.
def isPositive(n):
if n > 0:
return True
else:
return False
number = float(input("Enter a number: "))
if is_positive(number):
print("That number is positive.")
else:
print("Definitely NOT positive.")
Now write a function to test of a number is an even number or not. Lets name the function isEven(n), which takes an integer as an argument and returns True if the argument is an even number and False if it is odd. Call the function to test if the number that the user input is an even number or an odd number.
# copy and paste your code here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
