def pos_neg(a,b,negative):
a_neg = a < 0
b_neg = b < 0
if negative:
return a_neg and b_neg # return True if both numbers are less than zero, otherwise False
else:
return a_neg ^ b_neg # returns True if *exactly* one of the numbers is less than zero, otherwise False
"false"
是一个字符串。False
是一个布尔值那么,你为什么要查假的?你知道吗
不管怎样,你可以使用布尔逻辑来使用布尔逻辑。你知道吗
试试这个
如果正好有一个数字小于零,则返回True,除非布尔参数为True。
在这种情况下,[负==真]只有当两个数字都小于零时才返回真。
如果不返回True,则返回False。你知道吗
将打印:
相关问题 更多 >
编程相关推荐