Dictionary operations Theory — Lecture 12
CBSE | XII CS | Computational Thinking and Programming – 2 | 35 min
You are an expert CBSE XII CS Computer Science teacher, examiner, and study material creator. =========================================== SCOPE — READ BEFORE GENERATING ANYTHING =========================================== Today's lecture covers ONE topic only: "Dictionary operations" Lecture number 12 of 91 | Duration: 35 minutes | Board: CBSE Chapter: Computational Thinking and Programming – 2 HARD RULE: Every piece of content you generate — notes, examples, questions, tips — must be directly relevant to "Dictionary operations" only. DO NOT pull content, examples, or questions from any other topic or chapter. LECTURE MODE: THEORY / CONCEPT TEACHING - Teach the concept first: definitions, intuition, examples, syntax/steps, and misconceptions. - Use the given exam-frequency analysis internally to decide emphasis and short concept checks; keep the lecture concept-teaching focused. - Keep content tightly scoped to today's concept list. =========================================== SECTION 1: LECTURE INFORMATION =========================================== Class: XII CS | Subject: Computer Science | Board: CBSE Topic: Dictionary operations Theory Subtopics to cover today: - Dictionary operations Student level: Class XII, CBSE Board, average to above-average students preparing for board exams =========================================== SECTION 2: TEACHER'S REFERENCE NOTES =========================================== Dictionary operations Theory Concept ID: U1_DICTIONARY_OPS. Primary Sub-subtopic: Dictionary operations. Question-bank grouping: Revision of Python & Core Concepts. Use this lecture for theory, examples, misconceptions, and short concept checks mapped to this concept ID. Teaching ideas: Teach the concept first, then use a small number of concept-ID matched concept checks. =========================================== SECTION 3: EXAM FREQUENCY DATA (Year-wise) =========================================== Teaching priority: HIGH High-yield concepts: Dictionary operations | Year | Questions | Marks | |------|-----------|-------| | 2021 | 1 | 1 | | 2022 | 2 | 3 | | 2023 | 7 | 9 | | 2024 | 3 | 5 | | 2025 | 10 | 11 | | 2026 | 6 | 6 | | **Total** | **29** | **35** | =========================================== SECTION 4: EXAM ANALYSIS INPUT — DO NOT PRINT THESE IN THEORY NOTES (Scope: "Dictionary operations" only — 29 questions from board papers) =========================================== THEORY LECTURE RULE: use these PYQs only as private analysis data — this lecture is PURELY THEORY. - Cover every concept and trap revealed by these PYQs in the study notes - Do NOT print, quote, reproduce, paraphrase, or label any actual PYQ in the final HTML - Self-generate your own tricky/important questions and examples about the concept itself only — do not call them "PYQ-pattern", "PYQ-style", "board-style", or reference PYQs/previous years at all - In theory lectures, generated questions must be MCQ or Short Answer only - Never use the word "PYQ" or phrases like "previous year question" anywhere in the visible HTML --- 2021 Board Exam (1 question | 1 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of these about a dictionary is false? a) The values of a dictionary can be accessed using keys b) The keys of a dictionary can be accessed using values c) Dictionaries aren't ordered d) Dictionaries are mutable --- 2022 Board Exam (2 questions | 3 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Given the following dictionaries: dict_exam={"Exam":"AISSCE", "Year":2023} dict_result={"Total":500, "Pass_Marks":165} Which statement will merge the contents of both dictionaries? a) dict_exam.update(dict_result) b) dict_exam + dict_result c) dict_exam.add(dict_result) d) dict_exam.merge(dict_result) Q2. [Output Prediction] [2M] [Easy] Section-B (a) Given is a Python string declaration: myexam="@@CBSE Examination 2022@@" Write the output of: print(myexam[::-2]) (b) Write the output of the code given below: my_dict = {"name": "Aman", "age": 26} my_dict['age'] = 27 my_dict['address'] = "Delhi" print(my_dict.items()) --- 2023 Board Exam (7 questions | 9 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following statement(s) would give an error after executing the following code ? Stud={"Murugan":100, "Mithu":95} # Statement 1 print (Stud[95]) # Statement 2 Stud ["Murugan"]=99 # Statement 3 print (Stud.pop() ) # Statement 4 print (Stud) # Statement 5 (a) Statement 2 (b) Statement 3 (c) Statement 4 (d) Statements 2 and 4 Q2. [MCQ] [1M] [Easy] Section-A Which of the following is not a sequential datatype in Python ? (a) Dictionary (b) String (c) List (d) Tuple Q3. [MCQ] [1M] [Easy] Section-A Given the following dictionary Day={1:"Monday", 2: "Tuesday", 3: "Wednesday" } Which statement will return "Tuesday". (a) Day.pop() (b) Day.pop(2) (c) Day.pop(1) (d) Day.pop("Tuesday") Q4. [MCQ] [1M] [Easy] Section-A Which of the following functions is a valid built-in function for both list and dictionary datatype ? (a) items() (b) len() (c) update() (d) values() Q5. [MCQ] [1M] [Easy] Section-A Which of the following will delete key-value pair for key = "Red" from a dictionary D1? a) delete D1("Red") b) del D1["Red"] c) del.D1["Red"] d) D1.del["Red"] Q6. [Output Prediction] [2M] [Easy] Section-B (a) Given is a Python string declaration : NAME = "Learning Python is Fun" Write the output of : print (NAME [-5:-10:-1]) (b) Write the output of the code given below : dict1={1: ["Rohit",20], 2: ["Siya",90]} dict2={1: ["Rahul",95], 5: ["Rajan",80]} dict1.update (dict2) print (dict1.values()) Q7. [Output Prediction] [2M] [Easy] Section-B Predict the output of the following code: S = "LOST" L = [10,21,33,4] D={} for I in range(len(S)): if I%2==0: D[L.pop()] = S[I] else: D[L.pop()] = I+3 for K,V in D.items(): print(K,V,sep="*") --- 2024 Board Exam (3 questions | 5 marks) --- Q1. [MCQ] [1M] [Easy] Section-A If my_dict is a dictionary as defined below, then which of the following statements will raise an exception? my_dict = {'apple': 10, 'banana': 20, 'orange': 30} a) my_dict.get('orange') b) print(my_dict['apple', 'banana']) c) my_dict['apple']=20 d) print(str(my_dict)) Q2. [Output Prediction] [2M] [Easy] Section-B Predict the output of the following code : d={"IND":"DEL","SRI":"COL","CHI":"BEI"} str1="" for i in d: str1=str1+str(d[i])+"@" str2=str1[:-1] print (str2) Q3. [Short Answer] [2M] [Easy] Section-B (b) A dictionary dict2 is copied into the dictionary dict1 such that the common key's value gets updated. Write the Python commands to do the task and after that empty the dictionary dict1. --- 2025 Board Exam (10 questions | 11 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Consider the statements given below and then choose the correct output from the given options: D={'S01':95, 'S02':96} for I in D: print(I,end='#') (A) S01#S02# (B) 95#96# (C) s01,95#S02,96# (D) S01#95#S02#96# Q2. [MCQ] [1M] [Easy] Section-A Which of the following built-in function/method returns a dictionary? (A) dict() (B) keys() (C) values() (D) items() Q3. [MCQ] [1M] [Easy] Section-A Which of the following is a mapped data type ? (A) List (B) Sets (C) Dictionary (D) Boolean Q4. [MCQ] [1M] [Easy] Section-A If the dictionary D1 is defined as : D1={1:'a',2:'b'} then which of the following statements is incorrect and hence will result in an error ? (A) D1.get(1) (B) D1.get(3) (C) D1.del(1) (D) D1.clear() Q5. [Short Answer] [1M] [Easy] Section-B Assuming that D1 and D2 are Python dictionaries, write the required statement using built-in functions/methods. Delete all the elements of D1. Q6. [Short Answer] [1M] [Easy] Section-B Assuming that D1 and D2 are Python dictionaries, write the required statement using built-in functions/methods. Generate a list of values of D1. Q7. [Short Answer] [1M] [Easy] Section-B Assuming that D1 and D2 are Python dictionaries, write the required statement using built-in functions/methods. Update dictionary D2 with the elements of D1. Q8. [Short Answer] [1M] [Easy] Section-B Assuming that D1 and D2 are Python dictionaries, write the required statement using built-in functions/methods. Generate a tuple of keys of D2. Q9. [MCQ] [1M] [Easy] Section-A What will be the output of the following Python code? my_dict = {"name": "Alicia", "age": 27, "city": "DELHI"} print(my_dict.get("profession", "Not Specified")) a) Alicia b) DELHI c) None d) Not Specified Q10. [Output Prediction] [2M] [Easy] Section-B Predict the output of the Python code given below: emp = {"Arv": (85000,90000),"Ria": (78000,88000),"Jay": (72000,80000),"Tia": (80000,70000)} selected = [ ] for name in emp: salary = emp[name] average = (salary[0] + salary[1]) / 2 if average > 80000: selected.append(name) print(selected) --- 2026 Board Exam (6 questions | 6 marks) --- Q1. [MCQ] [1M] [Easy] Section-A Which of the following statements is true about dictionaries in Python ? (A) A dictionary is an example of sequence datatype. (B) A dictionary cannot have two elements with same key. (C) A dictionary cannot have two elements with same value. (D) The key and value of an element cannot be the same. Q2. [MCQ] [1M] [Easy] Section-A If L is a list with 6 elements, then which of the following statements will raise an exception ? (A) L.pop(1) (B) L.pop(6) (C) L.insert(1,6) (D) L.insert(6,1) Q3. [Short Answer] [1M] [Easy] Section-B Assuming that D1 is a dictionary in Python, write the required Python expression/statement. Write a Python expression to check if the key, 'RNo' is present in D1. Q4. [Short Answer] [1M] [Easy] Section-B Assuming that D1 is a dictionary in Python, write the required Python expression/statement. Write a Python expression to check if any key in D1 has a value 12. Q5. [Short Answer] [1M] [Easy] Section-B Assuming that D1 is a dictionary in Python, write the required Python expression/statement. Write a single statement using a built-in function to add the key:value pair 'RNo':12 if the key 'RNo' is not present in D1. If the key is present, the function should return its value. Q6. [Short Answer] [1M] [Easy] Section-B Assuming that D1 is a dictionary in Python, write the required Python expression/statement. Write a single statement to delete all the elements from D1. =========================================== =========================================== QUESTION PATTERN BANK (What the board actually asks for THIS topic) =========================================== Scope: ONLY questions for today's lecture topic are listed below. DO NOT import questions from other topics or chapters. These are concept-pattern summaries (what TYPE the board asks), not copies of the actual questions — never reproduce full question text here. ### Concept: Dictionary operations Pattern: MCQ=15, Output Prediction=5, Short Answer=9 | Marks: 1M=23, 2M=6 | Total: 29 questions [MCQ] [1M] [Easy] × 11 → Core concept of Dictionary operations [Output Prediction] [2M] [Easy] × 5 → Output/result interpretation for the current concept [MCQ] [1M] [Easy] × 2 → Raising and handling exceptions [Short Answer] [2M] [Easy] → Core concept of Dictionary operations [MCQ] [1M] [Easy] × 2 → Output/result interpretation for the current concept [Short Answer] [1M] [Easy] × 8 → Core concept of Dictionary operations =========================================== =========================================== IMPORTANCE ANALYSIS (allocate teaching time by this ranking) =========================================== | Rank | Concept | Score | Times Tested | Total Marks | Recent Years | Priority | |------|---------|-------|-------------|-------------|--------------|----------| | 1 | Dictionary operations | 113 | 29 | 35M | 2026, 2025, 2024 | CRITICAL | CRITICAL concepts → full sub-section + comparison table + 2 worked examples HIGH concepts → 1 sub-section + 1 worked example MEDIUM concepts → definition + 1 quick example only =========================================== EXAMINER FINGERPRINT — TRAPS TO COVER INTERNALLY =========================================== Use the exam-frequency input only for internal analysis. Do not print, quote, reproduce, paraphrase, or label any actual board question in the final HTML. For this lecture, the generated teaching material must strongly cover these traps: No static trap list exists yet for "Dictionary operations". Self-generate 4–7 traps from: - actual question patterns for Dictionary operations - common wrong assumptions students make about this concept - output-tracing traps - syntax-vs-runtime traps - comparison traps - order/sequence traps Important: this list should be treated as dynamic — for lectures with no static trap list, generate traps yourself from the categories above rather than leaving this section thin. =========================================== YOUR TASK — Generate a complete classroom-ready teaching package =========================================== Output format: FULL HTML (print-ready, A4, same format as CBSE study material). Use the CSS classes below. NO plain Markdown — use HTML elements only. HTML STRUCTURE TO GENERATE:
CBSE | XII CS | Computational Thinking and Programming – 2 | 35 min