
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Define Dictionary in Python
Dictionary object is an unordered collection of key-value pairs, separated by comma and enclosed in curly brackets. Association of value with key is marked by : symbol between them.
>>> D1={'a':1,'b':2,'c':3}
Key can appear in a dictionary object only once, whereas single value can be assigned to multiple keys. Key should be of immutable data type i.e. number, string or tuple.
>>> D2={1:'aaa', 2:'bbb', 3:'ccc'} >>> D3={(10,10):'x1', (20,20):'x2'} >>> D4={'Microsoft':['MS Office', 'Windows', 'C#'], 'Oracle':['Oracle', 'Java', 'MySQL']}
Advertisements