0 votes
in Python Flask by
What is a dictionary in Python?

1 Answer

0 votes
by

A python dictionary is something I have never seen in other languages like C++ or Java programming. It holds key-value pairs.

>>> roots={25:5,16:4,9:3,4:2,1:1}

>>> type(roots)

<class ‘dict’>

>>> roots[9]

3

A dictionary is mutable, and we can also use a comprehension to create it.

>>> roots={x**2😡 for x in range(5,0,-1)}

>>> roots

{25: 5, 16: 4, 9: 3, 4: 2, 1: 1}

Related questions

0 votes
asked Aug 30, 2020 in Python by sharadyadav1986
0 votes
asked Dec 19, 2019 in Python by sharadyadav1986
...