# What will be the output of the following Python code def foo(): total += 1 return total total = 0 print(foo())

1.  0

2.  1

3.  error

4.  none of the mentioned

4

error

Explanation :
No Explanation available for this question

# What will be the output of the following Python code def foo(x): x = ['def', 'abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))

1.  True

2.  False

3.  None

4.  Error

4

False

Explanation :
No Explanation available for this question

# What will be the output of the following Python code def foo(i, x=[]): x.append(i) return x for i in range(3): print(foo(i))

1.  [0] [1] [2]

2.  [0] [0, 1] [0, 1, 2]

3.  [1] [2] [3]

4.  [1] [1, 2] [1, 2, 3]

4

[0] [0, 1] [0, 1, 2]

Explanation :
No Explanation available for this question

# Which of the following data structures is returned by the functions globals() and locals()

1.  list

2.  set

3.  dictionary

4.  tuple

4

dictionary

Explanation :
No Explanation available for this question

# What will be the output of the following Python code x=1 def cg(): global x x=x+1 cg() x

1.  2

2.  1

3.  0

4.  ERROR

4

2

Explanation :
No Explanation available for this question

# On assigning a value to a variable inside a function, it automatically becomes a global variable.

1.  True

2.  False

2

False

Explanation :
No Explanation available for this question

# What will be the output of the following Python code e="butter" def f(a): print(a)+e f("bitter")

1.  error

2.  buttererror

3.  bittererror

4.  bitterbutter

4

bitter
error

Explanation :
No Explanation available for this question

# What happens if a local variable exists with the same name as the global variable you want to access

1.  Error

2.  The local variable is shadowed

3.  Undefined behavior

4.  The global variable is shadowed

4

Explanation :
No Explanation available for this question

# What will be the output of the following Python code a=10 globals()['a']=25 print(a)

1.  10

2.  25

3.  Junk value

4.  Error

4

25

Explanation :
No Explanation available for this question

1.  Error

2.  4

3.  Junk value

4.  1

4