Which of the following data types can be used as keys in dictionaries in Python? Select all that apply
Explanation
Only so called hashable objects can be used as dictionary keys in Python. But which object is hashable then?
Many people mistakenly say that only immutable data types are hashable. But it is not entirely correct. Object is hashable if hash() function returns the same value for it throughout the program execution.
Among provided answers - String and Integer are hashable. Immutable data types are subset of all hashable types in Python.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Python
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты