Repaso
EspaƱol
PythonFoundationsPY-63

What type is {"name": "Ana", "age": 30} in Python?

Options

  1. list: an ordered sequence of items
  2. dict: a collection of key-value pairs (Correct option)
  3. tuple: a fixed sequence of items
  4. str: a piece of text

Answer

dict (dictionary): key-value pairs

Why

Basic Python types:

  • int and float: numbers, like 30 and 3.5.
  • str: text, like "Ana".
  • bool: True or False.
  • list: ordered items that can change, like [1, 2, 3].
  • dict: key-value pairs inside curly braces. You read a value by its key: person["name"] gives "Ana".

Remember

{} with key: value pairs = dict.

Key terms

Practice this question in Repaso