# Function and Code [duplicate]

Is it allowed to have an answer which has some code outside of a function? For example, in Python, if you were to get the sum of two square roots, would this be allowed:

import math
R=math.sqrt
def f(x,y):
return R(x)+R(y)


or would it have to be this:

def f(x,y):
import math
R=math.sqrt
return R(x)+R(y)


or maybe this:

import math
def f(x,y):
R=math.sqrt
return R(x)+R(y)