dictionary
# Program to demonstrate Dictionary in Python
print("=== Dictionary ===")
# Creating a dictionary
student = {"Name": "Alice", "Age": 20, "Course": "B.Sc"}
# Print the original dictionary
print("Original Dictionary:", student)
# Access value using key
print("Student Name:", student["Name"])
# Add new key-value pair
student["Grade"] = "A"
print("After adding Grade:", student)
# Remove a key-value pair
student.pop("Age")
print("After removing Age:", student)
Comments
Post a Comment