67% found this document useful (3 votes)
3K views10 pages

Class 12 Computer Science Model Test 1

This document contains a model test paper for Class XII Computer Science with 5 sections (A-E). Section A contains 18 multiple choice questions worth 1 mark each. Section B contains 7 short answer questions worth 2 marks each. Section C contains 5 short answer questions worth 3 marks each. Section D contains 3 long answer questions worth 5 marks each. Section E contains 2 questions worth 4 marks each, with 1 internal choice in question 34c. All programming questions must be answered using Python.

Uploaded by

Namratha Murugan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
67% found this document useful (3 votes)
3K views10 pages

Class 12 Computer Science Model Test 1

This document contains a model test paper for Class XII Computer Science with 5 sections (A-E). Section A contains 18 multiple choice questions worth 1 mark each. Section B contains 7 short answer questions worth 2 marks each. Section C contains 5 short answer questions worth 3 marks each. Section D contains 3 long answer questions worth 5 marks each. Section E contains 2 questions worth 4 marks each, with 1 internal choice in question 34c. All programming questions must be answered using Python.

Uploaded by

Namratha Murugan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • General Instructions
  • Sections A-B: Objective and Short Questions
  • Sections C-D: SQL Queries and Python Programming
  • Section E: Database Practical Applications

MODEL TEST PAPER–1

CLASS XII
COMPUTER SCIENCE (083)
Maximum Marks: 70 Time Allowed: 3 hrs

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q34 against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION – A
1. State True or False: “Keywords can be used as identifiers in Python.” (1)
2. Which of the following is an invalid identifier in Python? (1)
(a) Roll_No (b) Salary
(c) Account No (d) EmpID
3. Which of the following will delete key-value pair for key = “Red” from a dictionary D1? (1)
(a) delete D1(“Red”) (b) del.D1(“Red”)
(c) del D1[“Red”] (d) del D1
4. What will be the output of the following statement: (1)
print(3-10**2+99/11)
(a) 80 (b) 81
(c) -81 (d) 81.0
5. What will be the output of the following code? (1)
Str1= ‘My name is digital’
Str2=Str1[3:7]
strlen = len(Str2)
print(strlen)
(a) 4 (b) 14
(c) 24 (d) 34
6. Which of the following functions is used to write data in the binary mode? (1)
(a) write (b) output
(c) dump (d) send
7. Fill in the blank: (1)
______ keyword is used to display non-repeated values in MySQL.
(a) Unique (b) Remove
(c) Distinct (d) All
8. Which of the following commands will change row(s) of the table from MySQL database? (1)
(a) REPLACE TABLE (b) CHANGE TABLE
(c) UPDATE (d) ALTER TABLE

Model Test Paper–1 A.1


9. Which of the following statement(s) would give an error after executing the following code? (1)
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
(a) Statement 1 (b) Statement 2
(c) Statement 3 (d) Statement 4
10. Fill in the blank: (1)
_________ is a table constraint that will prevent the entry of duplicate rows.
(a) Primary Key (b) NULL
(c) Unique (d) Distinct
11. Which of the following is the correct syntax of file object ‘fobj’ to write sequence data type using writelines()
function? (1)
(a) [Link](sequence)
(b) [Link]()
(c) [Link](sequence)
(d) [Link]()
12. Fill in the blank: (1)
HAVING clause is used in combination with ____________ clause.
(a) GROUP BY (b) Where
(c) IN (d) Order By
13. The network that connects many organizations spread over one or more countries or continents is
known as: (1)
(a) WWW (b) LAN
(c) PAN (d) WAN
14. Which statement consists of a logical operator? (1)
(a) a+b**c (b) a >b:
(c) a and b not c (d) 2 in a
15. Which of the following function can work with NULL values in a database? (1)
(a) avg() (b) sum()
(c) count(*) (d) total(*)
16. Which command is used for counting the number of rows in a database? (1)
(a) row (b) rowcount
(c) count() (d) row_count
Q17 and 18 are Assertion and Reason-based questions. Mark the correct choice:
(i) Both A and R are true and R is the correct explanation for A
(ii) (ii) Both A and R are true and R is not the correct explanation for A
(iii) A is True but R is False
(iv) A is False but R is True
17. Assertion (A): Function can take input values as parameters, execute them and return output (if required)
to the calling function with a return statement. (1)
Reason (R): A function in Python can return multiple values.
18. Assertion (A): Pickle in Python is primarily used in serializing and deserializing a Python object structure.
Reason (R): [Link]() method is used to write the object in file and [Link]() method is used to read
the object from pickled file. (1)
A.2 Computer Science–XII
SECTION – B
19. Shristi has written a Python program to add all the numbers of the list. Her code is having errors. Rewrite
the correct code and underline the corrections made. (2)
define sum(numbers):
total = 0
for x in numbers
total += x
returns total
print(sum([4, 6, 3, 5, 6]))
20. What is the use of Modem and Router in a network? (2)
OR
Write two points of difference between Star topology and Bus topology.
21. (a) Given is a Python string declaration: (2)
mySubject = "Computer Science with Python"
(i) Write the output of: print(mySubject[-27:-10:2])
(b) Write the output of the code given below:
>>>a=[10,20,30,40,50,60,70]
>>> a[3:5]=[100,1000]
>>> a[3:5]=[10000]
>>> print(a)
22. What is the difference between ‘Primary Key’ and ‘Foreign Key’? Can a table have multiple Primary keys or
Foreign keys? (2)
23. (a) What is the use of VoIP? (1)
(b) Write the full form of: (i) POP (ii) XML (1)
24. Write the output of the given code: (2)
def Display(l):
L2=[]
for n in l:
if n % 2 == 0:
[Link] (n)
return l2
print(Display([100, 228, 333, 432, 509, 60, 787, 800, 967]))
OR
Predict the output of the Python code given below:
t1=(10,20,"book",30,9.5,"item",[12,13],(3,4),30,5,30)
print([Link](20))
print( [Link](30))
print([Link](30))
print(t1[–8:–4])
25. Write any two aggregate functions in SQL with an appropriate example. (2)
OR
Write two commands each of DDL and DML commands in SQL.

Model Test Paper–1 A.3


SECTION – C
26. (a) Consider the following tables – CARDEN and CUSTOMER: (1+2)
Table: CARDEN Table: CUSTOMER
Code CarName Charges Code CarName
501 A-Star 18 1001 Hemant Sahu
503 Indigo 16 1002 Raj Lal
502 Innova 15 1003 Feroza Shah
509 SX4 14 1004 Ketan Dhar
What will be the output of the following statement?
SELECT * FROM CARDEN, CUSTOMER;
(b) Write the output of the queries (i) to (iv) based on the table, STOCK given below:
Table: STOCK
ItemNo Item Dcode Qty UnitPrice StockDate
5005 Ball Pen 0.5 102 100 16 2010-03-31
5003 Ball Pen 0.25 102 150 20 2010-01-01
5002 Gel Pen Premium 101 125 14 2010-02-14
5006 Gel Pen Classic 101 200 22 2009-01-01
5001 Eraser Small 102 210 5 2009-03-19
5004 Eraser Big 102 60 10 2009-12-12
5009 Sharpener Classic 103 160 8 2009-01-23
Table: DEALERS
Dcode DName
101 Reliable Stationers
103 Classic Plastics
102 Clear Deals
(i) SELECT Dcode, MAX(UnitPrice) FROM STOCK GROUP BY Dcode;
(ii) SELECT COUNT(DISTINCT Dcode) FROM STOCK;
SELECT
(iii) Qty*UnitPrice FROM STOCK WHERE ItemNo=5006;
(iv) SELECT MIN(StockDate) FROM STOCK;
27. Write a user-defined function Count_H_T() in Python that displays the number of lines starting with ‘H’ and
‘T’ in the file “[Link]”. Example, if the file contains: (3)
Here we go round the mulberry bush,
The mulberry bush,
The mulberry bush.
Here we go round the mulberry bush
On a cold and frosty morning.
The line count should be 4.
OR
Write a function Replace_Space() in Python which should read each character of a text file “[Link]”
and then replace all spaces from text with dash (-).
Example:
If the file content is as follows:
The relative paths are relative to current working directory.
The Replace_Space() function should display the output as:
The-relative-paths-are-relative-to-current-working-directory.
A.4 Computer Science–XII
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the relations MOBILEMASTER & MOBILESTOCK
given below: (3)
Table: MOBILEMASTER
M_Id M_Company M_Name M_Price M_Mf_Date
MB001 Samsung Galaxy 4500 2013-02-12
MB003 Nokia N1100 2250 2011-04-15
MB004 Micromax Unite3 4500 2016-10-17
MB005 Sony XperiaM 7500 2017-11-20
MB006 Oppo SelfieEx 8500 2010-08-21
Table: MOBILESTOCK
S_Id M_Id M_Qty M_Supplier
S001 MB004 450 New Vision
S002 MB003 250 Praveen Gallery
S003 MB001 300 Classic Mobile Store
S004 MB006 150 A-one Mobiles
S005 MB003 150 The Mobile
S006 MB006 50 Mobile Centre
(i) SELECT M_Company, M_Name, M_Price,M_Qty FROM MOBILEMASTER MM,
MOBILESTOCK MS, WHERE MM.M_ID= MS.M_ID;
(ii) SELECT MAX(M_Price) FROM MOBILEMASTER WHERE M_Name LIKE "S%";
(iii) SELECT M_Supplier, M_Qty FROM MOBILESTOCK WHERE M_Id ="MB003";
(iv) SELECT M_Company FROM MOBILEMASTER WHERE M_Price BETWEEN 3000 AND
5000;
(b) Write a command to open an existing database ‘Stock’.
29. Write the definition of a method COUNTNOW(PLACES) to find and display those place names in which there
are more than five characters after storing the name of places in a dictionary. (3)
For example, if the dictionary PLACES contains:
{'1': "DELHI", '2': "LONDON", '3': "PARIS", '4': "NEW YORK", '5': "DUBAI"}
The following output should be displayed:
LONDON NEW YORK
30. A list contains the following record of a Hostel: [Hostel_No, Total_Students, Total Rooms] (3)
Write the following user defined functions to perform given operations on the stack named ‘Hostel’:
(i) Push_element() - To push an object containing Hostel_No and Total Students along with Total Rooms
to the stack
(ii) Pop_element() - To pop the objects from the stack and display them. Also, display “Stack Empty” when
there are no elements in the stack.
For example:
If the lists of Hostel details are:
[1,2000,1000]
[2, 1500,800]
[3,5000,2000]
The output should be:
[1,2000,1000]
[2, 1500,800]
[3,5000,2000]
Stack Empty

Model Test Paper–1 A.5


OR
Write a program to implement a Stack for book_details (book name : book price) where book name is a key
and book price is value. Write a function in Python, Push(book_details) where book_details is a dictionary
containing the details of books– {book_name : book_price}. The function should push the names of those
books in the stack which have price greater than 500. Also display the count of books pushed into the stack.
For example: If the dictionary contains the following data: books={"Python":560,"Java":450,"MySQL":330,"Web
Development":725}
The stack should contain Python and Web Development.
The output should be: The count of books in the stack is 2.
SECTION – D
31. Sony has set up its Branch at Srinagar for its office and web-based activities. It has four zones of buildings
as shown in the diagram: (5)
Zone Zone
Z Y

Zone Zone
X U
Branch-to-branch distance is:
Zone X to Zone Z 40 m
Zone Z to Zone Y 60 m
Zone Y to Zone X 135 m
Zone Y to Zone U 70 m
Zone X to Zone U 165 m
Zone Z to Zone U 80 m
Number of Computers:
Zone X 50
Zone Z 130
Zone Y 40
Zone U 15
(a) Suggest the most suitable cable layout or Networking Topology of connections between the zones.
(b) Suggest the most suitable place (i.e., Zone) to house the Server of this organization. Give a suitable
reason with justification.
(c) Suggest the placement of the following devices with justification:
(i) Repeater (ii) Hub/Switch
(d) Which is the most economic type of cable for the selected topology?
(e) Suggest a device/software to be installed in each branch to take care of data security.
32. (a) Write the output of the code given below: (2+3)
Val = 100
def display(N):
global Val
Val = 100
if N%2==0:
Val = Val ** N
else:
Val = Val * N
print(Val, end="$")
display(2)
print(Val)

A.6 Computer Science–XII


(b) The code given below inserts the following record in the table Fun_City:
Ticket_Id – integer
Name – string
Ticket_Price – integer
No_Of_Tickets – integer
Total_Amount – integer
Note the following to establish connectivity between Python and MySQL:
• Username is root
• Password is Ticket
• The table exists in a MySQL database named Amusement.
• The details (Ticket_Id, Name, Ticket_Price, No_of_Tickets) are to be accepted by the user.
Write the following missing statements to complete the code:
Statement 1 – To form the cursor object
Statement 2 – Write a command to execute the query
Statement 3 – Write a command to save data permanently in the database.
import [Link] as mysql
def sql_data():
con=[Link](host="localhost",user="root", password="Ticket",
database="Amusement")
mycursor=_________________ #Statement 1
Ticket_No=int(input("Enter Ticket Number :: "))
Name=input("Enter Name :: ")
Ticket_Price= input("Enter Ticket Price :: ")
No_Of_Tickets=int(input("Enter No of tickets :: "))
Total_Amount= Ticket_Price * No_Of_Tickets
query="Insert into Fun_City values({},'{}',{},{})".format(Ticket_No,
Name, Ticket_Price, No_Of_Tickets, Total_Amount)
____________________ #Statement 2
______________________ #Statement 3
print("Data Added successfully")
OR
(a) Predict the output of the code given below:
def Change(s):
k =len(s)
m=" "
for i in range(0,k):
if(s[i].isupper()):
m=m+s[i].lower()
elif s[i].isalpha():
m=m+s[i].upper()
else:
m=m+'$'
print(m)
Change('IPv6 128-bit')

Model Test Paper–1 A.7


(b) The code given below reads the following record from the table named Employee and displays only
those records who have a Salary greater than 75000:
• EmpNo – integer
• EmpName – string
• Designation – string
• Salary – integer
Note the following to establish connectivity between Python and MySQL:
• Username is root
• Password is sales_emp
• The table exists in a MySQL database named “Office”.
Write the following missing statements to complete the code:
• Statement 1 – To form the cursor object
• Statement 2 – To execute the query that extracts records of those employees whose salaries are
greater than 75000.
• Statement 3 – To read the complete result of the query (records whose salaries are greater than
75000) into the object named data from the table employee in the database.
import [Link] as mysql
def SQL_Office():
con=[Link](host="localhost",user="root", password="sales_emp",
database="Office")
mycursor=_______________ #Statement 1
print("Employees with salaries greater than 75000 are : ")
_______________ #Statement 2
data=__________________ #Statement 3
for i in data:
print(i)
print()
33. What is the function of [Link]() function? (5)
Write a program in Python that defines and calls the following user-defined functions:
(i) AddRecord() – To accept and add data of Mobile phones to a CSV file ‘Mobile_Phones.csv’. Each record
consists of a list with field elements as ModelNo, MobileName, Manufacturer and Price to store model
number, mobile name, manufacturer and price respectively.
(ii) Find() – To search the records of mobiles manufactured by Apple present in the CSV file named
‘Mobile_Phones.csv’.
OR
What is the benefit of using “with open()” method over “open()” method while opening a file?
Write a program in Python that defines and calls the following user-defined functions:
(i) Add_Item() – To accept and add data of stationery items to a CSV file ‘[Link]’. Each record
consists of a list with field elements as Item_Id, Item_name and Item_price to store item id,
item_name and item_price.
(ii) Count() – To count the total number of stationery items in the CSV file.

A.8 Computer Science–XII


SECTION – E
34. Krishna, working as a computer professional in a hospital, creates a table OPD to store records of patients
registered in the OPD section. A sample of the records is given below: (1+1+2)
Table: OPD
Reg No Name Age Department Dateof_Reg Charges Gender Room No
R0123 Arpita 62 Gen. Physician 2022-01-21 500 M 10
R0124 Jai 22 ENT 2022-10-12 300 M 15
R0125 Kamal 32 Orthopaedic 2022-02-19 500 M 11
R0126 Arun 12 Paediatrician 2022-07-11 500 M 12
R0127 Neha 30 ENT 2022-01-12 300 F 15
R0128 Neetu 16 ENT 2022-09-24 300 F 15
R0129 Ankit 29 Cardiology 2022-02-20 800 F 20
Based on the data given above, answer the following questions:
(i) If the table “OPD” is to be linked with another table “Registration” in the same database named
“Hospital”, then identify the most appropriate column which can be used as a Foreign key in the
“Registration” table.
(ii) What is the cardinality and degree of the given table?
(iii) Write the statements to:
(a) Insert the following record into the table: RegNo–R130, Name–Naman, Age–30, Department–
ENT, Dateof_Reg–2022-10-10, Charges–700, Gender–M.
(b) Increase the OPD Charges of the ENT department by ` 200.
OR (Option for part iii only)
(iii) Write the statements to:
(a) Delete the column RoomNo from the table OPD.
(b) Add a new column Panel_Discount in the table with datatype as Varchar with 50 characters.
35. Vedansh is a Python programmer working in a school. For the Annual Sports Event, he has created a binary
file ‘[Link]’ with Student_Id, St_Name, Game_Name and Result to store the results of students in
different sports events. After the event has been completed, he now wants to display the records of those
students who won the game, which is inserted in the Result field with ‘Won’ and ‘Loss’ data. As a Python
expert, help him complete the following code based on the requirement given above: (1+1+1+1)
import ___________ #Statement1
rec=[]
while True:
Student_Id=int(input(("Enter Student Id:")))
St_name=input("Enter name:")
Game_Name=input("Enter Salary:")
Result= input(“Enter Result:”)
data=[Student_Id, St_Name, Game_Name,Result]
[Link](data)
Choice=input("Wish to enter more records: Y/N")
if [Link]()=='N':
break
f1=____________________#Statement2
[Link](rec,f1)
print("Record added:")

Model Test Paper–1 A.9


fout=open("[Link]",'rb')
res=________________ #Statement 3
count=0
for i in res:
if __________________: #Statement 4
st_id=i[0]
st_name=i[1]
game=i[2]
result=i[3]
count+=1
print(st_id,st_name,game,result)
print("Total students are", count)
[Link]()
(i) Write a statement to import the module. (Statement 1)
(ii) Write a statement to open a binary file in write mode. (Statement 2)
(iii) Write the correct statement required to load the file. (Statement 3)
(iv) Write a statement to check if result field contains ‘Won’ or ‘won’. (Statement4)

A.10 Computer Science–XII

Common questions

Powered by AI

'UPDATE' and 'ALTER TABLE' serve different purposes in SQL operations. 'UPDATE' is used to modify existing records in a table, ideal for changing content of specific cells based on conditions or across the entire column. On the other hand, 'ALTER TABLE' changes the structure or metadata of the table itself, such as adding or dropping columns, indexes, or constraints. The choice reflects the intention: 'UPDATE' is for data modification, ensuring the data remains current, while 'ALTER TABLE' is for schema evolution, allowing the database structure to adapt to new requirements or optimizations .

Assertion and reason-based questions test different cognitive skills compared to traditional multiple-choice questions by evaluating both factual knowledge and the student's ability to understand and apply logical reasoning. These questions require students to not only identify the correctness of a statement but also to justify it, thus testing their understanding of causal relationships and the interconnectivity of concepts. This approach encourages deep comprehension, critical thinking, and the ability to articulate reasoning, skills that are crucial for advanced learning and problem-solving .

Both 'Primary Key' and 'Unique' constraints are used to prevent duplicate entries in a database. A 'Primary Key' is a table constraint that enforces uniqueness for the row identifier and requires that no fields in that column be null, making it essential for establishing relationships between tables. Conversely, a 'Unique' constraint allows null values and can be applied to any column to ensure all its entries are unique, without designating a row identifier. 'Primary Key' is preferred for identifying records uniquely across tables, while 'Unique' is used when only the column's data needs to be exclusive without affecting table relationships .

Python does not allow keywords to be used as identifiers because keywords have predefined meanings and are reserved for specific purposes within the language's syntax, such as defining control structures, functions, or other language constructs. Allowing them to be used as identifiers would cause ambiguity and confusion, hindering code readability and maintainability. This restriction enforces clarity and consistency, encouraging programmers to use meaningful, descriptive identifiers while avoiding names that can be confusing or misleading due to their predefined roles .

Logical operators in Python, such as 'and', 'or', and 'not', influence code execution by determining the flow and control structures based on conditions. Understanding their precedence is crucial because it affects how expressions are evaluated; 'not' has the highest precedence, followed by 'and', then 'or'. Misunderstanding this order can lead to logic errors, incorrect conditional statements, and unexpected behavior in programs. Properly using logical operators enables correct decision-making processes and efficient code execution in many programming tasks .

DDL (Data Definition Language) commands are used to define and modify database structures, including commands like CREATE, ALTER, and DROP, affecting the database schema but not the data. DML (Data Manipulation Language), including SELECT, INSERT, UPDATE, and DELETE, is used to manage the data within these structures. The primary implication of using DDL is that it can change the framework of a database, which is generally slower and affects database integrity. DML is more dynamic and frequent, operating on the data itself without altering the schema, thereby supporting data retrieval and manipulation operations essential for daily database interactions .

Using "with open()" in Python is advantageous because it ensures that files are properly closed after usage, including during exceptions, removing the need for an explicit close() call and thus reducing the risk of resource leaks. It also results in cleaner code and better handling of file operations. However, this convenience comes at the cost of potentially obscuring some error handling decisions regarding file closure, which might be necessary in specific applications requiring explicit control over file lifecycle .

When serializing complex Python objects using Pickle, it's essential to consider compatibility between Python versions, as Pickle formats may change, potentially causing deserialization errors. Security is another concern because untrusted data can include executable code, leading to execution during deserialization if improperly handled. Additionally, serializing objects with non-serializable components like open file pointers can cause errors or incomplete state captures. Developers need to ensure that only safe, compatible objects are pickled, often opting for alternatives like JSON when security and compatibility are a priority .

The 'HAVING' clause is used with 'GROUP BY' to filter groups of rows returned by a query based on specified conditions, often used for aggregate data filtering where 'WHERE' cannot be applied to aggregate functions. This combination allows for querying results that are processed by aggregation, like calculating sums or averages, and then filtering these results to display groups meeting certain criteria. Queries that require conditions on aggregated data, such as finding departments with average salaries above a threshold, benefit significantly from the use of 'HAVING' .

A Modem serves as the bridge between the local network and the internet, converting digital data from a computer to analog for transmission over phone lines and vice versa. A Router, on the other hand, connects multiple networks together, directing data packets between connected devices on a local network and providing a firewall layer. Both devices complement each other as the modem brings internet connectivity to the local network, which the router can then distribute to multiple devices, managing data traffic and maintaining security .

You might also like