12th Computer Science One Mark Questions and Book Back Answers
Class 12 Computer Science starts with problem solving: function specification, data abstraction, scoping rules and algorithmic strategies. It then moves to Python programming, including lists, tuples, sets, dictionaries, classes and objects, followed by database concepts and SQL. The last chapters connect Python to other tools: running C++ programs, reading and writing CSV files, querying SQLite and drawing charts with pyplot.
Chapters
Previous year question papers
View all →About Computer Science
Medium ~20 h study
The Class 12 Computer Science book is really three subjects stitched together. First comes problem solving on paper: what a function does, how data is hidden behind constructors and selectors, how a name is looked up in nested scopes, and how fast an algorithm runs. Then comes Python, where those ideas turn into working code. Finally the book brings in databases and SQL, and shows Python talking to C++ programs, CSV files and SQLite.
The order matters. Unit I does not use any particular language, so terms like pure function, impure function, abstract data type and the LEGB rule have to be learnt as definitions. From Unit II onwards you write Python: tokens, operators, if and elif, while and for loops, functions with different kinds of arguments, and string slicing. Unit III covers lists, tuples, sets, dictionaries and classes. Unit IV is database theory, SQL commands and CSV files. Unit V connects Python to C++ programs and SQLite, and ends with pyplot charts.
In the exam, one-mark questions mostly test exact definitions and the output of short code snippets. Longer answers ask you to write a Python program or an SQL query, or to compare two ideas such as list and tuple, or DBMS and RDBMS. So you need both: clear definitions you can reproduce word for word, and enough practice at the keyboard that you can predict what a few lines of code will print. The book-back questions on this site are arranged chapter by chapter for that practice.
What you'll learn
- Design an algorithm for a given problem and describe its efficiency using Big O, Big Omega and Big Theta.
- Write Python programs using if, while, for, user-defined functions and correct indentation.
- Choose between a list, tuple, set or dictionary based on whether the data must change, stay ordered or stay unique.
- Define classes with constructors, destructors and private members, and create objects from them.
- Create tables and write SQL queries that select, insert, update and delete rows.
- Read and write CSV files using Python's csv module.
- Compile and run a C++ program from a Python script using g++ and command-line arguments.
- Draw line, bar and pie charts using pyplot.
Before you start
- Basic idea of how a computer stores and processes data, and how to plan the logic of a program.
- C++ programming and object-oriented concepts from Class 11.
Units in Computer Science
Computer Science — the syllabus in depth
How the Syllabus Is Organised
Problem Solving and Algorithmic Thinking
The first unit is about designing a solution before writing any code. A function specification lists its parameters and what it returns. Parameters are the names in the definition; arguments are the values you pass when you call it. A pure function gives the same result for the same arguments and changes nothing outside itself. An impure function may read or change outside variables, so its result can vary. Data abstraction uses constructors to build an abstract data type and selectors to pull values back out, so the rest of the program never needs to know how the data is stored. The scoping chapter explains the LEGB order: Local, Enclosed, Global, Built-in. The last chapter of the unit compares searching and sorting algorithms using Big O, Big Omega and Big Theta to describe time and space complexity.
Python Programming and Control Flow
Python is where the algorithms become programs. You start with tokens (keywords, identifiers, literals, operators and delimiters), variables and the difference between interactive mode and script mode. Python marks a block by indentation, not by curly braces as in C++, so a misaligned line is a real error. The control structures chapter covers sequential statements, alternative branching with if, if..else and if..elif..else, and iteration with while and for. The functions chapter covers required, keyword, default and variable-length arguments, plus anonymous functions written with lambda. The strings chapter covers slicing, stride, and built-in string functions and formatting.
Data Structures and Object-Oriented Programming
This unit introduces Python's collection types. A list is an ordered, mutable sequence in square brackets. A tuple is an ordered sequence that cannot be changed once created. A set holds unique elements with no fixed order. A dictionary stores key-value pairs, and each key must be unique. The classes and objects chapter shows how a class acts as a template and how an object bundles data with its methods. The constructor __init__ runs automatically when an object is created, and the destructor __del__ runs when the object is deleted. A variable whose name begins with two underscores is private and cannot be accessed directly from outside the class.
Relational Databases and Structured Query Language
The database chapters explain what a DBMS does and why an RDBMS stores data in tables of rows and columns linked by keys. Redundancy, consistency and transactions are compared, and data models such as hierarchical, network, relational and entity-relationship are described. The SQL chapter then puts this into practice. DDL commands such as CREATE, ALTER and DROP define tables. DML commands such as INSERT, UPDATE and DELETE change the data. Constraints like PRIMARY KEY, UNIQUE, NOT NULL and CHECK protect the data, and the WHERE clause with aggregate functions such as COUNT, SUM and AVG pulls out the answers you need.
Connecting Python with Other Tools
Unit IV closes with CSV files, and Unit V uses Python as a glue language. You compile and run a C++ program from a Python script using the g++ compiler from MinGW, with the sys, os and getopt modules handling command-line arguments and system commands. The CSV chapter shows how to read and write comma-separated files with the csv module, including values that contain commas, quotes or line breaks. The SQLite chapter runs SQL queries from Python using connection and cursor objects. The last chapter uses the pyplot module of Matplotlib to draw line charts, bar charts and pie charts.
How to study Computer Science
Work through the book in its own order, because each unit uses the one before it. Learn the Unit I definitions and the LEGB rule first; they come back when you write functions and classes. Then open a Python editor and type out every example in the control structures, functions and strings chapters, changing values to see what happens.
After Python, move to lists, tuples, sets, dictionaries and classes, then to database concepts and SQL. SQL questions reward exact syntax, so write the queries out by hand. Finish with the Unit V chapters by running a script that reads a CSV file, one that queries an SQLite table and one that draws a pyplot chart.
Each week, aim to cover:
- the theory and book-back questions for one or two chapters
- writing and fixing code in both interactive mode and script mode
- a set of SQL commands on a small sample table
Regular practice at the keyboard is what makes code-output questions easy to answer in the exam.
Common mistakes to avoid
- Mixing up parameters and arguments: parameters are the names written in the function definition, and arguments are the actual values passed when the function is called.
- Careless indentation in Python: C++ uses curly braces for blocks, but Python uses indentation, so a line that is not aligned with its block raises an IndentationError. Mixing tabs and spaces can cause the same problem.
- Trying to change a tuple element: tuples are immutable, so t[0] = 5 raises a TypeError. Lists are mutable and allow this.
- Writing == where = is needed, or the other way round: a single = assigns a value to a variable, while == compares two values and gives True or False.
- Leaving out the comma in a one-element tuple: (10,) is a tuple, but (10) is just the integer 10 inside brackets.
- Accessing a private variable from outside the class: a name that starts with two underscores, such as __num, can only be used by methods of that class. Using obj.__num from outside raises an AttributeError.
Frequently asked questions
What is the difference between a pure and an impure function?
A pure function always returns the same result for the same arguments, because the result depends only on those arguments. It has no side effects and does not change any outside variable. An impure function may give different results for the same arguments, because it reads or changes variables outside its own body. random() is a common example of an impure function.
How do constructors and selectors work in data abstraction?
Constructors and selectors are the two kinds of functions used with an abstract data type. A constructor builds the object by putting the pieces of information together, for example making a rational number from a numerator and a denominator. A selector takes one piece back out of the object, such as the numerator, without the caller needing to know how the object is stored inside.
What is the LEGB rule for variable scope in Python?
LEGB is the order in which Python searches for a name. It first looks in the Local scope of the current function. If the name is not there, it checks the Enclosed scope of any outer function, then the Global scope of the module, and finally the Built-in scope, which holds names such as print and len. The first match found is used.
What is the difference between list and tuple in Python?
The main difference is mutability. A list is written in square brackets and can be changed after it is created: elements can be replaced, added or removed. A tuple is written in parentheses and cannot be changed once created. Because of this, iterating over a tuple is slightly faster than iterating over a list.
What are constructors and destructors in Python classes?
They are special methods that Python calls automatically. The constructor, __init__, runs when an object is created and is normally used to set the object's starting values. The destructor, __del__, runs when the object is about to be destroyed, for example after del is used on it, and can be used for clean-up work.
How is a DBMS different from an RDBMS?
A DBMS is software that stores and manages data using a navigational model, where data is reached through linked records. Normalization is not achieved and links between data are weak. An RDBMS stores all data in tables of rows and columns and connects tables through keys. It supports normalization to reduce redundancy, enforces integrity constraints and supports distributed databases. dBase and FoxPro are DBMS examples; MySQL, Oracle and SQLite are RDBMS examples.
What is the difference between DELETE, TRUNCATE, and DROP in SQL?
DELETE removes the rows that match a WHERE condition, or all rows if there is no condition. The table structure stays, and the space used by those rows is not freed. TRUNCATE removes every row in the table and frees that space, but the empty table remains. DROP removes the table itself, structure and data together, from the database.
How do you read a CSV file into a Python dictionary?
Use the DictReader class from the csv module. DictReader treats the first line of the file as the header and uses its values as keys. Each later row is returned as a dictionary that maps those keys to the values in that row. In older Python versions each row comes back as an OrderedDict.
How can Python run external C++ programs?
Python uses the os module to send commands to the operating system. The script calls os.system with a command such as g++ followed by the source file name and -o with the executable name, which compiles the C++ code using MinGW's g++ compiler. A second os.system call then runs the executable, and its output appears in the command window.
Last updated 15 September 2026