Python Data Types and Type Conversion Essentials Quiz

  1. Identifying Integer Type

    What data type will result from the expression type(42) in Python?

    1. long
    2. boolean
    3. str
    4. int
    5. float
  2. Float Conversion

    If you execute float('3.14'), what type is returned in Python?

    1. bool
    2. tuple
    3. int
    4. float
    5. string
  3. Type Casting to String

    What happens when str(123) is executed in Python?

    1. True
    2. 123.0
    3. {1:2, 3:4}
    4. '123'
    5. [1, 2, 3]
  4. Boolean Evaluation of Zero

    What is the result of bool(0) in Python?

    1. 0.0
    2. None
    3. False
    4. 'False'
    5. True
  5. Tuple Identification

    Given the variable t = (1, 2, 3), what type is t in Python?

    1. set
    2. list
    3. tuple
    4. range
    5. dictionary
  6. List Creation

    Which of the following expressions creates a list containing the numbers 1, 2, and 3?

    1. (1, 2, 3)
    2. 1, 2, 3
    3. {1:2, 3:4}
    4. [1, 2, 3]
    5. {1, 2, 3}
  7. Set Uniqueness

    What is the main characteristic of a Python set, such as set([1, 2, 2, 3])?

    1. It is immutable
    2. It allows duplicate keys
    3. It is a sequence
    4. It only contains unique elements
    5. It maintains order
  8. Dictionary Structure

    If d = {'a': 1, 'b': 2}, what data type is d in Python?

    1. array
    2. list
    3. tuple
    4. dict
    5. set
  9. Boolean Conversion from String

    What does bool('False') evaluate to in Python?

    1. TypeError
    2. False
    3. 0
    4. True
    5. None
  10. Immutability of Tuples

    Which statement describes tuples in Python, such as (1, 2, 3)?

    1. They are mutable
    2. They are immutable
    3. They are unordered
    4. They are key-value pairs
    5. They contain only strings
  11. Converting List to Set

    What is the result of set([1, 2, 2, 4]) in Python?

    1. [1, 2, 2, 4]
    2. {1, 2, 4}
    3. {1:2, 2:2, 4:4}
    4. '1, 2, 2, 4'
    5. (1, 2, 2, 4)
  12. List Concatenation

    Which of the following is valid for concatenating two Python lists a = [1, 2] and b = [3, 4]?

    1. a | b
    2. a + b
    3. a - b
    4. a * b
    5. a u0026 b
  13. int() with Float Value

    What is the value of int(3.9) in Python?

    1. '3.9'
    2. 3
    3. 3.9
    4. 4
    5. Error
  14. Accessing Dictionary Values

    With data = {'apple': 5, 'banana': 8}, what is the result of data['banana']?

    1. None
    2. 8
    3. 'banana'
    4. Error
    5. 5
  15. Type Checking

    What will type([1, 'two', 3.0]) return in Python?

    1. tuple
    2. list
    3. dict
    4. array
    5. set
  16. String to Integer Conversion

    Which expression safely converts the string '10' to the integer 10 in Python?

    1. str('10')
    2. int('10')
    3. float('10')
    4. bool('10')
    5. set('10')