Skip to main content

Py: 8. Python Dictionary

Python Dictionary is used to store the data in a key-value pair format, whereas

  1. Keys must be a single element
  2. Value can be any type such as list, tuple, integer, etc.
Syntax:- 

Dict = {"Name": "Tom", "Age": 22}    

Example:- 
Employee = {"Name": "John", "Age": 29, "salary":25000,"Company":"GOOGLE"}  
print(type(Employee))  
print("printing Employee data .... ")  
print("Name :",Employee["Name"])  
print("Age : ", Employee["Age"])  
print("Salary :", Employee["salary"])  
print("Company :", Employee["Company"])  

Output:- 
<class 'dict'>
printing Employee data .... 
Name : John
Age :  29
Salary : 25000
Company : GOOGLE

Exercises:-

Comments