SEP-PYTHON

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 . . .

 
  
 PART-B
 3.Write a Program to Demonstrate use of Dictionaries
 #---------------------------------
 
# 1. Creating a Dictionary
# Dictionaries use curly braces {} with key:value pairs

student_info = {
    "name": "Aryan",
    "age": 21,
    "course": "Computer Science",
    "skills": ["Python", "Machine Learning"]
}

print(f"Original Dictionary: {student_info}")

 
name = student_info["name"]
current_course = student_info.get("course")
print(f"\nStudent Name: {name}")
print(f"Enrolled In: {current_course}")
 
student_info["age"] = 22  # Update
student_info["GPA"] = 3.8 # Add new key-value pair
print(f"Updated Info (Age & GPA): {student_info}")
 
removed_skill = student_info["skills"].pop(1)  
del student_info["course"] # Deletes the 'course' key entirely
print(f"After deletion: {student_info}")
 
print("\nIterating through keys and values:")
for key, value in student_info.items():
    print(f"- {key}: {value}")
 
print(f"\nAll Keys: {list(student_info.keys())}")
print(f"All Values: {list(student_info.values())}")