Home / Expert Answers / Computer Science / python-a-variable-defined-inside-a-function-is-a-local-variable-otherwise-it-is-a-global-variab-pa287

(Solved): (Python) A variable defined inside a function is a local variable; otherwise, it is a global variab ...



(Python)

A variable defined inside a function is a local variable; otherwise, it is a global variable.

If a local variable has the same name as a global variable, the local variable is used inside the function.

What does this print?

def myFunc1 ():

one = -1

print (one, two)

one = 1

two = 2

print (one, two)

myFunc1 ()

print (one two)



We have an Answer from Expert

View Expert Answer

Expert Answer


There is a syntax error in the last line of the code provided.Assuming that the last line is intended to print the values of the variables one and two
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe