0% found this document useful (0 votes)
62 views

CS XII - MTP-1 (Solved)

Uploaded by

rahulkrana6899
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
0% found this document useful (0 votes)
62 views

CS XII - MTP-1 (Solved)

Uploaded by

rahulkrana6899
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
You are on page 1/ 11

APPENDIX D

MODEL TEST PAPER 1 (SOLVED)


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

General Instructions:
• This question paper contains 37 questions.
• All questions are compulsory. However, internal choices have been provided in some questions. Attempt only
one of the choices in such questions.
• The paper is divided into 5 Sections—A, B, C, D and E.
• Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
• Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
• Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
• Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
• Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
• All programming questions are to be answered using Python language only.
• In case of MCQ, text of the correct answer should also be written.

Section A
1. State whether the following statement is True or False: (1)
The arguments of range() function in Python must be integers.
Ans. True
2. Identify the output of the following code snippet: (1)
text = "Hello World from Python"
modified_text = text.title().strip().replace("o", "@").replace(" ", "-")
print(modified_text)
(a) Hell@-W@rld-fr@m-Pyth@n (b) Hell@-W@rld-from-Pyth@n
(c) Hello-World-from-Python (d) Hell@-World-from-Python
Ans. (a) Hell@-W@rld-fr@m-Pyth@n
3. Which of the following expressions evaluates to True? (1)
(a) True and not (False or True) (b) False or (True and False)
(c) True or (False and True) (d) False and (True or False)
Ans. (c) True or (False and True)
4. What will be the output of the given expression? (1)
text = "Hello, welcome to the world of Python!"
print(text.find("world"))
(a) 13 (b) 18
(c) 22 (d) –1
Ans. (c) 22
5. What will be the output of the following code snippet? (1)
course = "AdvancedMachineLearning"
result = course[0:9] + course[10:18]
print(result)
(a) AdvancedMchineLea (b) AdvancedMachineLea
(c) AdvancedMacchineLea (d) AdvancedMachineLearn
Ans. (a) AdvancedMchineLea
6. What will be the output of the following code?(1)
t1 = (1, 2, 3)
t2 = (4, 5)
result = t1 * 2 + t2
print(result)
(a) (1, 2, 3, 1, 2, 3) + (4, 5) (b) (1, 2, 3, 4, 5)
(c) (2, 4, 6, 8, 10) (d) (1, 2, 3, 1, 2, 3, 4, 5)
Ans. (d) (1, 2, 3, 1, 2, 3, 4, 5)
7. If car_info is a dictionary as defined below, then which of the following statements will raise an
exception?(1)
car_info = {'make': 'Toyota', 'model': 'Corolla', 'year': 2020}
(a) car_info['model'] = 'Camry' (b) car_info['year'] = 2021
(c) print(car_info.get('make')) (d) print(car_info['color'])
Ans. (d) print(car_info['color'])
8. Which of the following statements accurately describes the behaviour of the update() method when used
with dictionaries in Python? (1)
(a) It creates a new dictionary by merging the original dictionary with another dictionary or iterable and
returns this new dictionary.
(b) It replaces the values of the keys that already exist in the dictionary with the values from another
dictionary or iterable and adds new key-value pairs if they do not exist in the original dictionary.
(c) It only adds new key-value pairs from another dictionary or iterable to the original dictionary without
modifying any existing key-value pairs.
(d) It removes key-value pairs from the original dictionary that are present in another dictionary or iterable.
Ans. (b) It replaces the values of the keys that already exist in the dictionary with the values from another
dictionary or iterable and adds new key-value pairs if they do not exist in the original dictionary.
9. If a table has three candidate keys and two alternate keys, then how many primary keys will this table
have?(1)
Ans. A table has only one primary key.
10. Write the missing statement to complete the following code: (1)
file = open("records.txt", "r")
content = file.read()
_________________ # Move the file pointer to the beginning of the file
firstline = file.readline()
file.close()
Ans. file.seek(0)
11. State whether the following statement is True or False: (1)
IOError is raised in Python when an index is not found in a sequence, i.e., it is out of range or out of bounds.
Ans. False
12. What will be the output of the following code? (1)
z = 30
def cal():
    z = 60
    print(z, end="#")
cal()
z = z + 10
print(z, end="@")
(a) 60#70@ (b) 60#30@
(c) 60#40@ (d) 60@40#
Ans. (c) 60#40@
13. Which SQL command is used to add a primary key constraint to an existing table? (1)
Ans. ALTER TABLE command is used to add a primary key constraint to an existing table.

A.36 Computer Science with Python–XII


14. What will be the output of the following query? (1)
SELECT AVG(salary) FROM Employees WHERE department = 'HR';
(a) The average salary of all employees in the Employees table.
(b) The average salary of employees whose department is ‘HR’, including those with NULL values for salary.
(c) The average salary of employees whose department is ‘HR’, excluding NULL values for salary.
(d) The total salary of all employees in the Employees table whose department is ‘HR’.
Ans. (c) The average salary of employees whose department is ‘HR’, excluding NULL values for salary.
15. In a table in MySQL database, an attribute X of datatype varchar(15) has the value ‘Computer’. The attribute
Y of datatype char(15) has the value ‘Science’. How many characters are occupied by attribute X and
attribute Y? (1)
(a) 15, 7 (b) 8, 15
(c) 8, 7 (d) 7, 8
Ans. (b) 8, 15
16. What does COUNT() function return when used as COUNT(*) with SQL SELECT statement? (1)
(a) The number of distinct rows
(b) The sum of all values
(c) The number of non-NULL values
(d) The total number of rows in the table, including NULL values
Ans. (d) The total number of rows in the table, including NULL values
17. Which type of network topology has a central hub or switch? (1)
(a) Mesh Topology (b) Bus Topology
(c) Star Topology (d) Ring Topology
Ans. (c) Star Topology
18. Which device can selectively forward data based on MAC address, thereby reducing unnecessary traffic? (1)
(a) Bridge (b) Switch
(c) Router (b) Hub
Ans. (a) Bridge
19. Why is a switch called an intelligent hub? (1)
Ans. A switch is called an intelligent hub because it forwards the message across a network only to the intended node.
Q.20 and 21 are Assertion and Reasoning based questions. Mark the correct choice as:
(a) Both A and R are true and R is the correct explanation for A.
(b) Both A and R are true but R is not the correct explanation for A.
(c) A is true but R is false.
(d) A is false but R is true.
20. Assertion (A): A function in Python can be called before it is defined in the code.
Reason (R): Python uses a top-down approach for code execution. (1)
Ans. (d) A is false but R is true
21. Assertion (A): A foreign key establishes a relationship between two tables.
Reason (R): A foreign key must contain unique values in the parent table. (1)
Ans. (b) Both A and R are true but R is not the correct explanation for A.

Section B
22. Why are lists called mutable data type? Explain with examples. (2)
Ans. Lists are called mutable data type because the values in a list can be changed or modified and can be accessed
using the index value enclosed within square brackets.
For example:
L = [1,3,6,7,98]
L[2] = 56
The new list is L = [1,3,56,7,98].

Appendices A.37
23. What is implicit conversion in Python? (2)
Ans. Implicit conversion in Python is also known as coercion. This conversion means that the data type conversion
is done automatically during run-time and is not instructed by the programmer.
For example:
x=9
y=99.0
z=x+y
print(z)
So, it gives the output 108.0 as implicit conversion is performed to convert it into float automatically.
24. Answer the following using built-in functions only. (2)
If T1= (3,5,7,9) and T2 = (1,2,4,6), then
I. (a) Write a statement to convert T1 to a list.
OR
(b) Write a statement to find the maximum value from tuple T2.
II. (a) Write a statement to find the sum of all elements in T1.
OR
(b) Write a statement to find the length of T2.
Ans. I. (a) L1 = list(T1)
OR
(b) Max_Value = max(T2)
II. (a) T_Sum= sum(T1)
OR
(b) T2_length = len(T2)
25. Identify the correct output(s) of the following code. Also write the minimum and the maximum possible values
of the variable val. (2)
import random
s =[100,75,10,125]
val =random.randint(0,3)
for j in range(val):
   print(s[j],"$$")
(a) 100$$ (b) 100$$
75$$ 99$$
10$$
(c) 150$$ (d) 125$$
100$$ 10$$
Ans. The correct output is:
(a) 100$$
75$$
10$$
The minimum value of variable val is 0 and the maximum value of variable val is 3.
26. The following code is intended to check whether a number is positive or not; if negative, then make it a
positive number. However, there are syntax and logical errors in the code. Rewrite it after removing all
errors. Underline all the corrections made. (2)
DEF check_num():
         num = input("Enter a number:")
         if (abs(num)= num):
            print"You entered a positive number"
         else:
            num=*-1
            print"Number made positive:"num
check_num()

A.38 Computer Science with Python–XII


Ans. The correct code is as follows:
def check_num():
         num = input("Enter a number:")
         if (abs(num)== num):
            print("You entered a positive number)"
         else:
            num*=-1
            print__("Number made positive:",num)
check_num()
27. I. (a) What constraint should be used to ensure that a column contains unique values but must not
accept NULL entries? (2)
OR
(b) What constraint can be applied to a table column to ensure that all entries meet a specific condition
such as allowing only positive numbers?
II. (a) Write the SQL command to create a unique constraint on the Marks column in a table named Student.
OR
(b) Write the SQL command to make the column Product_ID the primary key of an already existing table,
named PRODUCT.
Ans. I. (a) Primary Key constraint
OR
(b) Check constraint
II. (a) ALTER TABLE Student
ADD CONSTRAINT UNIQUE (Marks);
OR
(b) ALTER TABLE PRODUCT
ADD PRIMARY KEY (Product_ID);
28. (a) List one advantage and one disadvantage of bus topology. (2)
OR
(b) What does WAN stands for? Describe.
Ans. (a) One advantage of bus topology is that nodes can be connected or removed easily from bus network.
One disadvantage of bus topology is that if there is a fault or breakdown of the backbone (main cable), the
entire network shuts down.
OR
(b) WAN stands for Wide Area Network.
It is a telecommunication network that spreads over a large geographical area across countries and
continents. It facilitates fast and efficient exchange of information at high speed and low cost, for
example, the internet.

Section C
29. (a) Write a Python function called Replace_ Word(filename, old_word, new_word) that takes three
parameters: filename (string), old_word (string) and new_word (string). The function should replace
all occurrences of old_word with new_word in the specified file. (3)
OR
(b) Write a Python function called Unique_Words(filename) that takes a single parameter, filename (string).
The function should read the content of the specified file and return a set of unique words.
Ans. (a) def Replace_Word_in_file(filename, old_word, new_word):
   try:
    with open(filename, 'r') as file:
     content = file.read()
    content = content.replace(old_word, new_word)
    with open(filename, 'w') as file:
     file.write(content)
   except FileNotFoundError:
    return "File not found."
Note: Users can take any filename, old word and new word.

Appendices A.39
OR
(b) def Unique_Words(filename):
   try:
with open(filename, 'r') as file:
text = file.read()
words = text.split()
return set(words)
   except FileNotFoundError:
return "File not found."

Note: Users can take any filename.
30. (a) Consider a dictionary containing names and fees as key-value pairs of 5 doctors. Write a program with
separate user-defined functions to perform the following operations: (3)
(i) Push the keys (name of the doctors) of the dictionary into a Stack where the corresponding value
(fees) is greater than 1000.
(ii) Pop and display the contents of the Stack.
The dictionary should be as follows:
doc={"Reena":500,"Amrita":1000,"Shama":900,"Vishal":1500,"Vyom":2000}

Then the output will be:
Vishal, Vyom

OR
(b) Write functions in Python, do_push(Num) and do_pop(Num), to add a new number and delete a
number from a list of numbers, considering them to act as push and pop operations of the
Stack data structure.
Ans. (a) def push(stk,item):
  stk.append(item)
def pop(stk):
  if stk==[]:
      return None
  else:
      return stk.pop()
stk=[]
doc={"Reena":500, "Amrita": 1000, "Shama":900, "Vishal":1500, "Vyom":2000}
for i in doc:
if doc[i] > 1000:
      push(stk,i)
while True:
  if stk!=[]:
      print(pop(stk),end=" ")
  else:
break
OR
(b) def do_push(Num):
a=int(input("Enter a number:"))
  Num.append(a)
def do_pop(Num):
  if(Num==[]):
      print("stack empty")
  else:
print("Deleted element",Num.pop())

A.40 Computer Science with Python–XII


31. Predict the output of the following code: (3)
(a) products = {
   "Laptop": 1000,
   "Smartphone": 600,
   "Tablet": 300,
   "Headphones": 150
}
discounted_products = {}
for product, price in products.items():
    discounted_price = price * 0.9 # Apply a 10% discount
    discounted_products[product] = discounted_price
print(discounted_products)
OR
(b) matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
]
result = []
for i in range(len(matrix)):
    row_sum = 0
    for j in range(len(matrix[i])):
       row_sum += matrix[i][j]
   result.append(row_sum)
print(result)
Ans. (a) {'Laptop': 900.0, 'Smartphone': 540.0, 'Tablet': 270.0, 'Headphones': 135.0}
OR
(b) [6, 15, 24]

Section D
32. Consider the given table STUDENT:(4)
Table: STUDENT


Note: The table contains more records than shown here.
(a) Write the following queries:
(i) To display the records in alphabetical order as per the name of the student.
(ii) To display the average marks of Delhi students.
(iii) To display the details of students whose names end with the letter ‘a’.
(iv) To display the total number of students studying in class XI or XII.
OR
(b) Write the output:
(i) Select * from STUDENT where gender = 'F' and marks>350;
(ii) Select RollNo, DOB, City from STUDENT where Marks between 200 and 300;
(iii) Select Min(Marks ) from STUDENT;
(iv) Select Name, Marks from STUDENT where city IN ('Agra', 'Dubai');

Appendices A.41
Ans. (a) (i) Select * from STUDENT order by Name;
(ii) Select avg(Marks) from STUDENT where city = "Delhi";
(iii) Select * from STUDENT where Name like '%a';
(iv) Select count(*) from STUDENT where Class = 'XI' or Class = 'XII';
(b) (i)
RollNo Name Class DOB Gender City Marks
3 Sonal XI 1994-05-06 F Delhi 400
4 Trisla XII 1995-08-08 F Mumbai 450
7 Neha X 1995-12-08 F Moscow 377
(ii)
RollNo DOB City
6 1994-12-12 Dubai
(iii)
Min(Marks)
250
(iv)
Name Marks
Nanda 551
Marisla 250
33. Write user-defined functions to perform read and write operations on to a ‘teacher.csv’ file having fields
TeacherID, Name, Subject and Experience (in years). (4)
Ans. import csv
row=['2101','Amrita Rana', 'Science','15']
def readcsv():
   with open("teacher.csv",'r') as f:
     data=csv.reader(f)
     for row in data:
         print(row)
def writecsv():
   with open("teacher.csv",'w',newline='') as fobj:
     csv_w=csv.writer(fobj,delimiter=',')
     csv_w.writerow(row)
print("Press 1 to read data and Press 2 to write data")
a=int(input())
if a==1:
    readcsv()
elif a==2:
    writecsv()
else:
    print("Invalid value")
34. Dhriti works in Prilknot Pvt. Ltd. She needs to access some information from SALESMAN and CUSTOMER tables.
Help her extract the following information by writing the desired SQL queries as mentioned below. (4)
Table: SALESMAN
Salesman_id Name City Commission
5001 Jai Chauhan New York 0.15
5002 Neil Mahajan Paris 0.13
5005 Priyank Chawla London 0.11
5006 Prerna Malhotra Paris 0.14
5007 Jyoti Singh Rome 0.13
5003 Aaren Kumar San Jose 0.12

A.42 Computer Science with Python–XII


Table: CUSTOMER
Customer_id Cust_name City Grade Salesman_id
3002 Sunita Mishra New York 100 5001
3007 Sujata New York 200 5001
3005 Amir Suri California 200 5002
3008 Kiaansh Soni London 300 5002
3004 Chirag Puri Paris 300 5006
3009 Kanika Kapoor Berlin 100 5003
3003 Kamlesh Yadav Moscow 200 5007
3001 Sumit Aneja London 100 5005
(a) To display the details (from both the tables) of the salesmen whose commission is less than 0.15.
(b) To display the details of customers whose grade is in the range of 100 to 400.
(c) To increase the grade by 250 of all the customers who belong to New York.
(d) (i) To display the names and id of customers who belong to Moscow or London.
OR
(ii) To display the cartesian product of these two tables.
Ans. (a) Select * from SALESMAN s, CUSTOMER c where commission <0.15 and s.
Salesman_id=c. Salesman_id;
(b) Select * from CUSTOMER where Grade between 100 and 400;
(c) Update CUSTOMER set Grade = Grade + 250 where City='New York';
(d) (i) Select Cust_name, Customer_id from CUSTOMER where City IN ('Moscow',
'London');
OR
(ii) Select * from SALESMAN, CUSTOMER;
35. A table, named VEHICLE in MOTORSDB database, has the following structure: (4)

Field Type
Vehicle_id Int(8)
Vehicle_Name Varchar(20)
Price Float
Quantity Int(10)
Write the following Python function to perform the specified operation:
Show_data() to display and read only those records in which Quantity more than 100.
Note the following to establish connectivity between Python and MySQL:
Host: localhost
Username: root
Password: motors
Ans. import mysql. connector as mysql
def show_data():
   con1=mysql.connect(host="localhost", user="root", password="motors",\
                   database ="MOTORSDB")
    mycursor=con1.cursor()
   print("Vehicles having quantity more than 100")
   mycursor. execute ("Select * from vehicle where quantity > 100")
    data=con1.commit()
   for i in data:
     print(i)
    print()

Appendices A.43
Section E
36. Shreya is a manager working in Le Hotels Group of J&G industry. She needs to manage the records of various
hotels. For this, she wants the following information of each hotel to be stored: (5)
Hotel_ID – Integer
Hotel_Name – String
Location – String
No_of _Rooms – Integer
As a programmer of the company, you have been assigned to do this job for Shreya.
(a) Write a function to input the data for a record and add to a binary file.
(b) Write a function in Python which accepts Location as a parameter and counts and returns the number of
hotels by the given location stored in a binary file.
Ans. (a) import pickle
def datafile():
    f=open("Hotel.dat","rb")
   Hotel_ID=int(input("Enter hotel id"))
   Hotel_Name=input("Enter name of the hotel")
   Location=input("Enter location of the hotel")
   No_of_Rooms=int(input("Enter number of rooms in a hotel"))
   record=[Hotel_ID, Hotel_Name, Location, No_of_Rooms]
    pickle.dump(record,f)
    f.close()
(b) import pickle
def CountRecords(Location):
    f=open("Hotel.dat","rb")
    count=0
    try:
     while True:
        record=pickle. load(f)
     if Location == record[2]:
        count=count+1
     except:
        f. close()
     return count
37. Canvo International Inc. is planning to connect its Bengaluru Office Set-up with its Head Office in Delhi. The
Bengaluru Office of Canvo International Inc. is spread across an area of approximately 1 square kilometre,
consisting of 3 blocks: Human Resources, Administration and Academics. As a network expert, you have to
suggest solutions to the following five queries, i.e., (a) to (e), raised by them, keeping in mind the distances
between various blocks and the number of computers in each block. (5)

Bengaluru Office Set-up


Delhi
Head Human Resources
Office
Administration Academics

Shortest distances between various blocks:


Human Resources to Administration 100 m
Human Resources to Academics 65 m
Academics to Administration 110 m
Delhi Head Office to Bengaluru Office Set-up 2350 km

A.44 Computer Science with Python–XII


Number of computers installed in various blocks are as follows:
Human Resources 155
Administration 20
Academics 100
Delhi Head Office 20

(a) Suggest the most suitable block in the Bengaluru Office Set-up to host the server. Give a suitable reason.
(b) Suggest a cable layout among the various blocks within the Bengaluru Office Set-up for connecting the
blocks.
(c) Suggest a suitable networking device to be installed in each block, essentially required for connecting
computers inside the blocks with fast and efficient connectivity.
(d) Suggest the most suitable media to provide secure, fast and reliable data connectivity between the Delhi
Head Office and the Bengaluru Office Set-up.
(e) (i) What would be your recommendation for enabling live visual communication between the Bengaluru
Office and the Delhi Head Office from the following options?
I. Videoconferencing
II. Instant Messaging
III. Email
IV. Telephony
OR
(ii) Which type of network (PAN, LAN, MAN or WAN) will be set up among the computers connected in the
Bengaluru Office?
Ans. (a) The most suitable block to host the server is Human Resources because it has the maximum number of
computers.
(b)
Human Resources
65 m 100 m
Academics
Administration
(c) Switch
(d) Satellite link
(e) (i) I. Videoconferencing
OR
(ii) LAN

For CBSE Sample Question Paper (with Solutions) scan

Appendices A.45

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy