Courses / Computer Science XII (HSSC-II) – FBISE Complete SLO-Based Course
Unit 3 Review, Situational Quiz and Unit Test
Unit 3 – Programming Fundamentals · 45 min read · 16 MCQs to check yourself
Unit 3: Programming Fundamentals – review
This unit carries about 10% (theory) + practical exam of the marks in the FBISE model paper (Table of Specifications).
SLO checklist – tick each one you can do
| SLO | Students should be able to… | Lesson(s) |
|---|---|---|
| CS-12-C-01 | Understand and evaluate applications of programming paradigms; write a Python OOP program with instance attributes to manage state | 3.1, 3.2 |
| CS-12-C-02 | Use advanced constructs: lists, dictionaries, file handling and databases (SQL, normalisation, keys) in Python | 3.3, 3.4, 3.5, 3.6, 3.7 |
| CS-12-C-03 | Implement complex algorithms that use lists (nested lists, lists in dictionaries); count letters in a text file | 3.3, 3.4 |
| CS-12-C-04 | Use advanced testing and debugging techniques: unit tests, breakpoints, watches, print debugging | 3.8 |
Unit test
CS XII Unit 3 Test – Programming Fundamentals – 12 MCQs online (15 min). Full paper:
| Section | Questions | Marks |
|---|---|---|
| A – MCQs (online here) | 12 × 1 | 12 |
| B – Short questions | 4 × 3 | 12 |
| C – Long questions | 1 × 6 | 6 |
| Total | 30 |
Then take CS XII Monthly Test 2.
Practise these before the test
Long questions
- What is meant by a programming paradigm? Explain and compare the Functional and Object-Oriented programming paradigms, supporting your answer with suitable examples. (1 + 5)
- Write a Python program using Object-Oriented Programming to define a class BankAccount with instance attributes owner and balance to manage state. Include methods deposit(), withdraw() (which must not allow the balance to go negative) and display(). Create two objects and show how each keeps its own state. (6)
- Write a Python program that stores each student’s subjects as a list inside a dictionary. It should (a) add a new student, (b) add a subject for an existing student, (c) remove a subject, (d) print each student with the number of subjects, and (e) list students taking "CS". Explain why a dictionary is used. (5 + 1)
- Write, execute and debug a Python program that reads a text file from disk and prints the number of occurrences of each letter of the alphabet. Explain how your program treats upper/lower case and non-letter characters, and mention two errors you might meet while debugging it. (4 + 2)
- A college keeps records of Students (roll_no, name, class) and Fees (receipt_no, roll_no, amount, date). (a) Identify the primary and foreign keys and explain the relationship. (b) Write SQL to create both tables, insert two records into each, delete one fee record, and display all fees of roll number 12 sorted by date. (2 + 4)
- A school keeps one table: Enrolment(StudentID, StudentName, ClassTeacher, TeacherPhone, CourseID, CourseName, Grade), key (StudentID, CourseID). Identify the anomalies and normalise the table to 3NF, showing each step and the final tables with keys. (2 + 4)
- Write a Python program that uses sqlite3 to create a database "clinic.db" with a table patients(id, name, age, disease). The program should insert three patients, update one patient’s disease, delete one patient, and display all remaining patients older than 30 sorted by age. Explain the purpose of commit(). (5 + 1)
- A function average(marks) should return the average of a list of marks, but users report wrong results and a crash when the list is empty. Describe how you would use unit tests, print statements, breakpoints and watches to find and fix the problems, and write a corrected function with unittest test cases. (3 + 3)
Short questions
- What is meant by a programming paradigm? Name any four paradigms.
- Give three advantages and two disadvantages of object-oriented programming.
- Give the pros and cons of functional programming.
- Write Python code to find the sum of squares of even numbers in [3, 4, 7, 10, 12] using (a) procedural and (b) functional style.
- Define class, object and instance attribute with a Python example.
- What is polymorphism? Give a Python example.
- Explain inheritance with a Python example.
- Write a Python class Rectangle with instance attributes length and width and methods area() and perimeter().
Model answers are listed under each lesson of this unit (and below for the extra review questions).
This lesson ends with a quiz of 16 MCQs. Open the lesson on PrepOasis to take it and save your progress.
Previous: 3.8 Testing and Debugging: Unit Tests, Breakpoints and Watches · Next: 4.1 Machine Learning Basics: Learning from Data, Features and Train-Test Split
All lessons in Computer Science XII (HSSC-II) – FBISE Complete SLO-Based Course