Python Dictionaries

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

# Dictionary in Python
#myd={101:'CSE',102:'IT',103:'Civi',104:'MBA',105:'Account',102:'ITDept'}
# myd={101:'CSE',102:'IT',103:'Civi',104:'MBA',105:'Account'}
# print(myd.keys())
# print("----------------------------------")
# print(myd.values())
# print("----------------------------------")
# print(myd.items())

#print(len(myd))

# print("Before Pop: ")
# print(myd)

# myd.popitem()

# print("After Pop: ")
# print(myd)
# print("Before Pop: ")
# print(myd)
# myd.pop(2)
# print("After Pop: ")
# print(myd)

# myd.update({106:'Sales'})
# print(myd.items())
# myd1=myd.copy()
# print(myd1)
#print(type(myd1))
#myd.clear()
#print(myd.keys())
# mykey=myd.keys()
# print(mykey)
#print(myd.items())
#print(type(myd))
#print(myd)
# for x in myd:
#     print(x,end=":")
#     print(myd.get(x))

# x={101,102,103} 
# y={0}
# mynewd=dict.fromkeys(x,y)
# print(mynewd)

 

Did you like this article? If Yes, please give DataFlair 5 Stars on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *