Dictionary in Python

#----------------------------- 1- Creating a Dictionary ------------------------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}
print(company)
#----------------------------- 2- Modifying a Dictionary -----------------------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}

company["age"] = 26  # updating age to 26

print(company)
#----------------------------- 3- Adding and Dleting Dictionary ----------------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}

#adding key-value pair
company["city"] = "Madurai"
print(company)

# Deleting a key-value pair
del company["grade"] #deleting the key- value pair with key = "grade"
print(company)
#----------------------------- 4- Iterating through Dictionary -----------------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}

# Iterating through keys
print("\nKeys\n")
for key in company:
    print(key)

# Iterating through values
print("\nValues\n")
for value in company.values():
    print(value)

# Iterating through key-value pairs
print("\nKey Value\n")
for key, value in company.items():
    print(key, value)
#----------------------------- 5- Checking existing key in Dictionary ----------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}

# Checking if a key exists
if "name" in company:
    print("Name Key is present in the dictionary")

#---------------------------- 6- Sorting Keys the Dictionary -------------------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}

# Sorting a dictionary by keys
sortK = dict(sorted(company.items()))
print(sortK)

#--------------------------- 7- Concatination of Dictionary --------------------------

# Creating a dictionary
company  = {"name": "WebGapp", "age": 15, "grade": "A"}

# Merging two dictionaries
dict1 = {"a": 1, "b": 2}
dict2 = {"b": 3, "c": 4}
merged = {**dict1, **dict2, **company}
print(merged)
#-------------------------- 8- Nested Dictionary -------------------------------------

 # Creating a nested dictionary
webgapp = {
    "make": "WebGapp",
    "Design": "HTML",
    "year": 2018,
    "Expert": {
        "special": "Web development",
        "course": "Python"
    }
}
print(webgapp)

Join our team, where career growth knows no limits.

For More Details

Our internship program guarantees personalized attention for optimal career development in the tech industry.

+91 97879 68375

-> You should bring your own laptop during the internship

Who can apply?

Internships are open for students who: B.E / B.Tech / M.E / M.Tech / B.Sc / M.Sc / M.C.A / B.C.A / Diploma.

  • Ongoing Students Only
  • days, 5days/ 10days or Based on Student Preference
  • Limited 1 to 10 students per slot
  • Registration fees : 1000 INR
  • Slots are filling quickly only fewer slots are available