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?

1 Answers1

1

Normally evaluating square(2) would result in the console displaying 4.

No. Normally evaluating square(2) should return 4 and should not display anything.

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

Will show no output at all.

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

Will output the result of square(2) which is 4.

Hyperboreus
  • 31,997
  • 9
  • 47
  • 87