Dictionary in Python
1.7M views on YouTube
Check out our courses:
Agentic AI Engineering with Python : https://go.telusko.com/agentic-ai-python
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : https://go.telusko.com/learn-master
Coupon: TELUSKO10 (10% Discount)
For More Queries WhatsApp or Call on : +919008963671
website : https://telusko.com/
Udemy Courses:
Java Spring:- https://go.telusko.com/Udemyjavaspring
Java:- https://go.telusko.com/udemyteluskojava
Spring: https://go.telusko.com/udemyteluskospring
Java For Programmers:- https://go.telusko.com/javaProgrammers
Python : https://go.telusko.com/udemyteluskopython
Git : https://go.telusko.com/udemyteluskogit
Docker : https://go.telusko.com/udemyteluskodocker
Instagram : https://www.instagram.com/navinreddyofficial/
Linkedin : https://in.linkedin.com/in/navinreddy20
WhatsApp : https://go.telusko.com/whatsapp
Discord : https://discord.gg/D8hWe9BqfF
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’]
Spring Full Course : https://courses.telusko.com/learn/Spring5?
Python for Beginners :- http://bit.ly/3JOLQhl
Rest API in Spring Boot : https://goo.gl/5Wgsk6
Restful Web Services Tutorial : https://goo.gl/3mosnz
Spring Boot Tutorials : https://goo.gl/7894NE
More Learning :
Java :- https://bit.ly/3x6rr0N
Python :- https://bit.ly/3GRc7JX
Django :- https://bit.ly/3MmoJK6
JavaScript :- https://bit.ly/3tiAlHo
Node JS :- https://bit.ly/3GT4liq
Rest Api :-https://bit.ly/3MjhZwt
Servlet :- https://bit.ly/3Q7eA7k
Spring Framework :- https://bit.ly/3xi7buh
Design Patterns in Java :- https://bit.ly/3MocXiq
Docker :- https://bit.ly/3xjWzLA
Blockchain Tutorial :- https://bit.ly/3NSbOkc
Corda Tutorial:- https://bit.ly/3thbUKa
Hyperledger Fabric :- https://bit.ly/38RZCRB
NoSQL Tutorial :- https://bit.ly/3aJpRuc
Mysql Tutorial :- https://bit.ly/3thpr4L
Data Structures using Java :- https://bit.ly/3MuJa7S
Git Tutorial :- https://bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
https://www.telusko.com