Please Select a Company.
Please Select a Company.
Python MCQ Questions | Interview Quick

.

Python MCQ

1. What is an abstract class?

2. What happens when you use the build-in function any() on a list?

3. What data structure does a binary tree degenerate to if it isn't balanced properly?

4. What statement about static methods is true?

5. What are attributes?

6. What built-in list method would you use to remove items from a list?

7. What is one of the most common use of Python's sys library?

8. What is the runtime of accessing a value in a dictionary by using its key?

9. . What is the correct syntax for defining a class called Game, if it inherits from a parent class called LogicGame?

10. . What is the correct way to write a doctest?

11. What built-in Python data type is commonly used to represent a stack?

12. What is the purpose of the "self" keyword when defining or calling instance methods?

13. Which of these is NOT a characteristic of namedtuples?

14. What is an instance method?

15. Which statement does NOT describe the object-oriented programming concept of encapsulation?

16. What is the purpose of an if/else statement?

17. What built-in Python data type is best suited for implementing a queue?

18. What is the correct syntax for instantiating a new object of the type Game?

19. What does the built-in map() function do?

20. If you don't explicitly return a value from a function, what happens?

21. What is the purpose of the pass statement in Python?

22. What is the term used to describe items that may be passed into a function?

23. Which collection type is used to associate values with unique keys?

24. When does a for loop stop iterating?

25. Assuming the node is in a singly linked list, what is the runtime complexity of searching for a specific node within a singly linked list?

26. What happens when you use the built-in function all() on a list?

27. What is the algorithmic paradigm of quick sort?

28. What is runtime complexity of the list's built-in .append() method?

29. What is key difference between a set and a list?

30. What is the definition of abstraction as applied to object-oriented Python?

31. Pick correct representation of doctest for function in Python.

32. Suppose a Game class inherits from two parent classes: BoardGame and LogicGame. Which statement is true about the methods of an object instantiated from the Game class?

33. What does calling namedtuple on a collection type return?

34. What symbol(s) do you use to assess equality between two elements?

35. What does a class's __init__() method do?

36. What is meant by the phrase "space complexity"?

37. What is the correct syntax for creating a variable that is bound to a dictionary?

38. What is the purpose of the self keyword when defining or calling methods on an instance of an object?

39. What statement about the class methods is true?

40. What does it mean for a function to have linear runtime?

41. What is the proper way to define a function?

42. According to the PEP 8 coding style guidelines, how should constant values be named in Python?

43. Describe the functionality of a deque.

44. What is the correct syntax for creating a variable that is bound to a set?

45. What is the correct syntax for defining an __init__() method that takes no parameters?

46. Which of the following is TRUE About how numeric data would be organised in a Binary Search Tree?

47. Why would you use a decorator?

48. When would you use a for loop?

49. What is the most self-descriptive way to define a function that calculates sales tax on a purchase?

50. What would happen if you did not alter the state of the element that an algorithm is operating on recursively?

51. What is the runtime complexity of searching for an item in a binary search tree?

52. Why would you use mixin?

53. What is the runtime complexity of adding an item to a stack and removing an item from a stack?

54. Which statement accurately describes how items are added to and removed from a stack?

55. What is a base case in a recursive function?

56. Why is it considered good practice to open a file from within a Python script by using the with keyword?

57. Why would you use a virtual environment?

58. What is the correct way to run all the doctests in a given file from the command line?

59. What is a lambda function ?

60. What is the primary difference between lists and tuples?

61. What does a generator return?

62. What is the difference between class attributes and instance attributes?

63. What is the correct syntax of creating an instance method?

64. What is the correct way to call a function?

65. How is comment created?

66. What will happen if you use a while loop and forget to include logic that eventually causes the while loop to stop?

67. Describe the functionality of a queue?

68. Which choice is the most syntactically correct example of the conditional branching?

69. How does defaultdict work?

70. What is the correct syntax for adding a key called variety to the fruit_info dictionary that has a value of Red Delicious?

71. When would you use a while loop?

72. What is the correct syntax for defining an __init__() method that sets instance-specific attributes upon creation of a new class instance?

73. In Python, when using sets, you use _ to calculate the intersection between two sets and _ to calculate the union.

74. You encounter a FileNotFoundException while using just the filename in the open function. What might be the easiest solution?

75. What does the // operator in Python 3 allow you to do?

76. What file is imported to use dates in python?

77. What is the correct syntax for defining a class called Game?

78. What is the correct syntax for calling an instance method on a class named Game?

79. Elements surrounded by [] are _, {} are _, and () are _.

80. Which syntax correctly creates a variable that is bound to a tuple?

81. Which mode is not a valid way to access a file from within a Python script?

82. NumPy allows you to multiply two arrays without a for loop. This is an example of _.

83. What built-in Python data type can be used as a hash table?

84. Which Python function allows you to execute Linux shell commands in Python?

85. When an array is large, NumPy will not print the entire array when given the built-in print function. What function can you use within NumPy to force it to print the entire array?

86. When would you use a try/except block in code?

87. In Python, how can the compiler identify the inner block of a for loop?

88. What Python mechanism is best suited for telling a user they are using a deprecated function

89. Given that NumPy is imported as np, which choice will return True?

90. How do you add a comment to existing Python script?

91. What two functions within the NumPy library could you use to solve a system of linear equations?

92. What is the correct syntax for creating a variable that is bound to a list?

93. What are the two main data structures in the Pandas library?

94. Suppose you have a variale named vector of type np.array with 10,000 elements. How can you turn vector into a variable named matrix with dimensions 100x100?

95. Which choice is an immutable data type?

96. Choose the option below for which instance of the class cannot be created

97. Which choice is not a native numerical type in Python?

98. Given a list defined as numbers = [1,2,3,4], what is the value of numbers[-2]?

99. Which statement about strings in Python is true?

100. What is the correct syntax for defining an init() method that takes no parameters?

101. Suppose you need to use the sin function from the math library. What is the correct syntax for importing only that function?

102. What do you get if you apply numpy.sum() to a list that contains only Boolean values?

103. If you do not explicitly return a value from a function, what happens?

104. it is often the case that the pandas library is used for _ data and NumPy for _ data.

105. What do you need to do to install additional packages into Python?

106. When using NumPy in Python, how do you check the dimensionality (number and length of dimensions) of an object called my_object?

107. Assume you have a non-empty list named mylist and you want to search for a specific value. The minimum number of comparison will be __ and the maximum number of comparison will be _?

108. If a function does not have a return statement, what does it really return?

109. What is a common use of python's sys library?

110. In Python, a class method must have __ as a function decorator, and the first parameter of the method will be a reference to __.

111. Which snippet of code will print My name is Joffrey, son of Robert?

112. Suppose you have a variable named vector of type np.array with 10.000 elements. How can you turn vector into a variable named matrix with dimensions 100x100?

113. What is the maximum length of a Python identifier?

114. f-strings are also called:

115. How many CPUs (or cores) will the Python threading library take advantage of simultaneously?

116. The process of pickling in Python includes?

117. Is list mutable in python ?

118. Who created the Python programming language?

119. Which collection is ordered, changeable, and allows duplicate members?

120. Which comparison of lists and tuples in Python is correct?

121. Which of the following statements defines a new object type named "Dog" in Python?

122. To use pipelines in scikit-learn, import from the scikit-learn._ submodule.

Our Brands by Nishtya Infotech Private Limited:

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as