Python Data Types u0026 Type Conversion Challenge Quiz

Test your understanding of Python's core data types and the subtle complexities of type conversion. Each question is designed to probe your grasp of advanced topics like mutability, nesting, type casting behavior, and the nuances between similar data structures.

  1. Immutable vs Mutable Types

    Which Python data type is immutable and cannot be changed once created, even if it contains other mutable objects?

    1. Tuple
    2. Set
    3. Array
    4. List
    5. Dictionary
  2. Numeric Type Conversion

    What is the result of evaluating float(int('17.3')) in Python?

    1. 17,3
    2. 17.3
    3. Error
    4. 17.0
    5. 17
  3. String to Boolean Conversion

    What is the bool value of the string 'False' when converted using bool('False') in Python?

    1. None
    2. 0
    3. Error
    4. False
    5. True
  4. Set Creation with Strings

    What is the result of set('yyzz') in Python?

    1. {'yy', 'zz'}
    2. {'z', 'yy'}
    3. {'y', 'z', 'yyzz'}
    4. ['y', 'z']
    5. {'y', 'z'}
  5. List Comprehension u0026 Type

    Given lst = [str(i) for i in range(2)]; what is the type of lst[0]?

    1. tuple
    2. str
    3. list
    4. bool
    5. int
  6. Tuple Packing and Unpacking

    After executing x, y = (3, 'hi'), what are the types of x and y respectively?

    1. int, tuple
    2. list, str
    3. str, int
    4. int, str
    5. tuple, tuple
  7. Dictionary Key Requirements

    Which of the following can NOT be used as a dictionary key in Python?

    1. None
    2. ['a', 'b']
    3. 42
    4. False
    5. ('a', 'b')
  8. Type Casting with Complex Numbers

    What happens if you attempt int(2+3j) in Python?

    1. Returns 2+3j
    2. Returns 2
    3. Raises TypeError
    4. Raises ValueError
    5. Returns 5
  9. Boolean Arithmetic

    What is the value and type of True + False in Python?

    1. 1, int
    2. 2, int
    3. 1, bool
    4. False, bool
    5. True, bool
  10. Nested Data Structures

    What is the type of the object returned by {'a': [1, 2, 3]}['a']?

    1. list
    2. dict
    3. tuple
    4. str
    5. set
  11. Set Comprehension

    What is the result of {i // 2 for i in [1, 2, 3, 4]} in Python?

    1. [0, 1, 2]
    2. {2, 3, 4}
    3. {0, 1}
    4. {0, 1, 2}
    5. {1, 2, 3}
  12. String to Integer Base Conversion

    What does int('1010', 2) evaluate to in Python?

    1. 1010
    2. 8
    3. 10
    4. Error
    5. 2
  13. Identity vs Equality

    Given a = [1, 2] and b = [1, 2], which of the following is True?

    1. a is b
    2. a == b and a is b are both True
    3. a == b is False, a is b is True
    4. a == b is True, a is b is False
    5. a == b is False, a is b is False
  14. Dictionary View Objects

    After d = {'x':1, 'y':2}, what is the type of d.keys()?

    1. dict_values
    2. list
    3. dict_keys
    4. set
    5. tuple
  15. List Slicing and Type

    What is the type of [123][0:1] in Python?

    1. tuple
    2. int
    3. dict
    4. list
    5. str