Stack concept and operations using list PYQ part 1 — Lecture 41
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: "Stack concept and operations using list" Lecture number 41 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 "Stack concept and operations using list" only. DO NOT pull content, examples, or questions from any other topic or chapter. LECTURE MODE: SUBTOPIC PYQ PRACTICE - Scope: "Stack concept and operations using list" only. - Do not reteach the topic from scratch. Use a short recap only when a PYQ needs it. - Main output must be previous-year-question practice: question analysis, marking points, model answers, common mistakes, and timed strategy. - Use the 15 real PYQ record(s) provided below as the source of truth. Do not fabricate board years, marks, or questions. =========================================== SECTION 1: LECTURE INFORMATION =========================================== Class: XII CS | Subject: Computer Science | Board: CBSE Topic: Stack concept and operations using list PYQ part 1 Subtopics to cover today: - Stack concept and operations using list Student level: Class XII, CBSE Board, average to above-average students preparing for board exams =========================================== SECTION 2: TEACHER'S REFERENCE NOTES =========================================== Stack concept and operations using list PYQ part 1 PYQ PRACTICE SCOPE: Stack concept and operations using list. Concept ID: U1_STACK_LIST_OPS. Use only previous-year questions whose concept_ids include U1_STACK_LIST_OPS. Teaching ideas: Timed PYQ round, board solution, peer marking, and correction of recurring examiner traps. =========================================== SECTION 3: EXAM FREQUENCY DATA (Year-wise) =========================================== Teaching priority: HIGH High-yield concepts: Stack concept and operations using list | Year | Questions | Marks | |------|-----------|-------| | 2022 | 8 | 22 | | 2023 | 6 | 14 | | 2024 | 1 | 3 | | **Total** | **15** | **39** | =========================================== SECTION 4: ACTUAL PREVIOUS YEAR QUESTIONS (Scope: "Stack concept and operations using list" only — 15 questions from board papers) =========================================== PYQ LECTURE RULE: use these questions as the source pool for practice. - This pool has 15 questions: preserve and discuss ALL 15 actual PYQs in Section 7. - Do not compress, replace, paraphrase, or skip any actual PYQ. - Do not create substitute or newly framed questions for this small pool. - Do not fabricate board years, marks, sections, or questions. --- 2022 Board Exam (8 questions | 22 marks) --- Q1. [Short Answer] [2M] [Easy] Section-A "Stack is a linear data structure which follows a particular order in which the operations are performed." What is the order in which the operations are performed in a Stack ? Name the List method/function available in Python which is used to remove the last element from a list implemented stack. Also write an example using Python statements for removing the last element of the list. Q2. [Short Answer] [2M] [Easy] Section-A Differentiate between Push and Pop operations in the context of stacks. Q3. [Programming] [3M] [Medium] Section-B Write the definition of a user defined function PushNv(N) which accepts a list of strings in the parameter N and pushes all strings which have no vowels present in it, into a list named NoVowel. Write a program in Python to input 5 words and push them one by one into a list named All. The program should then use the function PushNV() to create a stack of words in the list NoVowel so that it stores only those words which do not have any vowel present in it, from the list All. Thereafter, pop each word from the list NoVowel and display the popped word. When the stack is empty display the message "EmptyStack". For example : If the Words accepted and pushed into the list All are ['DRY', 'LIKE', 'RHYTHM', 'WORK', 'GYM'] Then the stack NoVowel should store ['DRY', 'RHYTHM', 'GYM'] And the output should be displayed as GYM RHYTHM DRY EmptyStack Q4. [Programming] [3M] [Medium] Section-B Write the definition of a user defined function Push3_5(N) which accepts a list of integers in a parameter N and pushes all those integers which are divisible by 3 or divisible by 5 from the list N into a list named Only3_5. Write a program in Python to input 5 integers into a list named NUM. The program should then use the function Push3_5() to create the stack of the list Only3_5. Thereafter pop each integer from the list Only3_5 and display the popped value. When the list is empty, display the message "StackEmpty". For example : If the integers input into the list NUM are : [10, 6, 14, 18, 30] Then the stack Only3_5 should store [10, 6, 18, 30] And the output should be displayed as 30 18 6 10 StackEmpty Q5. [Programming] [3M] [Medium] Section-B (a) Write separate user defined functions for the following : (i) PUSH (N) — This function accepts a list of names, N as parameter. It then pushes only those names in the stack named OnlyA which contain the letter 'A'. (ii) POPA(OnlyA) — This function pops each name from the stack OnlyA and displays it. When the stack is empty, the message "EMPTY" is displayed. For example : If the names in the list N are ['ANKITA', 'NITISH', 'ANWAR', 'DIMPLE', 'HARKIRAT'] Then the stack OnlyA should store ['ANKITA', 'ANWAR', 'HARKIRAT'] And the output should be displayed as HARKIRAT ANWAR ANKITA EMPTY (ii) popEven(EVEN) — This function pops each integer from the stack EVEN and displays the popped value. When the stack is empty, the message "Stack Empty" is displayed. For example : If the list N contains [10,5,3,8,15,4] Then the stack, EVEN should store [10,8,4] And the output should be 4 8 10 Stack Empty Q6. [Programming] [3M] [Medium] Section-B (b) Write the following user defined functions : (i) pushEven(N) — This function accepts a list of integers named N as parameter. It then pushes only even numbers into the stack named EVEN. (ii) popEven(EVEN) — This function pops each integer from the stack EVEN and displays the popped value. When the stack is empty, the message "Stack Empty" is displayed. For example : If the list N contains [10,5,3,8,15,4] Then the stack, EVEN should store [10,8,4] And the output should be 4 8 10 Stack Empty Q7. [Programming] [3M] [Medium] Section-C A list contains following record of a customer: [Customer_name, Phone_number, City] Write the following user defined functions to perform given operations on the stack named 'status': (i) Push_element() - To Push an object containing name and Phone number of customers who live in Goa to the stack. (ii) Pop_element() - To Pop the objects from the stack and display them. Also, display "Stack Empty" when there are no elements in the stack. For example: If the lists of customer details are: ["Gurdas", "99999999999","Goa"] ["Julee", "8888888888","Mumbai"] ["Murugan","77777777777","Cochin"] ["Ashmit", "1010101010","Goa"] The stack should contain: ["Ashmit","1010101010"] ["Gurdas","9999999999"] The output should be: ["Ashmit","1010101010"] ["Gurdas","9999999999"] Stack Empty Q8. [Programming] [3M] [Medium] Section-C Write a function in Python, Push(SItem) where SItem is a dictionary containing the details of stationary items – {Sname:price}. The function should push the names of those items in the stack who have price greater than 75. Also display the count of elements pushed into the stack. For example: If the dictionary contains the following data: Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25} The stack should contain: Notebook Pen The output should be: The count of elements in the stack is 2 --- 2023 Board Exam (6 questions | 14 marks) --- Q1. [Assertion-Reason] [1M] [Easy] Section-A Assertion (A) : A stack is a LIFO structure. Reason (R) : Any new element pushed into the stack always gets positioned at the index after the last existing element in the stack. (a) Both (A) and (R) are true and (R) is the correct explanation for (A). (b) Both (A) and (R) are true and (R) is not the correct explanation for (A). (c) (A) is true but (R) is false. (d) (A) is false but (R) is true. Q2. [Assertion-Reason] [1M] [Easy] Section-A Assertion (A): In Python, a stack can be implemented using a list. Reasoning (R): A stack is an ordered linear list of elements that works on the principle of First In First Out (FIFO). (a) Both (A) and (R) are true and (R) is the correct explanation for (A). (b) Both (A) and (R) are true and (R) is not the correct explanation for (A). (c) (A) is true but (R) is false. (d) (A) is false but (R) is true. Q3. [Programming] [3M] [Medium] Section-C (a) A list contains following record of customer: [Customer name, Room Type] Write the following user defined functions to perform given operations on the stack named 'Hotel': (i) Push_Cust() — To Push customers' names of those customers who are staying in 'Delux' Room Type. (ii) Pop_Cust() — To Pop the names of customers from the stack and display them. Also, display "Underflow" when there are no customers in the stack. For example : If the lists with customer details are as follows : ["Siddarth", "Delux"] ["Rahul", "Standard"] ["Jerry", "Delux"] The stack should contain Jerry Siddharth The output should be: Jerry Siddharth Underflow Q4. [Programming] [3M] [Medium] Section-C (b) Write a function in Python, Push(Vehicle) where, Vehicle is a dictionary containing details of vehicles — {Car Name: Maker}. The function should push the name of car manufactured by 'TATA' (including all the possible cases like Tata, TaTa, etc.) to the stack. For example: If the dictionary contains the following data: Vehicle={"Santro": "Hyundai", "Nexon": "TATA", "Safari": "Tata"} The stack should contain Safari Nexon Q5. [Programming] [3M] [Medium] Section-C A list contains following record of course details for a University : [Course name, Fees, Duration] Write the following user defined functions to perform given operations on the stack named 'Univ' : (i) Push_element() — To push an object containing the Course_name, Fees and Duration of a course, which has fees greater than 100000 to the stack. (ii) Pop_element() — To pop the object from the stack and display it. Also, display "Underflow" when there is no element in the stack. For example : If the lists of courses details are : ["MCA",200000,3] ["MBA",500000,2] ["BA",100000,3] The stack should contain : ["MBA",500000,2] ["MCA",200000,3] Q6. [Programming] [3M] [Medium] Section-C A list, NList contains following record as list elements: [City, Country, distance from Delhi] Each of these records are nested together to form a nested list. Write the following user defined functions in Python to perform the specified operations on the stack named travel. (i) Push_element(NList): It takes the nested list as an argument and pushes a list object containing name of the city and country, which are not in India and distance is less than 3500 km from Delhi. (ii) Pop_element(): It pops the objects from the stack and displays them. Also, the function should display "Stack Empty" when there are no elements in the stack. For example: If the nested list contains the following data: NList=[["New York", "U.S.A.", 11734], ["Naypyidaw", "Myanmar", 3219], ["Dubai", "UAE", 2194], ["London", "England", 6693], ["Gangtok", "India", 1580], ["Columbo", "Sri Lanka", 3405]] The stack should contain: ['Naypyidaw', 'Myanmar'] ['Dubai', 'UAE'] ['Columbo', 'Sri Lanka'] The output should be: ['Columbo', 'Sri Lanka'] ['Dubai', 'UAE'] ['Naypyidaw', 'Myanmar'] Stack Empty --- 2024 Board Exam (1 question | 3 marks) --- Q1. [Programming] [3M] [Medium] Section-C A dictionary, d_city contains the records in the following format : {state:city} Define the following functions with the given specifications : (i) push_city(d_city) : It takes the dictionary as an argument and pushes all the cities in the stack CITY whose states are of more than 4 characters. (ii) pop_city() : This function pops the cities and displays "Stack empty" when there are no more cities in the stack. =========================================== =========================================== 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: Stack concept and operations using list Pattern: Assertion-Reason=2, Programming=11, Short Answer=2 | Marks: 1M=2, 2M=2, 3M=11 | Total: 15 questions [Short Answer] [2M] [Easy] × 2 → Core concept of Stack concept and operations using list [Programming] [3M] [Medium] × 7 → Output/result interpretation for the current concept [Assertion-Reason] [1M] [Easy] × 2 → Core concept of Stack concept and operations using list [Programming] [3M] [Medium] × 3 → Core concept of Stack concept and operations using list [Programming] [3M] [Medium] → Nested try/except behaviour =========================================== =========================================== IMPORTANCE ANALYSIS (allocate teaching time by this ranking) =========================================== | Rank | Concept | Score | Times Tested | Total Marks | Recent Years | Priority | |------|---------|-------|-------------|-------------|--------------|----------| | 1 | Stack concept and operations using list | 97 | 15 | 39M | 2024, 2023, 2022 | 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 and actual previous-year questions to identify traps, marking points, and common mistakes. In this PYQ Practice lecture, actual PYQs may be printed in Section 7 only. Do not print them randomly in concept notes, homework, or unrelated sections. For this lecture, the generated teaching material must strongly cover these traps: No static trap list exists yet for "Stack concept and operations using list". Self-generate 4–7 traps from: - actual question patterns for Stack concept and operations using list - 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