Loading, please wait...

Python Multiple Choice Questions And Answers

Search here for MCQs

Are you preparing for the next job interviews? If yes, trust me this post will help you also we'll suggest you check out a big collection for Programming Full Forms that may help you in your interview:

List of Programming Full Forms 

16. What will be the output of the following Python code and state the type of copy that is depicted?

l1=[2, 4, 6, 8] l2=[1, 2, 3] l1=l2 l2 The code shown above depicts shallow copy and the output of the code is: [1, 2, 3].
  • [2, 4, 6, 8], shallow copy
  • [2, 4, 6, 8], deep copy
  • [1, 2, 3], shallow copy
  • [1, 2, 3], deep copy

17. What will be the output?

ef fact(num): if num == 0: return 1 else: return _____________________ Suppose n=5 then, 5*4*3*2*1 is returned which is the factorial of 5.
  • num*fact(num-1)
  • (num-1)*(num-2)
  • num*(num-1)
  • fact(num)*fact(num-1)

18. What will be the output

def f1(x): global x x+=1 print(x) f1(15) print("hello") The code shown above will result in an error because ‘x’ is a global variable. Had it been a local variable, the output would be: 16
  • error
  • hello
  • 16 hello

19. What will be the output of the following Python code?

def f1(a,b=[]):
   b.append(a)
   return b

print(f1(2,[3,4]))

In the code shown above, the integer 2 is appended to the list [3,4]. Hence the output of the code is [3,4,2]. Both the variables a and b are local variables.

  • [3,2,4]
  • [2,3,4]
  • Error
  • [3,4,2]

20. Program code making use of a given module is called a ______ of the module.

Program code making use of a given module is called the client of the module. There may be multiple clients for a module.
  • Client
  • Docstring
  • Interface
  • Modularity