Dictionary in Python



Dictionary in Python

Dictionary in Python

In this lecture we are discussing about Dictionary:
— if you want to accessing the data by using key then we are using dictionary
— Dictionary uses key and value pair
key and value
in python
data={1:’Navin’,2:’kiran’,4:’Harsh’} # 1 is key and Navin is value and 2 is key and kiran is value and 4 is key and Harsh is value

property of dictionary:
— key must be immutable and unique
# immutable means we can’t change the value
# unique means we can’t repeat the key
— value can be anything
— we can access the value by using key
— we can’t access the value by using index
— we can’t access the value by using value

fetching the value from dictionary
data[4] # we can access the value by using key here key is 4
data[3] # you get error because key is not present in dictionary

get() method:
— we can access the value by using get() method
— if key is present in dictionary then it will return the value
— if key is not present in dictionary then it will return None
data.get(1)
data.get(3) # not get anything
print(data.get(3)) # it will return None
data.get(1,’Not Found’)
data.get(3,’Not Found’)

use of zip() method:
— we can combine the two list by using zip() method
— it will return the tuple
keys = [‘Navin’,’Kiran’,’Harsh’]
values=[‘Python’,’Java’,’JS’]

use of dict() method:
— we can convert the tuple into dictionary by using dict() method
data=dict(zip(keys,values))
data[‘Kiran’]
data[‘Monika’] # it will give error because key is not present in dictionary

add the value in dictionary:
data[‘Monika’]=’CS’
data

delete the value from dictionary:
del data[‘Harsh’]

Nested Dictionary:
— we can store the dictionary inside the dictionary
prog={‘JS’:’Atom’,’CS’:’VS’,’Python’:[‘Pycharm’,’Sublime’],’Java’:{‘JSE’:’Netbeans’,’JEE’:’Eclipse’}}
prog
prog[‘JS’]
prog[‘python’][1]
prog[‘Java’]
prog[‘Java’][‘JEE’]

Support by
becoming a Member : https://www.youtube.com/channel/UC59K-uG2A5ogwIrHw4bmlEg/join
Instamojo (India) : https://www.instamojo.com/@NavinReddy/
Paypal : https://www.paypal.me/navinreddy20
UPI : navinreddy20@okicici

Spring Full Course : https://courses.telusko.com/learn/Spring5?

Python for Beginners :- http://bit.ly/3JOLQhl

Java:- https://bit.ly/JavaUdemyTelusko

Spring:- https://bit.ly/SpringUdemyTelusko

Rest API in Spring Boot : https://goo.gl/5Wgsk6
Restful Web Services Tutorial : https://goo.gl/3mosnz
Spring Boot Tutorials : https://goo.gl/7894NE

Editing Monitors :
https://amzn.to/2RfKWgL
https://amzn.to/2Q665JW
https://amzn.to/2OUP21a.

Editing Laptop :
ASUS ROG Strix – (new version) https://amzn.to/2RhumwO
Asus vivoBook :https://amzn.to/2wS0Hpt

Camera : https://amzn.to/2OR56AV
lens : https://amzn.to/2JihtQo

Mics
https://amzn.to/2RlIe9F
https://amzn.to/2yDkx5F
https://amzn.to/2WYqLde

Check out our website: http://courses.telusko.com

Follow Telusko on Twitter: https://twitter.com/navinreddy20

Follow on Facebook:
Telusko : https://www.facebook.com/teluskolearnings
Navin Reddy : https://www.facebook.com/navintelusko

Follow Navin Reddy on Instagram: https://www.instagram.com/navinreddy20
Follow Telusko Official Page : https://www.instagram.com/telusko_edutech

Subscribe to our other channel:
Navin Reddy : https://www.youtube.com/channel/UCxmkk8bMSOF-UBF43z-pdGQ
Telusko Hindi :
https://www.youtube.com/channel/UCitzw4ROeTVGRRLnCPws-cw

More Learning :

Python for Beginners :- https://bit.ly/3x2g23h
Django Tutorial for Beginners :- https://bit.ly/3GyNqS6

JavaScript Tutorial for Beginners :- https://bit.ly/3NGR3ba
Node JS Tutorial for Beginners:- https://bit.ly/3N82IQy

Java Tutorial For Beginners :- https://bit.ly/3z8HWfq
Rest Api | Restful Web Service :-https://bit.ly/3axANLo
Servlet and JSP Tutorial for Beginners :- https://bit.ly/3M0FhqH
Spring Framework with Maven Tutorial :- https://bit.ly/3LWByL3
Design Patterns in Java :- https://bit.ly/3a9VjSa
Docker Basics:- https://bit.ly/38DNLqo

Blockchain Tutorial for Beginners :- https://bit.ly/3x33f0z
The Web3 Show:- https://bit.ly/3M4znF0
Corda Tutorial:- https://bit.ly/3Q2Zwrg
Hyperledger Fabric :- https://bit.ly/3PMFJfD

NoSQL Tutorial for Beginners :- https://bit.ly/3m03Ycq
Sql Tutorial for Beginners :- https://bit.ly/3GyWWEU
Mysql Tutorial :- https://bit.ly/3M4C6OK

Data Structures using Java :- https://bit.ly/3t5HPNY
Data Structures using C :- https://bit.ly/3GBLoAE
Kotlin Tutorial:- https://bit.ly/3x1kOfV
Git Tutorial for Beginners:- https://bit.ly/3NMbmUw
C Programming Tutorial :- https://bit.ly/3x4bA45

Comments are closed.