0

I'm using the Mac program CodeRunner to test some Python code. However, when I return values through functions, the console does not show these values.

ex:

def square(x):
    return x**2

Normally evaluating square(2) would result in the console displaying 4. However, nothing appears in CodeRunner. Is this a flaw in the program or is there something I'm missing?

4

1 回答 1

1

通常评估 square(2) 会导致控制台显示 4。

不。通常评估square(2)应该返回4并且不应该显示任何内容。

def square(x):
    return x**2
square(2)

根本不会显示任何输出。

def square(x):
    return x**2
print(square(2))

将输出结果square(2)4.

于 2013-10-12T08:19:30.290 回答