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

CBSE(NCERT) GRADE 12 COMPUTER SCIENCE 2024 COMPARTMENT SET1

38 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 True or False: “In Python, tuple is a mutable data type”.

Solution hidden

Log in to view solution →
Q2 mcq 1 mark
The primary key is selected from the set of ___________.
  • A. composite keys
  • B. alternate keys
  • C. candidate keys
  • D. foreign keys

Solution hidden

Log in to view solution →
Q3 mcq 1 mark
What will be the output of the following statement? print(6+5/4**2//5+8)
  • A. –14.0
  • B. 14.0
  • C. 14
  • D. –14

Solution hidden

Log in to view solution →
Q4 mcq 1 mark
Select the correct output of the code: S = "text#next" print(S.strip("t"))
  • A. ext#nex
  • B. ex#nex
  • C. text#nex
  • D. ext#next

Solution hidden

Log in to view solution →
Q5 mcq 1 mark
In SQL, which command will be used to add a new record in a table?
  • A. UPDATE
  • B. ADD
  • C. INSERT
  • D. ALTER TABLE

Solution hidden

Log in to view solution →
Q6 mcq 1 mark
'L' in HTML stands for:
  • A. Large
  • B. Language
  • C. Long
  • D. Laser

Solution hidden

Log in to view solution →
Q7 mcq 1 mark
Identify the valid Python identifier from the following:
  • A. 2user
  • B. user@2
  • C. user_2
  • D. user 2

Solution hidden

Log in to view solution →
Q8 mcq 1 mark
Consider the statements given below and then choose the correct output from the given options: Game="World Cup 2023" print(Game[-6::-1])
  • A. CdrW
  • B. ce o
  • C. puC dlroW
  • D. Error

Solution hidden

Log in to view solution →
Q9 mcq 1 mark
Predict the output of the following Python statements: >>>import statistics as s >>>s.mode ([10, 20, 10, 30, 10, 20, 30])
  • A. 30
  • B. 20
  • C. 10
  • D. 18.57

Solution hidden

Log in to view solution →
Q10 mcq 1 mark
Which of the following output will never be obtained when the given code is executed? import random Shuffle = random.randrange(10)+1 Draw = 10*random.randrange (5) print ("Shuffle", Shuffle, end="#") print ("Draw", Draw)
  • A. Shuffle 1 # Draw 0
  • B. Shuffle 10 # Draw 10
  • C. Shuffle 10 # Draw 0
  • D. Shuffle 11 # Draw 50

Solution hidden

Log in to view solution →
Q11 mcq 1 mark
Ethernet card is also known as:
  • A. LIC
  • B. MIC
  • C. NIC
  • D. OIC

Solution hidden

Log in to view solution →
Q12 short answer 1 mark
What will be the output of the given code? a=10 def convert(b=20): a=30 c=a+b print(a,c) convert(30) print(a)

Solution hidden

Log in to view solution →
Q13 mcq 1 mark
For the following Python statement: N = (25) What shall be the type of N?
  • A. Integer
  • B. String
  • C. Tuple
  • D. List

Solution hidden

Log in to view solution →
Q14 mcq 1 mark
Mr. Ravi is creating a field that contains alphanumeric values and fixed lengths. Which MySQL data type should he choose for the same?
  • A. VARCHAR
  • B. CHAR
  • C. LONG
  • D. NUMBER

Solution hidden

Log in to view solution →
Q15 short answer 1 mark
Fill in the blank: The full form of WWW is __________.

Solution hidden

Log in to view solution →
Q16 mcq 1 mark
__________ files are stored in a computer in a sequence of bytes.
  • A. Text
  • B. Binary
  • C. CSV
  • D. Notepad

Solution hidden

Log in to view solution →
Q17 mcq 1 mark
Assertion (A): Global variables are accessible in the whole program. Reason (R): Local variables are accessible only within a function or block in which it is declared.
  • A. Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
  • B. Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of 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 →
Q18 mcq 1 mark
Assertion (A): If numeric data are to be written to a text file, the data needs to be converted into a string before writing to the file. Reason (R): write() method takes a string as an argument and writes it to the text file.
  • A. Both Assertion (A) and Reason (R) are true and Reason (R) is the correct explanation of Assertion (A).
  • B. Both Assertion (A) and Reason (R) are true, but Reason (R) is not the correct explanation of Assertion (A).
  • C. Assertion (A) is true, but Reason (R) is false.

Solution hidden

Log in to view solution →
Q19 short answer 2 marks
(a) (i) Expand the following terms: URL, XML. (ii) Give one difference between HTTP and FTP. OR (b) (i) Define the term IP address with respect to network. (ii) What is the main purpose of a Router?

Solution hidden

Log in to view solution →
Q20 short answer 2 marks
Observe the following code carefully and rewrite it after removing all syntactical errors. Underline all the corrections made. def 1func(): a=input("Enter a number")) if a>=33 print("Promoted to next class") ELSE: print("Repeat")

Solution hidden

Log in to view solution →
Q21 short answer 2 marks
(a) Write the definition of a method/function SearchOut(Teachers, TName) to search for TName from a list Teachers, and display the position of its presence. For example: If the Teachers contain ["Ankit", "Siddharth", "Rahul", "Sangeeta", "rahul"] and TName contains "Rahul" The function should display Rahul at 2 rahul at 4 OR (b) Write the definition of a method/function Copy_Prime(lst) to copy all the prime numbers from the list lst to another list lst_prime.

Solution hidden

Log in to view solution →
Q22 short answer 2 marks
Predict the output of the following code: d={"IND":"DEL","SRI":"COL","CHI":"BEI"} str1="" for i in d: str1=strl+str(d[i])+"@" str2=str1[:-1] print(str2)

Solution hidden

Log in to view solution →
Q23 short answer 2 marks
(a) Write the Python statement for each of the following tasks using BUILT-IN functions/methods only: (i) To delete an element 10 from the list lst. (ii) To replace the string "This" with "That" in the string str1. OR (b) A dictionary dict2 is copied into the dictionary dict1 such that the common key’s value gets updated. Write the Python commands to do the task and after that empty the dictionary dict1.

Solution hidden

Log in to view solution →
Q24 short answer 2 marks
(a) Mr. Atharva is given a task to create a database, Admin. He has to create a table, users in the database with the following columns: User_id – int User_name – varchar(20) Password – varchar(10) Help him by writing SQL queries for both tasks. OR (b) Ms. Rita is a database administrator at a school. She is working on the table, student containing the columns like Stud_id, Name, Class and Stream. She has been asked by the Principal to strike off the record of a student named Rahul with student_id as 100 from the school records and add another student who has been admitted with the following details: Stud_id – 123 Name – Rajeev Class – 12 Stream – Science Help her by writing SQL queries for both tasks.

Solution hidden

Log in to view solution →
Q25 short answer 2 marks
Predict the output of the following code: def Total (Num=10): Sum=0 for C in range(1,Num+1): if C%2!=0: continue Sum+=C return Sum print(Total(4),end="$") print(Total(),sep="@")

Solution hidden

Log in to view solution →
Q26 short answer 3 marks
Predict the output of the Python code given below: s="India Growing" n = len(s) m="" for i in range(0, n): if (s[i] >= 'a' and s[i] <= 'm'): m = m + s[i].upper() elif (s[i] >= 'O' and s[i] <= 'z'): m = m + s[i-1] elif (s[i].isupper()): m = m + s[i].lower() else: m = m + '@' print(m)

Solution hidden

Log in to view solution →
Q27 short answer 3 marks
Consider the table Stationery given below and write the output of the SQL queries that follow. Table: Stationery ITEMNO ITEM DISTRIBUTOR QTY PRICE 401 Ball Pen 0.5 Reliable Stationers 100 16 402 Gel Pen Premium Classic Plastics 150 20 403 Eraser Big Clear Deals 210 10 404 Eraser Small Clear Deals 200 5 405 Sharpener Classic Classic Plastics 150 8 406 Gel Pen Classic Classic Plastics 100 15 (i) SELECT DISTRIBUTOR, SUM(QTY) FROM STATIONERY GROUP BY DISTRIBUTOR; (ii) SELECT ITEMNO, ITEM FROM STATIONERY WHERE DISTRIBUTOR = "Classic Plastics" AND PRICE > 10; (iii) SELCET ITEM, QTY * PRICE AS "AMOUNT" FROM STATIONERY WHERE ITEMNO = 402;

Solution hidden

Log in to view solution →
Q28 short answer
(a) Write a method/function COUNTWORDS() in Python to read contents from a text file DECODE.TXT,

Solution hidden

Log in to view solution →
Q28 short answer 3 marks
Write a method/function COUNTWORDS() in Python to read contents from a text file DECODE.TXT, to count and return the occurrence of those words, which are having 5 or more characters. OR Write a method/function COUNTLINES() in Python to read lines from a text file CONTENT.TXT, and display those lines, which have @ anywhere in the line. For example: If the content of the file is: Had an amazing time at the concert last night with @MusicLoversCrew. Excited to announce the launch of our new website! G20 @ India The method/function should display Had an amazing time at the concert last night with @MusicLoversCrew G20 @ India

Solution hidden

Log in to view solution →
Q29 short answer 3 marks
Consider the table Rent_cab, given below: Table: Rent_cab Vcode VName Make Color Charges 101 Big car Carus White 15 102 Small car Polestar Silver 10 103 Family car Windspeed Black 20 104 Classic Studio White 30 105 Luxury Trona Red 9 Based on the given table, write SQL queries for the following: (i) Add a primary key to a column name Vcode. (ii) Increase the charges of all the cabs by 10%. (iii) Delete all the cabs whose maker name is "Carus".

Solution hidden

Log in to view solution →
Q30 short answer 3 marks
A dictionary, d_city contains the records in the following format: {state:city} Define the following functions with the given specifications: (i) push_city(d_city): It takes the dictionary as an argument and pushes all the cities in the stack CITY whose states are of more than 4 characters. (ii) pop_city(): This function pops the cities and displays "Stack empty" when there are no more cities in the stack.

Solution hidden

Log in to view solution →
Q31 short answer 4 marks
Consider the tables GAMES and PLAYERS given below: Table: GAMES GCode GameName Type Number PrizeMoney 101 Carrom Board Indoor 2 5000 102 Badminton Outdoor 2 12000 103 Table Tennis Indoor 4 NULL 104 Chess Indoor 2 9000 105 Lawn Tennis Outdoor 4 25000 Table: PLAYERS PCode Name GCode 1 Nabi Ahmad 101 2 Ravi Sahai 108 3 Jatin 101 4 Nazneen 103 Write SQL queries for the following: (i) Display the game type and average number of games played in each type. (ii) Display prize money, name of the game, and name of the players from the tables Games and Players. (iii) Display the types of games without repetition. (iv) Display the name of the game and prize money of those games whose prize money is known.

Solution hidden

Log in to view solution →
Q32 short answer 4 marks
Mr. Mahesh is a Python Programmer working in a school. He has to maintain the records of the sports students. He has created a csv file named sports.csv, to store the details. The structure of sports.csv is: [sport_id, competition, prize_won] where sport_id is Sport id (integer) competition is competition name (string) prize_won is ("Gold", "Silver", "Bronze") Mr. Mahesh wants to write the following user-defined functions: Add_detail(): to accept the detail of a student and add to a csv file, "sports.csv". Count_Medal(): to display the name of competitions in which students have won "Gold" medal. Help him in writing the code of both the functions.

Solution hidden

Log in to view solution →
Q33 short answer 5 marks
Logistic Technologies Ltd. is a Delhi based organization which is expanding its office set-up to Ambala. At Ambala office campus, they are planning to have 3 different blocks for HR, Accounts and Logistics related work. Each block has a number of computers, which are required to be connected to a network for communication, data and resource sharing. As a network consultant, you have to suggest the best network related solutions for them for issues/problems raised in (i) to (v), keeping in mind the distances between various block/locations and other given parameters. Distances between various blocks/locations : HR Block to Accounts Blocks 400 meters Accounts Block to Logistics Block 200 meters Logistics Block to HR Block 150 meters Delhi Head Office to Ambala Office 220 Km Number of computers installed at various blocks are as follows : HR Block 70 Accounts Block 40 Logistics Block 30 (i) Suggest the most appropriate block/location to house the SERVER in the Ambala office. Justify your answer. (ii) Suggest the best wired medium to efficiently connect various blocks within the Ambala office compound. (iii) Draw an ideal cable layout (Block to Block) for connecting these blocks for wired connectivity. (iv) The company wants to schedule an online conference between the managers of Delhi and Ambala offices. Which protocol will be used for effective voice communication over the Internet ? (v) Which kind of network will it be between Delhi office and Ambala office ?

Solution hidden

Log in to view solution →
Q34 short answer 5 marks
(a) (i) What is the main purpose of seek() and tell() method ? (ii) Consider a binary file, Cinema.dat containing information in the following structure : [Mno, Mname, Mtype] Write a function, search_copy(), that reads the content from the file Cinema.dat and copies all the details of the "Comedy" movie type to file named movie.dat.

Solution hidden

Log in to view solution →
Q34 short answer 5 marks
(b) (i) Give one difference between write() and writeline() function in text file. (ii) A Binary file, "Items.dat" has the following structure : [Icode, Description, Price] Where Icode – Item code Description – Detail of item Price – Price of item Write a function Add_data(), that takes Icode, Description and Price from the user and writes the information in the binary file "Items.dat".

Solution hidden

Log in to view solution →
Q35 short answer 5 marks
(a) (i) Define the term foreign key with respect to RDBMS. (ii) Sangeeta wants to write a program in Python to delete the record of a candidate “Raman” from the table named Placement in MySQL database, Agency: The table Placement in MySQL contains the following attributes : CName – String Dept – String Place – String Salary – integer Note the following to establish connectivity between Python and MySQL : · Username – root · Password – job · Host – localhost Help Sangeeta to write the program in Python for the above mentioned task.

Solution hidden

Log in to view solution →
Q35 short answer 5 marks
(b) (i) Give one difference between CHAR and VARCHAR datatype in MySQL. (ii) Rahim wants to write a program in Python to insert the following record in the table named Bank_Account in MySQL database, Bank : · Accno – integer · Cname – string · Atype – string · Amount – float Note the following to establish connectivity between Python and MySQL : · Username – admin · Password – root · Host – localhost The values of fields Accno, Cname, Atype and Amount have to be accepted from the user. Help Rahim to write the program in Python.

Solution hidden

Log in to view solution →