BREAKING
5G in Schools: Government Mandates High-Speed Internet for All • SC Stays UGC 2026 Equity Rules: What it Means for College Students • CUET 2026 Registration Open: New Rules You Need to Know Before Applying • CBSE Revised Date Sheet 2026: Class 10 and 12 Exam Dates Changed • JEE Mains 2026 Phase 2: Registration Dates Announced • UPSC Prelims 2026: The 100-Day Countdown Strategy • UP Board 2026: Toll-Free Helpline Launched for Student Stress • UP Board 2026: Class 10 & 12 Time Table Released • Top 3 Scholarships Every Indian Student Should Apply for in 2026 • NEET UG 2026: Syllabus Confirmed by NMC • NEET UG 2026: Updated Biology Curriculum Highlights • NEET MDS 2026: Postponement Rumors and NBE Clarification • NEET 2026 Biology: The 'Do or Die' Cheat Sheet • NEET 2026: Fact Check on New Exam Pattern and Eligibility Rumors • Maharashtra HSC Hall Ticket 2026: Download Link Active • JEE Mains 2026: Session 1 Analysis and Cutoff Prediction • JEE Mains 2026: Tentative Session 1 Dates • JEE Advanced 2026: Revised Syllabus and Weightage Alert • GATE 2026: IISc Bangalore to be the Organizing Institute • CUET PG 2026: NTA Announces March Exam Window • CUET 2026: Application Guide and Exam Date Predictions • CLAT 2026: Consortium Announces Changes in Pattern • CBSE Class 10 Date Sheet 2026: Tentative Schedule Released • CBSE Admit Card 2026: Expected Release Date and Steps to Download • CBSE 2026 Marking Scheme: More Competency Questions • CBSE 2026: AI and Coding Mandatory for Class 9 and 10 • Board Exam Date Sheet 2026 Released5G in Schools: Government Mandates High-Speed Internet for All • SC Stays UGC 2026 Equity Rules: What it Means for College Students • CUET 2026 Registration Open: New Rules You Need to Know Before Applying • CBSE Revised Date Sheet 2026: Class 10 and 12 Exam Dates Changed • JEE Mains 2026 Phase 2: Registration Dates Announced • UPSC Prelims 2026: The 100-Day Countdown Strategy • UP Board 2026: Toll-Free Helpline Launched for Student Stress • UP Board 2026: Class 10 & 12 Time Table Released • Top 3 Scholarships Every Indian Student Should Apply for in 2026 • NEET UG 2026: Syllabus Confirmed by NMC • NEET UG 2026: Updated Biology Curriculum Highlights • NEET MDS 2026: Postponement Rumors and NBE Clarification • NEET 2026 Biology: The 'Do or Die' Cheat Sheet • NEET 2026: Fact Check on New Exam Pattern and Eligibility Rumors • Maharashtra HSC Hall Ticket 2026: Download Link Active • JEE Mains 2026: Session 1 Analysis and Cutoff Prediction • JEE Mains 2026: Tentative Session 1 Dates • JEE Advanced 2026: Revised Syllabus and Weightage Alert • GATE 2026: IISc Bangalore to be the Organizing Institute • CUET PG 2026: NTA Announces March Exam Window • CUET 2026: Application Guide and Exam Date Predictions • CLAT 2026: Consortium Announces Changes in Pattern • CBSE Class 10 Date Sheet 2026: Tentative Schedule Released • CBSE Admit Card 2026: Expected Release Date and Steps to Download • CBSE 2026 Marking Scheme: More Competency Questions • CBSE 2026: AI and Coding Mandatory for Class 9 and 10 • Board Exam Date Sheet 2026 Released
HomeNotesClass 12 CS: Python Dictionaries Handout
Back to Library
Computer Science
4.9 Rating

Class 12 CS: Python Dictionaries Handout

12/27/2025
5,400+ Students Accessed
1.2k Helpful Votes

Class 12 Computer Science - Python Dictionaries

A Dictionary is an unordered, mutable collection of key-value pairs.

1. Creating a Dictionary

student = {
    "name": "Rahul",
    "roll_no": 101,
    "marks": 95
}

2. Important Methods

  • dict.keys(): Returns all the keys.
  • dict.values(): Returns all the values.
  • dict.items(): Returns key-value pairs as tuples.
  • dict.get(key): Returns value for a key without raising an error if key is missing.
  • dict.pop(key): Removes the specified key and returns the value.

3. Merging Dictionaries

In Python 3.9+, you can use the union operator:

dict3 = dict1 | dict2

4. Dictionary Comprehension

squares = {x: x*x for x in range(1, 6)}
# Output: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

5. Board Exam Typical Question

Question: Write a function to count the frequency of each character in a string using a dictionary.

def count_freq(s):
    freq = {}
    for char in s:
        freq[char] = freq.get(char, 0) + 1
    return freq

Tip: Remember that keys in a dictionary must be immutable (Strings, Numbers, Tuples). 🐍💻

Student Feedback

SR
Sameer Rajput
Verified Student
2 days ago

"Literally saved my internal exams. The diagrams and cheat sheets included are so clear! High quality material."

NG
Nisha Gupta
Verified Student
1 week ago

"Best notes for JEE preparation. Concise, accurate, and exactly what I needed for last-minute revision."

Class 12 CS: Python Dictionaries Handout | ResultHub