PYTHON Data Types and Variables MCQs

  1. Which of the following is a valid Python data type?
    a) int
    b) float
    c) complex
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  2. What will be printed?
    1 x = "Eduinq"
    2 print(type(x))
    a) <class 'str'>
    b) <class 'list'>
    c) <class 'tuple'>
    d) <class 'dict'>
    View Answer

    Correct answer: A — <class 'str'>

  3. Which of the following is mutable?
    a) Tuple
    b) List
    c) String
    d) Frozenset
    View Answer

    Correct answer: B — List

  4. What is the output of print(type(3.14))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'decimal'>
    d) <class 'double'>
    View Answer

    Correct answer: B — <class 'float'>

  5. Which of the following is used to declare a complex number in Python?
    a) 3+4i
    b) 3+4j
    c) complex(3,4)
    d) Both B and C
    View Answer

    Correct answer: D — Both B and C

  6. Which of the following is immutable?
    a) List
    b) Set
    c) Tuple
    d) Dictionary
    View Answer

    Correct answer: C — Tuple

  7. What will be printed?
    1 a = [1,2,3]
    2 print(type(a))
    a) <class 'tuple'>
    b) <class 'list'>
    c) <class 'set'>
    d) <class 'dict'>
    View Answer

    Correct answer: B — <class 'list'>

  8. Which of the following is used to convert string to integer?
    a) str()
    b) int()
    c) float()
    d) eval()
    View Answer

    Correct answer: B — int()

  9. Which of the following is not a valid Python data type?
    a) array
    b) list
    c) tuple
    d) set
    View Answer

    Correct answer: A — array

  10. What will be printed?
    1 x = {"Eduinq":1, "Python":2}
    2 print(type(x))
    a) <class 'list'>
    b) <class 'dict'>
    c) <class 'set'>
    d) <class 'tuple'>
    View Answer

    Correct answer: B — <class 'dict'>

  11. Which of the following is used to declare a set in Python?
    a) {}
    b) set()
    c) Both A and B
    d) None of the above
    View Answer

    Correct answer: C — Both A and B

  12. What is the output of print(type(True))?
    a) <class 'int'>
    b) <class 'bool'>
    c) <class 'str'>
    d) <class 'float'>
    View Answer

    Correct answer: B — <class 'bool'>

  13. Which of the following is used to check type of variable?
    a) typeof()
    b) type()
    c) id()
    d) isinstance()
    View Answer

    Correct answer: B — type()

  14. What will be printed?
    1 x = (1,2,3)
    2 print(len(x))
    a) 2
    b) 3
    c) 4
    d) Error
    View Answer

    Correct answer: B — 3

  15. Which of the following is not mutable?
    a) List
    b) Set
    c) Tuple
    d) Dictionary
    View Answer

    Correct answer: C — Tuple

  16. What is the output of print(type(5))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'complex'>
    d) <class 'decimal'>
    View Answer

    Correct answer: A — <class 'int'>

  17. Which of the following is used to convert integer to string?
    a) str()
    b) int()
    c) float()
    d) eval()
    View Answer

    Correct answer: A — str()

  18. What will be printed?
    1 x = {"Eduinq", "Python", "MCQ"}
    2 print(type(x))
    a) <class 'list'>
    b) <class 'dict'>
    c) <class 'set'>
    d) <class 'tuple'>
    View Answer

    Correct answer: C — <class 'set'>

  19. Which of the following is used to declare dictionary?
    a) {}
    b) dict()
    c) Both A and B
    d) None of the above
    View Answer

    Correct answer: C — Both A and B

  20. What is the output of print(type(3+4j))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'complex'>
    d) <class 'double'>
    View Answer

    Correct answer: C — <class 'complex'>

  21. Which of the following is used to check if a variable is an instance of a class?
    a) type()
    b) isinstance()
    c) id()
    d) class()
    View Answer

    Correct answer: B — isinstance()

  22. What will be printed?
    1 x = [1,2,3]
    2 print(len(x))
    a) 2
    b) 3
    c) 4
    d) Error
    View Answer

    Correct answer: B — 3

  23. Which of the following is used to declare an empty dictionary?
    a) []
    b) {}
    c) dict()
    d) Both B and C
    View Answer

    Correct answer: D — Both B and C

  24. What is the output of print(type("Eduinq"))?
    a) <class 'str'>
    b) <class 'list'>
    c) <class 'tuple'>
    d) <class 'dict'>
    View Answer

    Correct answer: A — <class 'str'>

  25. Which of the following is mutable?
    a) Tuple
    b) List
    c) String
    d) Frozenset
    View Answer

    Correct answer: B — List

  26. What will be printed?
    1 x = (1,)
    2 print(type(x))
    a) <class 'int'>
    b) <class 'tuple'>
    c) <class 'list'>
    d) <class 'set'>
    View Answer

    Correct answer: B — <class 'tuple'>

  27. Which of the following is used to convert list to set?
    a) list()
    b) tuple()
    c) set()
    d) dict()
    View Answer

    Correct answer: C — set()

  28. What is the output of print(type(3))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'complex'>
    d) <class 'decimal'>
    View Answer

    Correct answer: A — <class 'int'>

  29. Which of the following is used to convert tuple to list?
    a) list()
    b) tuple()
    c) set()
    d) dict()
    View Answer

    Correct answer: A — list()

  30. What will be printed?
    1 x = {"Eduinq": "Python"}
    2 print(len(x))
    a) 0
    b) 1
    c) 2
    d) Error
    View Answer

    Correct answer: B — 1

  31. Which of the following is used to declare an empty set?
    a) {}
    b) set()
    c) []
    d) None
    View Answer

    Correct answer: B — set()

  32. What is the output of print(type([1,2,3]))?
    a) <class 'tuple'>
    b) <class 'list'>
    c) <class 'set'>
    d) <class 'dict'>
    View Answer

    Correct answer: B — <class 'list'>

  33. Which of the following is immutable?
    a) List
    b) Set
    c) Tuple
    d) Dictionary
    View Answer

    Correct answer: C — Tuple

  34. What will be printed?
    1 x = {"a":1, "b":2}
    2 print(type(x))
    a) <class 'list'>
    b) <class 'dict'>
    c) <class 'set'>
    d) <class 'tuple'>
    View Answer

    Correct answer: B — <class 'dict'>

  35. Which of the following is used to convert string to list?
    a) str()
    b) list()
    c) tuple()
    d) set()
    View Answer

    Correct answer: B — list()

  36. What is the output of print(type(3.0))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'complex'>
    d) <class 'decimal'>
    View Answer

    Correct answer: B — <class 'float'>

  37. Which of the following is used to convert list to tuple?
    a) list()
    b) tuple()
    c) set()
    d) dict()
    View Answer

    Correct answer: B — tuple()

  38. What will be printed?
    1 x = {"Eduinq", "Python"}
    2 print(len(x))
    a) 1
    b) 2
    c) 3
    d) Error
    View Answer

    Correct answer: B — 2

  39. Which of the following is used to declare an empty list?
    a) []
    b) list()
    c) Both A and B
    d) None of the above
    View Answer

    Correct answer: C — Both A and B

  40. What is the output of print(type(3+0j))?
    a) <class 'int'>
    b) <class 'float'>
    c) <class 'complex'>
    d) <class 'double'>
    View Answer

    Correct answer: C — <class 'complex'>

  41. Which of the following is used to convert dictionary keys to list?
    a) keys()
    b) list(dict.keys())
    c) Both A and B
    d) None
    View Answer

    Correct answer: B — list(dict.keys())

  42. What will be printed?
    1 x = "Eduinq"
    2 print(len(x))
    a) 5
    b) 6
    c) 7
    d) Error
    View Answer

    Correct answer: B — 6

  43. Which of the following is used to convert list to dictionary?
    a) dict()
    b) list()
    c) tuple()
    d) set()
    View Answer

    Correct answer: A — dict()

  44. What is the output of print(type([]))?
    a) <class 'tuple'>
    b) <class 'list'>
    c) <class 'set'>
    d) <class 'dict'>
    View Answer

    Correct answer: B — <class 'list'>

  45. Which of the following is immutable?
    a) List
    b) Set
    c) Tuple
    d) Dictionary
    View Answer

    Correct answer: C — Tuple

  46. What will be printed?
    1 x = {"Eduinq": "MCQ"}
    2 print(type(x))
    a) <class 'list'>
    b) <class 'dict'>
    c) <class 'set'>
    d) <class 'tuple'>
    View Answer

    Correct answer: B — <class 'dict'>

  47. Which of the following is used to convert set to list?
    a) list()
    b) tuple()
    c) set()
    d) dict()
    View Answer

    Correct answer: A — list()

  48. What is the output of print(type("Eduinq"))?
    a) <class 'str'>
    b) <class 'list'>
    c) <class 'tuple'>
    d) <class 'dict'>
    View Answer

    Correct answer: A — <class 'str'>

  49. Which of the following is used to convert list to string?
    a) str()
    b) join()
    c) Both A and B
    d) None
    View Answer

    Correct answer: B — join()

  50. What will be printed?
    1 x = (1,2,3,4)
    2 print(len(x))
    a) 3
    b) 4
    c) 5
    d) Error
    View Answer

    Correct answer: B — 4

Quick Links to Explore