Write a function called check_values that has three parameters:
x
,y
, andz
. Every value passed to each of these parameters will be an integer. This function should returnTrue
if all three variables sum to a positive number or if at least two of the variables hold positive values. Otherwise this function should returnFalse
.
Below is my code:
def check_values(x, y, z):
if x+y+z >= 0:
return True
elif (x or y >=0) or (y or z >=0) or (x or z >= 0):
return True
else:
return False
x = int(input('Enter X value: '))
y = int(input('Enter Y value: '))
Z = int(input('Enter Z value: '))
I failed this assert check:
assert not check_values(1, -1, -1), "this should return False, not True (or any other value)"
How do I fix this? Also is there a better way to do the check "if at least two of the variables hold positive values"?