What happens when you use another function as the argument for the print() function? [duplicate]

Solution 1:

It's quite simple

print(test())

is equivalent to

result = test()
print(result)

The first line calls the test function (which prints 'hi' in its body) and assigns the name result to the return value, which coincidally is also 'hi'.

The second line prints the value returned by test.