CS XII - MTP-2 (Solved)
CS XII - MTP-2 (Solved)
CLASS XII
COMPUTER SCIENCE (083)
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:
Functions can alter only mutable type values. (1)
Ans. True
2. Identify the output of the following code snippet. (1)
Str4 = " Learning Python ".strip().lower().replace(" ", "_")
print(Str4)
(a) learning_python (b) learning python
(c) learning_Python (d) Learning_Python
Ans. (a) learning_python
3. Which of these expressions evaluates to True? (1)
(a) 3 + 3 == 7
(b) not (10 < 20 and 20 > 30)
(c) 4 * 5!= 20
(d) not(1 == 1) and not(0)
Ans. (b) not (10 < 20 and 20 > 30)
4. What will be the output of the given expression? (1)
a = (4, 5, 6)
b = (a,)
print(b)
(a) (4, 5, 6)
(b) (4, 5, 6, 4, 5, 6)
(c) ((4, 5, 6),)
(d) Error
Ans. (c) ((4, 5, 6),)
Section C
29. (A) Write a Python function that reads ‘Words.txt’ and displays the number of times the word ‘Python’
appears in the file. (3)
OR
(B) Write a Python function that reads ‘Words.txt’ and displays the first 5 words from the file.
Ans. (A) def count():
count = 0
try:
with open('Words.txt', 'r') as file:
for line in file:
words = line.split()
for word in words:
if word == "Python":
count += 1
print('The word "Python" appears', count, 'times in the file.')
except FileNotFoundError:
print("Error: The file was not found.")
OR
(B) def display_words():
try:
with open('Words.txt', 'r') as file:
words = []
for line in file:
words.extend(line.split())
if len(words) >= 5:
break
print("The first 5 words in the file are:", words[:5])
except FileNotFoundError:
print("Error: The file Words.txt was not found.")
30. (A) In a call centre, customer complaints are handled through a Stack named ComplaintStack. Each
complaint is represented as a list with details: complaint_id, customer_name and complaint_details.
Write the following user-defined functions in Python to perform the specified operations on
ComplaintStack: (3)
Section D
32. Consider the given table DONATIONS. (4)
Field Type
movieID int(11)
movieName varchar(40)
genre varchar(20)
releaseYear int(4)
rating float
Write the following Python function to perform the specified operation:
Add_Display(): to input details of a movie and store it in the table MOVIES. The function should then retrieve
and display all records from MOVIES table where the rating is greater than 7.5.
Assume the following for Python-Database connectivity:
Host: localhost
User: admin
Password: movies123
Ans. def AddAndDisplay():
import mysql.connector as mycon
mydb=mycon.
connect(host="localhost",user="admin",passwd="movies123",database=
"MOVIEDB")
mycur=mydb.cursor()
mid=int(input("Enter Movie ID: "))
nm=input("Enter Movie Name: ")
gr=input("Enter Movie Genre: ")
year=int(input("Enter Movie Release Year: "))
rating=float(input("Enter Movie Rating"))
query="INSERT INTO movies(movieid, moviename, genre, releaseyear,
rating)VALUES (%s,%s,%s,%s,%s)"
Section E
36. Hitesh wants to manage the records of the faculty members in his university. For this, he wants the following
information of each faculty member to be stored: (5)
• Faculty_ID – integer
• Faculty_Name – string
• Department – string
• Years_of_Service – integer
As a programmer, you have been assigned to do this job for Hitesh.
(I) Write a function to input the data of a faculty member and append it in a binary file.
(II) Write a function to update the Department to ‘Senior Faculty’ for all faculty members with more than
15 years of service.
(III) Write a function to read the data from the binary file and display the data of all those faculty members
who are not in ‘Senior Faculty’ department.
Ans. (I) import pickle
def input_faculty():
faculty = []
n = int(input("Enter the number of faculty members you want to
add: "))
for i in range(n):
faculty_id = int(input("Enter Faculty ID: "))
faculty_name = input("Enter Faculty Name: ")
department = input("Enter Department of faculty: ")
yearofservice = float(input("Enter years of service: "))
faculty.append([faculty_id, faculty_name,
department,yearofservice])
return faculty
faculty_list = input_faculty()
def append_faculty_data(faculty):
with open('FacultyMembers.bin', 'ab') as f:
for i in faculty:
pickle.dump(faculty, f)
print("Faculty members data appended successfully.")
append_faculty_data(faculty_list)
(II) import pickle
def update_senior_faculty():
updated_faculty = []
try:
PUNE
LAB RESEARCH
ADMIN AUDITORIUM
From To Distance
LAB RESEARCH 100m
LAB ADMIN 60m
LAB AUDITORIUM 150m
RESEARCH ADMIN 65m
RESEARCH AUDITORIUM 120m
ADMIN AUDITORIUM 50m
LAB 15
RESEARCH 20
ADMIN 30
AUDITORIUM 10
(I) Suggest the most appropriate location for the server inside the Pune campus. Justify your choice.
(II) Which hardware device would you suggest to connect all computers within each department?
(III) Draw the cable layout to efficiently connect various departments within the Pune campus. Which cable
would you suggest for the most efficient data transfer over the network?
(IV) Is there any requirement of a repeater in the given cable layout? Justify your answer.
(V) (A) Which of the following would be best for holding an online seminar with participants from both
the Pune campus and remote locations?
(i) Videoconferencing
(ii) Instant Messaging
(iii) Email
(iv) Telephony
OR
(B) Which type of network (PAN, LAN, MAN or WAN) would be appropriate for connecting the
departments within the Pune campus?
Ans. (I) LAB department is the ideal location for the server in the Pune campus as it has the maximum number
of computers.
(II) Switch
(III)
ADMIN