Skip to main content
 首页 » 编程设计

Python 返回 True 或 False

2025年05月04日14zdz8207

<分区>

我不相信我设置正确...因为无论我为 foo() 填写什么数字,它似乎总是返回“True”。我做错了什么??

# Complete the following function. 
# Returns True if x * y / z is odd, False otherwise. 
 
def foo(x, y, z): 
    answer = True 
    product = (x * y) / z 
    if (product%2) == 0: 
        answer = False 
    return answer 
 
print(foo(1,2,3))