How the Class 12 CS practical is marked (CBSE 2026-27)
The short answer: the practical is 30 marks out of 100 and the theory paper is 70. The split below is from the CBSE Computer Science syllabus for 2026-27. CBSE's marks circular of 5 November 2026 lists a Board-appointed external examiner for the practical. The viva is listed separately at 3 marks, but the external examiner often asks about your program while you run it, so treat every part of the practical as viva preparation. For 2027, CBSE has fixed the window for practicals in regular-session schools as 1 January to 13 February 2027. Your school sets your exact day inside it. Winter-bound schools held theirs from 9 November to 19 December 2026.
What the viva really tests
Documentation is 20% of the program mark, and the project must be your own work: the curriculum tells teachers to guard against plagiarism. An examiner checks both by asking you to explain a line, change an input, or say why you chose a file type. A student who cannot explain the code can lose marks well beyond the 3 for the viva.
The 12 questions asked in almost every Class 12 CS viva
Python revision and functions viva questions
What is the difference between mutable and immutable types in Python?
A mutable object can be changed in place after it is created; an immutable one cannot. Lists, dictionaries and sets are mutable, so appending to a list keeps the same object. Integers, floats, strings and tuples are immutable, so an operation like adding to a string creates a new object. This matters when I pass a list to a function: changes inside the function are visible outside.
Follow-up: 'Can a tuple contain a list?' Yes, and that inner list can still be changed.
What is a function, and what are the three types of functions in the syllabus?
A function is a named block of code that runs when it is called and can take arguments and return a value. The three types are built-in functions such as len() and print(), functions defined in modules such as math.sqrt() or random.randint(), which need an import, and user-defined functions that I create with the def keyword.
What is the difference between a parameter and an argument?
A parameter is the name written in the function definition; an argument is the actual value passed when the function is called. In def area(length, width), length and width are parameters; in area(5, 3), 5 and 3 are arguments. People also call them formal and actual parameters.
What are default parameters, and what is the rule for writing them?
A default parameter has a value assigned in the definition, which is used when the caller does not pass that argument, for example def interest(p, r, t=1). The rule is that default parameters must come after all non-default parameters, otherwise Python raises a SyntaxError.
Give the example from your own file if you used one.
What are positional arguments?
Positional arguments are matched to parameters by their order in the call. In interest(10000, 6, 2), 10000 goes to p, 6 to r and 2 to t. If I pass them in the wrong order, the program still runs but gives a wrong answer, which is why keyword arguments such as t=2 are sometimes clearer.
Can a Python function return more than one value?
Yes. If I write return total, average, Python packs the values into a tuple and returns that one tuple. The caller can unpack it as t, a = stats(marks). In my practical file, the program that returns the largest and smallest number from a list uses exactly this.
What happens if a function has no return statement?
It still returns a value: None. So if I write x = show(), where show only prints, x will hold None. That is a common cause of a None appearing in output when someone prints the result of a print-only function.
Explain local and global scope with the global keyword.
A variable created inside a function is local and disappears when the function ends. A variable created at the top level of the module is global and can be read inside a function. If I want to change the global variable inside the function, I must declare it with the global keyword first; otherwise assignment creates a new local variable with the same name.
Examiners like the UnboundLocalError case: reading then assigning a global name inside a function without the global keyword.
What is the flow of execution in a program with functions?
Python runs statements from top to bottom. A def statement only creates the function; its body does not run until the function is called. When a call happens, control jumps to the function body, runs it, and comes back to the line after the call with the returned value.
What is the difference between a module and a library?
A module is a single Python file containing functions and variables, such as math or random. A package or library is a collection of related modules. I import a module with import math, or bring in one name with from math import sqrt.
Exception handling viva questions
What is an exception, and how is it different from a syntax error?
A syntax error is a mistake in the structure of the code, so the program does not start at all. An exception is an error that happens while a correct program is running, for example ZeroDivisionError when dividing by zero, ValueError when int() gets the text abc, or FileNotFoundError when opening a missing file in read mode.
Explain try, except and finally.
The code that may fail goes in the try block. If an exception occurs, Python jumps to the matching except block and the program continues instead of crashing. The finally block runs every time, whether an exception occurred or not, so it is the right place to close a file or a database connection. An optional else block runs only if no exception occurred.
Where have you used exception handling in your practical file?
In my binary file programs. I read records in a while True loop with pickle.load(), and when the file ends, load raises EOFError, which I catch in except EOFError to stop the loop. I also used except ValueError in the menu so that typing a letter instead of a number shows a message instead of crashing.
Text file handling viva questions
What are the three types of files in the Class 12 syllabus?
Text files, binary files and CSV files. A text file such as notes.txt stores readable characters line by line. A binary file stores bytes, and in our syllabus it holds pickled Python objects like a list for each student. A CSV file is a text file in which values are separated by commas, so it opens in a spreadsheet too.
What is the difference between an absolute and a relative path?
An absolute path gives the full location from the root of the drive, such as C:/Users/Riya/school/data.txt. A relative path is measured from the current working directory, such as data.txt or records/data.txt. Relative paths make the program work on another computer as long as the folder structure is the same.
Explain the text file modes r, w and a.
Mode r opens an existing file for reading and is the default; if the file does not exist it raises FileNotFoundError. Mode w opens for writing, creates the file if needed and erases any existing content. Mode a opens for appending, creates the file if needed and adds new data at the end without deleting anything.
The classic trap: 'What happens to old data if you open in w mode?' It is lost the moment the file opens.
How are r+, w+ and a+ different?
All three allow reading and writing. r+ needs the file to exist, keeps its content and starts at the beginning. w+ creates or empties the file first. a+ creates the file if needed, keeps the content, and every write goes to the end, though I can seek back to read.
What is the difference between write() and writelines()?
write() takes one string and writes it, returning the number of characters written. writelines() takes a list or other sequence of strings and writes them one after another. Neither adds a newline automatically, so I add the newline character myself at the end of each line.
How would you count the vowels in a text file?
I open the file in read mode with a with statement, read the whole content with read(), then loop through each character and increase a counter if the character, converted to lower case, is in the string aeiou. After the loop I print the counter. For large files I would read line by line instead to save memory.
What do seek() and tell() do?
tell() returns the current position of the file pointer. seek(offset, whence) moves the pointer: whence 0 counts from the start, 1 from the current position and 2 from the end. seek(0) is what I use to go back to the beginning and read the file again after writing to it. In text mode, offsets relative to the current position or the end are restricted, so I seek from the start.
How do you remove lines that contain a given character from a file?
A file cannot be edited in place line by line, so I read all lines from the original file, write only the lines that do not contain the character into a second file, and if needed rename the second file to replace the first. This is one of the CBSE suggested practicals, and it uses readlines() and write().
Binary file (pickle) and CSV file viva questions
Why do we need the pickle module for binary files?
A binary file stores bytes, but my data is a Python object such as a list [roll, name, marks]. The pickle module serialises the object into bytes with pickle.dump(object, file) and deserialises it back with pickle.load(file). Without pickle I would have to convert every record to a string and parse it back myself.
Which modes do you use for binary files?
The same letters with b added: rb to read, wb to write a new file, ab to append records, and rb+, wb+ and ab+ for read and write. Forgetting the b gives an error with pickle, because pickle writes bytes, not text.
How do you search a binary file for a roll number?
I open the file in rb mode and read one record at a time with pickle.load() inside a while True loop, wrapped in try and except EOFError. For each record I compare the roll number with the one entered; if it matches I print the name and set a found flag. After the loop, if the flag is still False, I print that the record was not found.
How do you update marks in a binary file?
The simple, safe method in my file is read-modify-write: I load every record into a list, change the marks of the matching roll number, then open the file in wb mode and dump all the records back. Another method uses rb+ with tell() and seek() to overwrite one record in place, but that only works safely when the record size does not change.
What is a CSV file, and which functions does the csv module give?
CSV stands for comma-separated values. It is a plain text file where each line is a record and the fields are separated by a delimiter, a comma by default. csv.writer(file) returns a writer object; writerow() writes one list as a row and writerows() writes a list of lists. csv.reader(file) returns an object I loop over, and each row comes back as a list of strings.
Why do numbers read from a CSV file need conversion?
Because csv.reader returns every field as a string. If marks are stored as 87, the reader gives me the string 87, so I convert with int() before comparing or adding; otherwise comparisons happen alphabetically and 9 would appear greater than 87.
How did you do the user-id and password program?
First I open users.csv in w mode with newline as an empty string, create a writer and write each user-id and password with writerow(). Then I open it in r mode, loop through csv.reader, and when the first field equals the user-id entered, I print the second field. In a real system passwords would be stored hashed, never in plain text.
Adding the last sentence shows judgement; examiners notice it.
Stack viva questions
What is a stack, and what are its operations?
A stack is a linear data structure in which insertion and deletion happen at one end, called the top, so the last element pushed is the first popped: LIFO. Push adds an element at the top, pop removes the top element, and peek reads the top without removing it. Checking whether the stack is empty comes before every pop.
How do you implement a stack using a list in Python?
I use a list where the end of the list is the top. Push is stack.append(item), pop is stack.pop() which removes and returns the last element, and peek is stack[-1]. isEmpty returns True when len(stack) equals 0. I write each as a separate function and call them from a menu.
What are overflow and underflow?
Underflow is trying to pop from an empty stack; in Python, list.pop() on an empty list raises IndexError, so I check for emptiness first and print Stack is empty. Overflow is pushing onto a full stack of fixed size. A Python list grows dynamically, so overflow happens only if memory runs out or if I impose a size limit myself.
Give real applications of a stack.
The undo feature in a text editor, the back button in a browser, reversing a string by pushing each character and popping them, checking whether brackets in an expression are balanced, and the function call stack that Python itself uses to remember where to return after each call.
SQL and database viva questions
What is a relation, and what are degree and cardinality?
In the relational model, a relation is a table. Each column is an attribute and each row is a tuple. Degree is the number of attributes and cardinality is the number of tuples. My STUDENT table with roll, name, class and marks for 20 students has degree 4 and cardinality 20.
Explain candidate key, primary key and alternate key.
A candidate key is any attribute or set of attributes that can uniquely identify each row. From the candidate keys, one is chosen as the primary key. The remaining candidate keys are alternate keys. In a STUDENT table, both admission number and Aadhaar number are candidate keys; if I choose admission number as primary key, Aadhaar number becomes an alternate key.
What is the difference between DDL and DML?
DDL, Data Definition Language, defines the structure: CREATE, ALTER and DROP. DML, Data Manipulation Language, works on the data inside the tables: INSERT, UPDATE, DELETE, and SELECT to query it. DDL changes the table design; DML changes or reads the rows.
What is the difference between CHAR and VARCHAR?
CHAR(n) is fixed length: CHAR(10) always uses space for 10 characters and pads shorter values with spaces. VARCHAR(n) is variable length: it stores only the characters entered, up to n. I use CHAR for fixed codes like a gender code and VARCHAR for names.
What is the difference between DELETE and DROP?
DELETE is DML and removes rows from a table, either all rows or those matching a WHERE condition; the table structure stays. DROP TABLE is DDL and removes the whole table, structure and data together. ALTER TABLE with DROP removes one column.
How do you add a column and a primary key to an existing table?
ALTER TABLE student ADD phone VARCHAR(15) adds a column. ALTER TABLE student ADD PRIMARY KEY (roll) makes roll the primary key, which only works if roll has no duplicates or NULLs. ALTER TABLE student DROP PRIMARY KEY removes it, and ALTER TABLE student DROP phone removes the column.
What does NULL mean, and how do you search for it?
NULL means the value is unknown or not applicable; it is not zero and not an empty string. Any comparison with NULL using the equals sign gives unknown, so WHERE marks = NULL returns nothing. I must write WHERE marks IS NULL or IS NOT NULL.
Explain LIKE with its wildcards.
LIKE matches a pattern in a text column. The percent sign stands for any number of characters, including none, and the underscore stands for exactly one character. WHERE name LIKE 'A%' finds names starting with A, and WHERE name LIKE '_a%' finds names whose second letter is a.
Is BETWEEN inclusive? And how is IN used?
Yes, BETWEEN includes both limits, so marks BETWEEN 60 AND 80 includes 60 and 80. IN checks membership in a list: WHERE city IN ('Delhi', 'Jaipur') is a shorter way of writing two conditions joined by OR.
What are aggregate functions, and how do they treat NULL?
Aggregate functions work on a set of rows and return one value: MAX, MIN, AVG, SUM and COUNT. They ignore NULL values. COUNT(marks) counts only rows where marks is not NULL, while COUNT written with an asterisk counts all rows, so the two can give different answers on the same table.
Explain GROUP BY and HAVING with an example.
GROUP BY collects rows with the same value into groups so an aggregate can be calculated for each group. SELECT class, AVG(marks) FROM student GROUP BY class gives the average for each class. HAVING then filters the groups: adding HAVING AVG(marks) greater than 70 keeps only classes whose average is above 70. WHERE could not do that because it runs before grouping.
What is the default order of ORDER BY, and what does DISTINCT do?
ORDER BY sorts in ascending order by default; I add DESC for descending, for example ORDER BY marks DESC. DISTINCT removes duplicate rows from the result, so SELECT DISTINCT city FROM student lists each city once.
What is a Cartesian product, and what are its degree and cardinality?
A Cartesian product joins every row of one table with every row of the other, which happens when I list two tables in FROM without a join condition. Its degree is the sum of the two degrees and its cardinality is the product of the two cardinalities. A table of 4 columns and 5 rows with one of 3 columns and 6 rows gives 7 columns and 30 rows.
What is the difference between an equi-join and a natural join?
An equi-join joins two tables with an equality condition on a common column, such as WHERE student.dept_id = dept.dept_id, and the common column appears twice in the result. A natural join joins on all columns with the same name automatically and shows the common column only once.
Python-MySQL connectivity viva questions
What are the steps to connect Python with MySQL?
First import the connector, for example import mysql.connector. Second, create a connection with connect(), passing host, user, password and database. Third, create a cursor with cursor(). Fourth, run SQL with execute(). Fifth, for SELECT read results with fetchone() or fetchall(); for INSERT, UPDATE or DELETE call commit(). Finally close the cursor and the connection.
What is a cursor?
A cursor is the object through which Python sends SQL statements to the database and receives the results. It keeps track of the result set and the current row, so each fetchone() call gives the next row.
What is the difference between fetchone() and fetchall()?
fetchone() returns the next row of the result as a tuple, or None when no rows are left. fetchall() returns all remaining rows as a list of tuples. For a large table I prefer a loop with fetchone() or fetchmany() so that the whole result is not loaded at once.
What does rowcount tell you?
cursor.rowcount gives the number of rows affected by the last execute(): rows inserted, updated or deleted, or the number of rows fetched so far after a SELECT. I print it after an UPDATE to confirm whether any record matched the condition.
Why use the %s format specifier instead of joining strings to build a query?
With execute(query, values), where the query contains %s and the values come as a tuple, the connector inserts the values safely and handles quotes. Building the query by joining strings breaks when a name contains an apostrophe and opens the program to SQL injection. The format() method also works, but %s with a values tuple is the safer habit.
Your INSERT ran without error but the row is not in the table. Why?
Most likely I forgot commit(). Changes made through the cursor stay in an uncommitted transaction, and when the connection closes they are discarded. After calling connection.commit() the row is saved and visible from the MySQL prompt too.
This is the most common live question when the examiner checks your connectivity program.
Questions on the suggested lab programs and how they are marked
How is your lab test program marked?
The CBSE syllabus gives the Python program 8 marks, judged 60 percent on logic, 20 percent on documentation and 20 percent on code quality. So I write comments, use clear variable names and handle wrong input, not just get the right output.
How did you simulate a dice in Python?
I imported the random module and used random.randint(1, 6), which returns a whole number from 1 to 6, both included. Inside a loop the user presses Enter to roll again. random.random() would give a decimal between 0 and 1 instead, so it does not suit a dice.
How did you display each word of a file separated by the hash symbol?
I opened the file in read mode, read it line by line, used split() to break each line into words, and printed the words joined with the hash symbol using join(). split() without arguments also removes extra spaces and the newline.
How did you count uppercase and lowercase characters in a file?
I read the whole file with read() and looped through each character. isupper() increased one counter and islower() another. Digits, spaces and punctuation are neither, so they are not counted in either total.
What is the difference between read(), readline() and readlines()?
read() returns the whole file, or n characters, as one string. readline() returns one line each time it is called. readlines() returns a list of all lines, each ending with a newline character.
Why is the with statement preferred for opening files?
with open('notes.txt') as f closes the file automatically when the block ends, even if an error occurs inside it. Without it, I must call close() myself, and a forgotten close can leave data unwritten.
Why do you catch EOFError when reading a binary file with pickle?
pickle.load() reads one object at a time and I do not know in advance how many records are in the file. When there are no more, it raises EOFError, so I put load() inside a loop in a try block and stop the loop in the except block.
Why do you pass newline as an empty string when writing a CSV file?
The csv writer adds its own line ending. Without newline equal to an empty string, on Windows an extra blank line appears between rows. The csv module documentation recommends it.
Computer networks questions that come up in the practical viva
Networks carry 10 theory marks and have no practical of their own, but examiners often ask one or two quick questions to round off the viva. These are common ones.
Class 12 CS project viva questions with model answers
CBSE expects the project to solve a real problem using Python file handling or Python-SQL connectivity, built in a group of two to three. The examiner asks every member separately, so each of you must explain your own module. The answers below use a library management project as the example; replace the details with yours.
What does your project do?
Our project is a library management system for our school library in Indore. The librarian was writing issue and return entries by hand, so finding overdue books took a whole afternoon. Our program stores books and members in MySQL, lets the librarian issue and return a book from a menu, and lists every overdue book with the fine in one step.
Which part did you build yourself?
I built the issue and return module. When a book is issued, my function checks that the book is available and the member has fewer than two books, inserts a row in the ISSUE table with today's date, and marks the book as issued. On return it calculates the fine at two rupees per late day and updates both tables, then commits.
Why did you use MySQL instead of a binary file?
Because we needed to search and join two kinds of data, books and issues, many times a day. In a binary file every search means reading all records with pickle; in MySQL one SELECT with a WHERE clause does it, and the primary and foreign keys stop us issuing a book that does not exist.
Show me the tables and keys in your project.
There are three tables. BOOK has book_id as the primary key with title, author and status. MEMBER has member_id as the primary key. ISSUE has its own issue_id and two foreign keys, book_id and member_id, referring to the other two tables, plus issue_date and return_date. A NULL return_date means the book is still out.
What happens if I enter a book number that does not exist?
The SELECT for that book_id returns no row, so fetchone() gives None. My code checks for None and prints Book not found, then shows the menu again. If you type letters instead of a number, the except ValueError block catches it and asks again instead of crashing.
What would you add if you had another month?
Two things. A search by title with LIKE so the librarian does not need the book number, and a login for the librarian, with the password stored as a hash rather than plain text. We also wanted a monthly report of the most issued books using GROUP BY and COUNT.
A two-day revision plan before the practical
- 1
Day 1 morning: your own file
Run every program in your practical file once. For each, say aloud in two sentences what it does and which file mode, function or query it depends on. Any program you cannot explain is the one the examiner will open.
- 2
Day 1 afternoon: files and stack
Write from memory the read, search, append and update programs for a binary file and the read and write programs for a CSV file. Then write push, pop and display for a stack in under ten minutes.
- 3
Day 1 evening: SQL
On one STUDENT table, write ALTER, UPDATE, ORDER BY, DELETE and GROUP BY with MIN, MAX, SUM, COUNT and AVG, which are exactly the CBSE suggested practicals. Add one equi-join with a second table.
- 4
Day 2 morning: connectivity and project
Run your four connectivity programs. Then rehearse the six project questions above with your own details, one minute per answer.
- 5
Day 2 evening: speak it
Answer the twelve most-asked questions out loud without notes, then run one mock viva. Sleep. The lab test needs a calm head more than one more chapter.
Practise the viva out loud with an AI examiner
Knowing the answer and saying it in two clear sentences to a stranger are different skills. The ExamPilot Class 12 science practical viva puts you in front of an AI external examiner who asks about your experiment or program, your practical file and your project, follows up when an answer is thin, and gives you a transcript with the exact answers that went wrong.
For deeper language practice, the Python viva questions and DBMS viva questions guides go beyond the Class 12 syllabus, and the free SQL and databases test checks your query basics before the lab test.
Frequently asked questions
- How many marks is the viva in the Class 12 computer science practical?
- In CBSE Computer Science (083) for 2026-27, the viva voce is 3 of the 30 practical marks. The rest is the lab test (8 for the Python program and 4 for SQL queries), 7 for the report file and 8 for the project. The theory paper carries 70. In practice, the viva questions also shape how the examiner marks your program, file and project.
- What questions are asked in a Class 12 computer science viva?
- Mostly questions on file handling (text, binary with pickle, CSV), the stack, SQL commands and keys, Python-MySQL connectivity, functions and exceptions, and your project. Examiners start from the program you just ran or a program in your practical file and ask you to explain a line or predict the output for a new input.
- How many programs should be in the Class 12 CS practical file?
- The CBSE curriculum asks for at least 15 Python programs, at least 5 sets of SQL queries using one or two tables, and at least 4 programs based on Python-SQL connectivity. Your school may ask for more. Make sure you can run and explain every program in it, because the examiner can pick any of them.
- Can I do the Class 12 CS project alone?
- The CBSE curriculum says the project should be done in groups of two to three students and started at least six months before submission. Each member is still questioned individually in the viva, so divide modules clearly and be ready to explain your own part in detail. Check your school's instructions if you have been allowed to work alone.
- Which project topics are good for Class 12 computer science?
- The curriculum asks for something useful built with Python file handling or Python-SQL connectivity, ideally a real problem from a local business or your school. Library, canteen billing, attendance, a GST invoice generator, a quiz with a score file or a stock register for a shop all work. A small project you fully understand beats a large one copied from the internet.
- What if I forget an answer in the CS viva?
- Say so honestly and reason from what you know: for example, I do not remember the exact function name, but I would read the records with pickle.load in a loop and stop at EOFError. Examiners reward the reasoning. Guessing a wrong definition confidently costs more than admitting a gap.
- Is the Class 12 IP practical viva the same as computer science?
- No. Informatics Practices (065) is a different subject with its own practical scheme: Pandas and Matplotlib programs 8, SQL queries 7, practical file 5, project 5 and viva 5. It is built around Pandas, data visualisation and SQL functions rather than file handling and the stack. See the Class 12 informatics practices viva guide.
Practise out loud
Practise your CS practical viva out loud
An AI external examiner asks about your program, practical file and project, follows up on weak answers and gives you a scored transcript.
School practical viva · Class 12 Science practical viva — Physics, Chemistry, Biology, Biotechnology, Computer Science, IP, Maths, PE, English and Hindi
