AllInfoHub Logo

AllInfoHub – MCQ Practice

Basics of Python – Multiple Choice Questions (MCQs)

  1. 61. What is the purpose of the `in` operator in Python?

    • A. To check if a value exists in a sequence
    • B. To perform mathematical operations
    • C. To define a loop
    • D. To define a function
  2. 62. What is the output of `print(3 in [1, 2, 3])`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  3. 63. What is the output of `print('a' in 'banana')`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  4. 64. What is the output of `print('key' in {'key': 1, 'value': 2})`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  5. 65. What is the purpose of the `not in` operator in Python?

    • A. To check if a value does not exist in a sequence
    • B. To negate a boolean value
    • C. To perform bitwise operations
    • D. To define a conditional statement
  6. 66. What is the output of `print(4 not in [1, 2, 3])`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  7. 67. What is the output of `print('z' not in 'banana')`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  8. 68. What is the output of `print('code' not in {'key': 'code', 'value': 2})`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  9. 69. What is the purpose of the `isinstance()` function in Python?

    • A. To check if a variable is defined
    • B. To check if a variable is of a certain data type
    • C. To convert a variable to a different data type
    • D. To find the type of a variable
  10. 70. What is the output of `print(isinstance(5, int))`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  11. 71. What is the output of `print(isinstance(5.0, float))`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  12. 72. What is the output of `print(isinstance('hello', str))`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None