Empowering Students with AI-Powered Assessments & Intelligent Learning
CBSE(NCERT) · Grade 12 · Computer Science

CBSE(NCERT) GRADE 12 COMPUTER SCIENCE 2025 COMPARTMENT SET1

47 questions from this Grade 12 Computer Science paper. Log in as a Grade 12 student to view solutions.

🔒 Login / Register to Download PDF
Q1 short answer 1 mark
State if following statement is True or False: If T is a tuple and L is a list, then T+L is a valid statement in Python.

Solution hidden

Log in to view solution →
Q2 mcq 1 mark
Identify the output of the following code segment:
  • B. 1
  • C. 3
  • D. 'a'

Solution hidden

Log in to view solution →
Q2 mcq 1 mark
Identify the output of the following code segment: s = "an apple. a toy." s = s.find('a', 2) print(s)
  • B. 1
  • C. 3
  • D. 'a'

Solution hidden

Log in to view solution →
Q3 mcq 1 mark
What is the value of the following expression?
  • A. [6.0, 27.0]
  • B. (6.0, 9.0)
  • C. (6, 27)
  • D. (6.0, 27.0)

Solution hidden

Log in to view solution →
Q3 mcq 1 mark
What is the value of the following expression? $3 + 3 \cdot 00,\ 3**3\cdot 0$
  • A. [$6\cdot 0$, $27\cdot 0$]
  • B. ($6\cdot 0$, $9\cdot 0$)
  • C. ($6$, $27$)
  • D. ($6\cdot 0$, $27\cdot 0$)

Solution hidden

Log in to view solution →
Q4 mcq 1 mark
What is the output of the following expression? Sports = "Paralympic Games" print(Sports.split("m"))
  • A. ['Paraly', 'm', 'pic Ga', 'm', 'es']
  • B. ('Paraly', 'm', 'pic Games')
  • C. ('Paraly', 'pic Ga', 'es')
  • D. ['Paraly', 'pic Ga', 'es']

Solution hidden

Log in to view solution →
Q6 mcq 1 mark
Which of the following is a mapped data type?
  • A. List
  • B. Sets
  • C. Dictionary
  • D. Boolean

Solution hidden

Log in to view solution →
Q8 mcq 1 mark
Which of the following list methods accepts exactly 2 parameters?
  • A. append()
  • B. extend()
  • C. insert()
  • D. pop()

Solution hidden

Log in to view solution →
Q10 mcq 1 mark
A text file song.txt contains the following contents in it: Life goes on as it never ends What will be the output of the following code snippet? f1 = open("song.txt", "r") s1 = f1.read(5) s2 = f1.readline(4) s3 = f1.read(3) print(s1, s3, sep="#")
  • A. goes# on
  • B. Life #goes# on
  • C. Life # on
  • D. Error

Solution hidden

Log in to view solution →
Q12 mcq 1 mark
What will be the output of the following code segment? a = 5 def func_1(b = 10): global a a = b - 10 b += a print(a, b) func_1(a)
  • A. 0 5
  • B. 5 0
  • C. 0 -5
  • D. -5 0

Solution hidden

Log in to view solution →
Q13 short answer 1 mark
Write any two DDL commands.

Solution hidden

Log in to view solution →
Q14 mcq 1 mark
Which of the following is not a valid relational operator used with WHERE clause in SQL?
  • A. >
  • B. <=
  • C. =>
  • D. <>

Solution hidden

Log in to view solution →
Q15 mcq 1 mark
What is the default format of date in MySQL?
  • A. DD-MM-YYYY
  • B. MM-DD-YYYY
  • C. YYYY-MM-DD
  • D. YYYY-DD-MM

Solution hidden

Log in to view solution →
Q16 mcq 1 mark
Ginni has created a table, SCORES in MySQL to store runs scored by players in a cricket match. The table contains the following records: Table: Scores PLAYER SCORE Ranveer 50 Sukesh 35 Mirza 10 John 51 Murugan 70 Which of the following statements will give 10 as output ?
  • A. SELECT MAX(Score) FROM Scores;
  • B. SELECT MIN(Score) FROM Scores;
  • C. SELECT SUM(Score) FROM Scores;
  • D. SELECT AVG(Score) FROM Scores;

Solution hidden

Log in to view solution →
Q20 mcq 1 mark
Assertion (A): Every object in Python is assigned a unique identity (ID). Reason (R): ID remains the same for the lifetime of that object.
  • A. Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).
  • B. Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).
  • C. Assertion (A) is true, but Reason (R) is false.
  • D. Assertion (A) is false, but Reason (R) is true.

Solution hidden

Log in to view solution →
Q21 mcq 1 mark
Assertion (A): Foreign key column of a table cannot have NULL entries. Reason (R): Primary key column of a table cannot have NULL entries.
  • A. Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of the Assertion (A).
  • B. Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of the Assertion (A).
  • C. Assertion (A) is true, but Reason (R) is false.
  • D. Assertion (A) is false, but Reason (R) is true.

Solution hidden

Log in to view solution →
Q22 short answer 2 marks
What is the difference between = and == in Python? Give an example of each.

Solution hidden

Log in to view solution →
Q23 short answer 2 marks
Give an example of each of the following: (i) An expression using any one identity operator. (ii) An arithmetic expression which uses any one augmented assignment operator.

Solution hidden

Log in to view solution →
Q24 long answer 2 marks
Assuming that D1 and D2 are Python dictionaries, write the following statements using built-in functions/methods: (I) (a) To delete all the elements of D1. OR (b) To generate a list of values of D1. (II) (a) To update dictionary D2 with the elements of D1. OR (b) To generate a tuple of keys of D2.

Solution hidden

Log in to view solution →
Q25 mcq 2 marks
Identify the correct possible output(s) of the following code segment. Also write the minimum and the maximum possible values of the variable b. import random s="War and Peace" a=len(s)//2 for i in range(4): b=random.randrange(i,a) print(s[b],end='+')
  • A. n+P+d+a+
  • B. W+r+n+n+
  • C. e+r+W+a+
  • D. a+P+e+r+

Solution hidden

Log in to view solution →
Q26 long answer 2 marks
The code provided below is intended to input a positive integer from the user and display the total number of its factors. However, there are syntax and logical errors in the code. Rewrite the code after removing all the errors. Underline all the corrections made. n=int(input("Enter a positive integer:") c=0 for i in range(n+1): if n%i=0: c+=1 print(c)

Solution hidden

Log in to view solution →
Q27 short answer 1 mark
(I) (a) Write any one difference between CHAR and VARCHAR data types in MySQL. OR (b) Write one difference between Primary key and Unique constraint.

Solution hidden

Log in to view solution →
Q28 short answer 2 marks
(I) (a) Expand any one of the following communication protocols: POP, TCP. (b) Write one difference between hub and switch used in a computer network. OR (II) (a) Write one difference between HTTP and HTTPS. (b) Write the names of two wireless transmission media.

Solution hidden

Log in to view solution →
Q28 short answer 2 marks
(I) (a) Expand the following terms: POP, TCP. (b) Write any one difference between a hub and a switch used in computer networks.

Solution hidden

Log in to view solution →
Q28 short answer 2 marks
(II) (a) Write any one difference between HTTP and HTTPS. (b) Write names of any two wireless transmission media.

Solution hidden

Log in to view solution →
Q28 long answer 3 marks
A stack named KeyStack contains records of some computer keyboards. Each record is represented as a list containing Make, Keys, Connectivity. The Make and Connectivity are strings, and Keys is an integer. For example, a record in the stack may be ('Hitech', 105, 'USB'). Write the following user-defined functions in Python to perform the specified operations on KeyStack:

Solution hidden

Log in to view solution →
Q29 long answer 3 marks
(a) Write a Python function which removes the dot (.) character from the file "Colors.txt". For example, if the input is: White is a mix of seven colors. What are these seven colors ? VIBGYOR – violet, indigo, blue, green, orange and red. When we mix all these colors we just get one light which is the WHITE light. then the output should be: White is a mix of seven colors. VIBGYOR – violet, indigo, blue, green, orange and red. which is the WHITE light. (Hint: You have to ignore the last character and trailing white spaces.) OR (b) Write a function in Python that removes the line with last number $n$ vowels from the file "Novel.txt".

Solution hidden

Log in to view solution →
Q29 short answer 1 mark
(II) (a) Write an SQL command to remove a column named ADDRESS, from a table named CUSTOMER. OR (b) Write an SQL command to add a column named ADDRESS, of type VARCHAR(20) in a table named CUSTOMER.

Solution hidden

Log in to view solution →
Q29 long answer 3 marks
Write the following user-defined functions in Python: (I) push_vowels(S,St): Here S is a string and St is a list representing a stack. The function should push all the vowels of the string S onto the stack St. For example, if the string S is "Easy Concepts", then the function push_vowels() should push the elements 'E','a','o','e' onto the stack. (II) pop_one(St) : The function should pop an element from the stack St, and return this element. If the stack is empty, then the function should display the message ‘Stack Underflow’, and return None. (III) display_all(St): The function should display all the elements of the stack St, without deleting them. If the stack is empty, the function should display the message ‘Empty Stack’.

Solution hidden

Log in to view solution →
Q30 short answer 3 marks
Write the output on execution of the following Python code: P=[3,5,7,4] P.insert(2,3) P.extend([10, 6]) print(P) print(P.index(7)) print(P[::2])

Solution hidden

Log in to view solution →
Q31 short answer 3 marks
Write the output on execution of the following Python code: def ALTER(Y=25): global X Y += X X += Y print(X,Y,sep="#") X=5; Y=15 ALTER(Y) ALTER() print(X,Y,sep="@")

Solution hidden

Log in to view solution →
Q32 short answer 1 mark
Write the output for the queries given below: (I) SELECT STAFF_NAME FROM STAFF WHERE SALARY BETWEEN 25000 AND 30000;

Solution hidden

Log in to view solution →
Q33 short answer 1 mark
Write the output for the queries given below: (II) SELECT * FROM STAFF WHERE DEPARTMENT = "MATHS" AND SALARY > 25000;

Solution hidden

Log in to view solution →
Q33 short answer 4 marks
Assuming you are asked to help Suman in her assignment, write a Python code for performing the following tasks with the help of user-defined functions: NewMembers(): to accept records of members from the user and add them to the file CLUB.CSV. PriorityMember(): to find and display those members from the file CLUB.CSV, who are paying Fee more than 35000.

Solution hidden

Log in to view solution →
Q34 short answer 1 mark
Write the output for the queries given below: (III) SELECT STAFF_NAME, STAFF_ID FROM STAFF WHERE DEPARTMENT LIKE "%S";

Solution hidden

Log in to view solution →
Q34 short answer 4 marks
Assume that you are working for ABC Corporation (ABCC). ABCC allots contracts to different contractors for some of its works. The data of Contracts and Contractors are kept in the tables Work and Contractor respectively. Following are a few records from these two tables of ABCC’s database. Table : Work W_ID C_ID W_Name W_Amt P0001 C_01 Painting 20000 E0001 C_01 Electrical 50000 D0001 C_02 Dumping 10000 Table : Contractor C_ID C_Name Phone email C_01 M. Khan & Sons 1232311 MK@xyz.com C_02 Acharya Pvt. Ltd. 2323311 APL@xyz.com C_03 Charu Corp. NULL CCP@pqr.xyz Note : The tables contain many more records than shown here. As an employee of ABCC, you are required to write the SQL queries for the following: (I) To display all the records from the Work table in alphabetical order of W_Name. (II) To display the names of contractors where W_Amt is more than 15000. (III) To display the structure of Work table. (IV) (a) To count total number of records present in Work table. OR (IV) (b) To delete the records of contractors whose phone number is not known.

Solution hidden

Log in to view solution →
Q35 short answer 1 mark
Write the output for the queries given below: (IV) SELECT MAX(SALARY)FROM STAFF ;

Solution hidden

Log in to view solution →
Q36 short answer 1 mark
Write the suitable SQL queries to perform the following tasks: (I) To display the average salary of each department.

Solution hidden

Log in to view solution →
Q36 short answer 5 marks
Keshav is the IT Head in a hospital. He needs to manage the records of all the doctors in the hospital. For this, he wants to store the following information of each doctor in a file : D_ID – An integer to store Doctor ID. D_Name – A string to store doctor’s name. D_Dept – A string to store the Department of the doctor. (Surgery, Radiology, etc.) Experience – An integer to store doctor’s experience (in years) For example, a doctor’s information may be : [1256, 'R. Gupta', 'Cardiology', 15] As an applicant for the post of a Programmer, you have to answer the following questions in this context : (I) Write one difference of storing this data in a binary file over a CSV file. (II) It is assumed that the data is stored in a binary file named DOCTORS.DAT. Write a Python function to read all the records from DOCTORS.DAT. (III) Write a Python function addDoctor() to accept doctor’s data from the user and store it in DOCTORS.DAT.

Solution hidden

Log in to view solution →
Q37 short answer 1 mark
Write the suitable SQL queries to perform the following tasks: (II) To insert the following record in the table, STAFF. STAFF_ID : S333 STAFF_NAME : GURMEET SALARY : 15000 DEPARTMENT : ADMIN DESIGNATION : CLERK

Solution hidden

Log in to view solution →
Q38 short answer 1 mark
Write the suitable SQL queries to perform the following tasks: (III) To display the unique designations from the table.

Solution hidden

Log in to view solution →
Q39 short answer 1 mark
Write the suitable SQL queries to perform the following tasks: (IV) To display all the details of the staff whose name is of four letters.

Solution hidden

Log in to view solution →
Q40 short answer 4 marks
Write the suitable SQL queries to perform the following tasks:

Solution hidden

Log in to view solution →
Q44 short answer
Write one difference of storing this data in a binary file over a CSV file.

Solution hidden

Log in to view solution →
Q45 short answer
Write a function addDoctor(), in Python, which accepts a doctor’s data from the user and writes it in the file DOCTORS.DAT.

Solution hidden

Log in to view solution →
Q46 short answer
What kind of network (PAN/LAN/MAN/WAN) will be formed by interconnecting all the computers inside a block ?

Solution hidden

Log in to view solution →
Q47 short answer
Is there a need for repeater(s) in Patiala branch ? Why, or why not ?

Solution hidden

Log in to view solution →