# What will be the output of the following Python code def f(p, q, r): global s p = 10 q = 20 r = 30 s = 40 print(p,q,r,s) p,q,r,s = 1,2,3,4 f(5,10,15)

1.  1 2 3 4

2.  5 10 15 4

3.  10 20 30 40

4.  5 10 15 40

4

10 20 30 40

Explanation :
No Explanation available for this question

# What will be the output of the following Python code def f(x): print("outer") def f1(a): print("inner") print(a,x) f(3) f1(1)

1.  outererror

2.  inner error

3.  outerinner

4.  error

4

outer
error

Explanation :
No Explanation available for this question

# What will be the output of the following Python code x = 5 def f1(): global x x = 4 def f2(a,b): global x return a+b+x f1() total = f2(1,2) print(total)

1.  Error

2.  7

3.  8

4.  15

4

7

Explanation :
No Explanation available for this question

# What will be the output of the following Python code x=100 def f1(): global x x=90 def f2(): global x x=80 print(x)

1.  100

2.  90

3.  80

4.  ERROR

4

100

Explanation :
No Explanation available for this question

# Read the following Python code carefully and point out the global variables y, z = 1, 2 def f(): global x x = y+z

1.  x

2.  y and z

3.  x, y and z

4.  Neither x, nor y, nor z

4

x, y and z

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