Class 12 CS Exam Viva Guide 2026

55+ Comprehensive Questions on Python & SQL Database Management

I. Important Syntax Reference

Database Connectivity:

import mysql.connector
db = mysql.connector.connect(host="localhost", user="root", password="pw")
cursor = db.cursor()
cursor.execute("SELECT * FROM student")
results = cursor.fetchall()

Binary File (Pickle):

import pickle
pickle.dump(obj, file_handle) # Write
data = pickle.load(file_handle) # Read

II. Essential Abbreviations

TermFull Form
LIFOLast-In-First-Out (Stack)
DDLData Definition Language
DMLData Manipulation Language
CSVComma Separated Values
DBMSDatabase Management System

III. 55 Viva Questions & Answers

Python Programming Concepts

1. What is a program?A set of instructions written to perform a specific task using a computer.
2. What are the main steps of problem-solving?Analysis, algorithm design, coding, testing, and debugging.
3. What is Python?A high-level, interpreted, general-purpose language known for simplicity.It was created by Guido van Rossum, and released in 1991. It is used for:
  • web development (server-side)
  • software development
  • system scripting.
  • 4. What are execution modes in Python?Interactive mode (line-by-line) and Script mode (saved files).
    5. What is a variable?A named memory location used to store data values.
    6. Define Python tokens.Keywords, identifiers, literals, operators, and punctuators.
    7. L-value vs R-value?L-value is the memory address (left side); R-value is the stored value (right side).
    8. Name Python data types.Int, float, complex, bool, str, list, tuple, dict, None.
    9. Mutable vs Immutable?Mutable (List, Dict) can change; Immutable (Int, Str, Tuple) cannot change.
    10. What are operators?Symbols performing arithmetic, relational, or logical operations.
    11. What is operator precedence?Order in which operators are evaluated (e.g., PEMDAS/BODMAS).
    12. What is type conversion?Converting one data type to another (Implicit or Explicit using int(), float(), etc.).
    13. Types of errors in Python?Syntax errors, Logical errors, and Runtime errors.
    14. What is indentation?Defining code blocks using white space; it is mandatory in Python.
    15. What is a conditional statement?Code executed based on a condition (if, if-else, elif).
    16. What is an iterative statement?Loops that repeat code blocks (for, while).
    17. Use of range()?Generates a sequence of integers, typically used in for loops.
    18. Break vs Continue?Break exits the loop; continue skips the current iteration.
    19. What is a string?An immutable sequence of characters in quotes.
    20. Four string methods?upper(), lower(), find(), split(), replace().
    21. What is a list?A mutable, ordered collection of elements.
    22. Common list methods?append(), insert(), pop(), remove(), sort().
    23. What is a tuple?An immutable, ordered collection of elements.
    24. Why are tuples faster?Because they are immutable, allowing fixed memory allocation.
    25. What is a dictionary?A collection of key-value pairs; keys must be unique.
    26. Accessing dict values?Using dict[key] or the get() method.
    27. Dictionary traversal?Using a loop to access all keys or values (e.g., for k in dict:).
    28. What is a module?A file (.py) containing Python functions and definitions.
    29. Name built-in modules.math, random, statistics, csv, pickle.
    30. What is a function?A reusable block of code that performs a specific task.
    31. Parameters vs Arguments?Parameters are in definition; Arguments are values passed during call.
    32. Variable scope?Local (inside function) or Global (outside function).
    33. What is an exception?A runtime error that disrupts the normal flow of a program.
    34. Handling exceptions?Using try-except-finally blocks.
    35. What is a file?Data stored permanently on a secondary storage device.
    36. Types of files?Text (.txt), Binary (.dat), and CSV (.csv).
    37. File open modes?r, w, a, rb, wb, ab, r+, w+.
    38. Use of 'with' statement?Ensures files are closed automatically, even if an exception occurs.
    39. What is a binary file?Stores data as bytes; not human-readable directly.
    40. Use of pickle module?To serialize (dump) and deserialize (load) Python objects in a binary file.
    41. What is a CSV file?CSV stands for Comma Separated Value, it is a plain text file where data is separated by delimiters (usually commas).
    42. What is a stack?A linear data structure following the LIFO principle.
    43. Stack operations?Push (add) and Pop (remove).

    Database & SQL Management

    44. What is a database?An organized collection of structured data.
    45. What is DBMS?Software to create and manage databases (e.g., MySQL, Oracle).
    46. What is a primary key?A unique, non-null attribute identifying each row.
    47. What is a foreign key?An attribute linking two tables, referencing a primary key in another table.
    48. What is SQL?Structured Query Language used to communicate with databases.
    49. What is DDL?Data Definition Language (CREATE, ALTER, DROP, TRUNCATE).
    50. What is DML?Data Manipulation Language (INSERT, UPDATE, DELETE, SELECT).
    51. Use of WHERE clause?Filters records based on specific criteria.
    52. Aggregate functions?SUM(), AVG(), COUNT(), MAX(), MIN().
    53. GROUP BY vs HAVING?GROUP BY categorizes rows; HAVING filters those categories (used with aggregates).
    54. What is a Join?Combining data from two or more tables based on a related column.
    55. Python-SQL Connectivity?Uses mysql-connector or similar drivers to bridge Python with a database.
    56. What is a Cursor?An object used to execute SQL queries and fetch data in Python.
    57. commit() vs rollback()?commit() saves changes; rollback() undoes unsaved changes.
    58. which keyword is used to make/create a python function?def