AllInfoHub Logo

AllInfoHub – MCQ Practice

Data Types and Variables – Multiple Choice Questions (MCQs)

  1. 25. What will be the output of `print(len('你好'))` in Python 3?

    • A. 2
    • B. 3
    • C. 4
    • D. 6
  2. 26. What will be the output of `print(type(range(5)))`?

    • A. <class 'list'>
    • B. <class 'tuple'>
    • C. <class 'range'>
    • D. <class 'int'>
  3. 27. Which of the following is NOT a valid way to create a string literal in Python?

    • A. single quotes'
    • B. double quotes
    • C. "triple quotes"
    • D. ''triple single quotes'''
  4. 28. What is the output of `print(bool(' '))`?

    • A. TRUE
    • B. FALSE
    • C. Error
    • D. None
  5. 29. Which method is used to remove a specific element from a list by its value?

    • A. pop()
    • B. remove()
    • C. discard()
    • D. del()
  6. 30. Which of the following is the correct way to check if a key exists in a dictionary `my_dict`?

    • A. `'key' in my_dict`
    • B. `my_dict.has_key('key')`
    • C. `my_dict.contains('key')`
    • D. `my_dict['key'] is not None`
  7. 31. What will be the output of `print(type(b'hello'))`?

    • A. <class 'str'>
    • B. <class 'bytes'>
    • C. <class 'bytearray'>
    • D. <class 'list'>
  8. 32. Which of the following is a mutable sequence type in Python?

    • A. tuple
    • B. string
    • C. bytes
    • D. list
  9. 33. What is the output of `print(f'{10:b}')`?

    • A. 1010
    • B. 0b1010
    • C. 1010'
    • D. 0b1010'
  10. 34. Which method is used to remove the last element from a list?

    • A. pop()
    • B. remove()
    • C. delete()
    • D. clear()
  11. 35. What will be the output of `print(type(1))`?

    • A. <class 'int'>
    • B. <class 'float'>
    • C. <class 'str'>
    • D. <class 'bool'>
  12. 36. Which of the following is a valid way to access the last element of a list `my_list`?

    • A. `my_list[len(my_list) - 1]`
    • B. `my_list[-1]`
    • C. `my_list.last()`
    • D. Both A and B