We have listed here some multiple choice questions with answer for Python Script, Which has asked by multiple companies like McAfee, Calsoft, Infotech, Capgemini, SAP etc.

You can prepare your job written and interview by using these sets of question fro here.

1. Where is function defined?
a) Module
b) Class
c) Another function
d) All of the mentioned

Answer: d

2. Which of the following is the use of id() function in python?
a) Id returns the identity of the object
b) Every object doesn’t have a unique id
c) All of the mentioned
d) None of the mentioned

Answer: a

3. Python supports the creation of anonymous functions at runtime, using a construct called __________
a) Lambda
b) pi
c) anonymous
d) None of the mentioned

Answer: a

4. What is the output of below program?
lamb = lambda x: x ** 3
print(lamb(5))
a) 15
b) 555
c) 125
d) None of the mentioned

Answer: c

5. Lambda contains block of statements
a) True
b) False

Answer: b

6. What is the output of this program?
min = (lambda x, y: x if x < y else y)
min(101*99, 102*98)
a) 9997
b) 9999
c) 9996
d) None of the mentioned

Answer: c

7. What is a variable defined outside a function referred to as?
a) A static variable
b) A global variable
c) A local variable
d) An automatic variable

Answer: b

8. What is a variable defined inside a function referred to as?
a) A global variable
b) A volatile variable
c) A local variable
d) An automatic variable

Answer: c

9. What is the output of the following code?
def change(one, *two):
print(type(two))
change(1,2,3,4)
a) Integer
b) Tuple
c) Dictionary
d) An exception is thrown

Answer: b

10. If a function doesn’t have a return statement, which of the following does the function return?
a) int
b) null
c) None
d) An exception is thrown without the return statement

Answer: c

11. What is the type of each element in sys.argv?
a) set
b) list
c) tuple
d) string

Answer: d

12. How are keyword arguments specified in the function heading?
a) one star followed by a valid identifier
b) one underscore followed by a valid identifier
c) two stars followed by a valid identifier
d) two underscores followed by a valid identifier

Answer: c

13. How many keyword arguments can be passed to a function in a single function call?
a) zero
b) one
c) zero or more
d) one or more

Answer: c

14. How are variable length arguments specified in the function heading?
a) one star followed by a valid identifier
b) one underscore followed by a valid identifier
c) two stars followed by a valid identifier
d) two underscores followed by a valid identifier

Answer: a

15. Which module in the python standard library parses options received from the command line?
a) getopt
b) os
c) getarg
d) main

Answer: a

16. Which of the following data structures is returned by the functions globals() and locals()?
a) list
b) set
c) dictionary
d) tuple

Answer: c

17. What happens if a local variable exists with the same name as the global variable you want to access?
a) Error
b) The local variable is shadowed
c) Undefined behavior
d) The global variable is shadowed

Answer: d

18. Which is the most appropriate definition for recursion?
a) A function that calls itself
b) A function execution instance that calls another execution instance of the same function
c) A class method that calls another class method
d) An in-built method that is automatically called

Answer: b

19. Which of these is false about recursion?
a) Recursive function can be replaced by a non-recursive function
b) Recursive functions usually take more memory space than non-recursive function
c) Recursive functions run faster than non-recursive function
d) Recursion makes programs easier to understand

Answer: c

20. What is tail recursion?
a) A recursive function that has two base cases
b) A function where the recursive functions leads to an infinite loop
c) A recursive function where the function doesn’t return anything and just prints the values
d) A function where the recursive call is the last thing executed by the function

Answer: d

21. What happens if the base condition isn’t defined in recursive programs?
a) Program gets into an infinite loop
b) Program runs once
c) Program runs n number of times where n is the argument given to the function
d) An exception is thrown

Answer: a

22. What is the output of the code shown below?
f=lambda x:bool(x%2)
print(f(20), f(21))
a) False True
b) False False
c) True True
d) True False

Answer: a

23. What is the output of the code shown?
m=reduce(lambda x: x-3 in range(4, 10))
print(list(m))
a) [1, 2, 3, 4, 5, 6, 7]
b) No output
c) [1, 2, 3, 4, 5, 6]
d) Error

Answer: b

24. What is the output of the line of code shown below?
list(map((lambda x:x^2), range(10)))
a) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
b) Error
c) [2, 3, 0, 1, 6, 7, 4, 5, 10, 11]
d) No output

Answer: c

25. What is the output of the following?
x = [‘ab’, ‘cd’]
print(len(map(list, x)))
a) [2, 2].
b) 2
c) 4
d) none of the mentioned

Answer: d