In Python programming language, a dictionary is a collection of an unordered collection of data values in the form of key-value pair.
dict() function
The dict() function is a built-in function in Python, it is used to create a dictionary.
Syntax:
dict(key:value pair1, key:value pair2, ...)
1) Creating an empty dictionary using dict() function
To create an empty dictionary, dict() function without augments can be used.
Syntax:
Program:
Output:
2) Creating a dictionary with key-value pairs using dict() function
The dict() function is used to create a dictionary by passing the key-value pairs.
Syntax:
Program:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer