XII MS Computer Science PB-1 (2023-24)
XII MS Computer Science PB-1 (2023-24)
XII MS Computer Science PB-1 (2023-24)
CLASS-XII
SUBJECT: COMPUTER SCIENCE (083)
TIME: 3:00 Hours M.M.: 70
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
Q35 against part c only.
8. All programming questions are to be answered using Python Language only.
SECTION A 1*18=18
1. Which of the following is not a valid identifier name in Python? 1
a) 5Total b) _Radius c) pie d) While
2. Which is valid keyword? 1
a) Int b) WHILE c) While d) if
3 Which Constraint not allow to enter repeated values in the table? 1
a) PRIMARY KEY b) UNIQUE c) BOTH A and B d) None of above
4. Consider the following expression: 1
51+4-3**3//19-3
Which of the following will be the correct output if the expression is evaluated?
a) 50 b) 51 c) 52 d) 53
5. Select the correct output of the code: 1
Str=“Computer Science”
Str=Str[-4:]
print(Str*2)
a) ence b) enceence c) ecneecne d) None of these
6. Which module is imported for working with CSV files in Python? 1
a) csv b) python-csv connector c) CSV d) python.csvconnector
7. Fill in the blank: _____ command is used to update records in the MySQL table. 1
a) ALTER b) UPDATE c) MODIFY d) SELECT
8. Which command used to fetch rows from the table in database? 1
a) BRING b) FETCH c) GET d) SELECT
9. Which of the following statement(s) would give an error after executing the following 1
code?
print(9/2) # Statement-1
print(9//2) # Statement-2
print(9%%2) # Statement-3
print(9%2) # Statement-4
a) Statement-1 b) Statement-2 c) Statement-3 d) Statement-4
10. Fill in the blanks: 1
_______ is the table constraint used to stop null values to be entered in the field.
a) Unique b) Not NULL c) Not Empty d) None
11 The correct syntax of read() function from text files is: 1
a) file_object.read() b) file_object(read)
c) read(file_object) d) file_object().read
12 In SQL, we use _____ command to display the list of databases in the server. 1
a) SELECT DATABASES; b) SELECT DATABASE;
c) SHOW DATABASES; d) DESC;
13 Fill in the blank: ________ protocol is used to send mail. 1
a) SMTP b) FTP c) POP d) HTTPS
14 In a stack, if a user tries to remove an element from empty stack it is called _____. 1
a) Underflow b) Empty c) Overflow d) Blank
15 Which method is used for object serialization in Python? 1
a) Pickling b) Un-pickling c) Merging d) None of the above
16 To establish a connection with MySQL from Python which of the following functions is 1
used?
a) connection() b) connect() c) open() d) cursor()
Q17 and 18 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 and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17. Assertion (A):- In stack, program should check for Underflow condition, before 1
executing the pop operation.
Reasoning (R):- In stack, underflow mean there is no element available in the stack or
stack is an empty stack. Ans: A
18. Assertion (A):- The readlines() method in python reads all lines from a text file. 1
Reasoning (R):- The readlines() method returns the tuple of lines(string). Ans: C
Section B 2*7=14
19. Rajat has written the following Python code. There are some errors in it. Re-write the 2
correct code and underline the corrections made.
DEF execmain():
x = input("Enter a number:")
if (abs(x)=x):
print ("You entered a positive number")
else:
x=*-1
print "Number made positive:"x
execmain()
20. What is difference between message switching and packet switching? 2
OR
What is difference between delete and drop command in sql.
21. a. Find output generated by the following code: 2
mystr = “Hello I am a Human.”
print(mystr[::-3]) Ans: .m mIlH
SECTION C 3*5=15
26. Consider the following tables Trainer and Course: 3
i. Suggest the most suitable location to install the main server of this institution to
get efficient connectivity.
ii. Suggest by drawing the best cable layout for effective network connectivity of the
blocks having server with all the other blocks.
iii. Suggest the devices to be installed in each of these buildings for connecting
computers installed within the building out of the following:
Modem, Switch, Gateway, Router
iv. Suggest the most suitable wired medium for efficiently connecting each computer
installed in every building out of the following network cables: Coaxial Cable,
Ethernet Cable, Single Pair, Telephone Cable
v. Suggest the type of network implemented here.
Ans:
(i) Admin Block. Because of Maximum Computers.
(iii) Switch
(iv) Ethernet cable
(v) LAN
32. a). Write the output of following python code:def result(s): 5
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] >= 'n' and s[i] <= 'z'):
m= m + s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '#'
print(m)
result('Cricket') Ans: cCICKEe
b). Avni is trying to connect Python with MySQL for her project. Help her to write the
python statement on the following:
i. Name the library, which should be imported to connect MySQL with Python.
ii. Name the function, used to run SQL query in Python.
iii. Write Python statement of connect function having the arguments values as
: Host name :192.168.11.111
User : root
Password: Admin
Database : MYPROJECT
Ans:
i. import mysql.connector
ii. cursorobj.execute(query)
iii. mysql.connector.connect(host= “192.168.11.111”, user = “root”, passwd =
“Admin”, database= “MYPROJECT”)
OR
a). Write the output of following python code:
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)
Ans: G*L*TME
b). Your friend Jagdish is writing a code to fetch data from a database Shop and
table name Products using Python. He has written incomplete code. You have to help
him write complete code:
import _mysql.connector_ as m # Statement-1
object1 =
m.connect(host="localhost",user="root",password="root",database="Shop")
object2 = object1.cursor()_____ # Statement-2
query = '''SELECT * FROM Products WHERE NAME LIKE "A%";'''
object2._execute____(query) # Statement-3
object1.close()
OR
i. DELETE FROM TRAINER WHERE TNAME = “Richa”;
ii. ALTER TABLE TRAINER ADD Remarks VARCHAR(50);
35 Priti of class 12 is writing a program to create a CSV file “emp.csv”. She has written 4
the following code to read the content of file emp.csv and display the employee
record whose name begins from “S‟ also show no. of employee with first letter “S‟
out of total record. As a programmer, help her to successfully execute the given task.
Consider the following CSV file (emp.csv):
1,Peter,3500
2,Scott,4000
3,Harry,5000
4,Michael,2500
5,Sam,4200
import ____csv_ #Line-1
defsnames():
with open( emp.csv”, “r” ___) as csvfile: #Line-2
myreader = csv._reader__ (csvfile, delimiter=",") # Line-3
count_rec=0
count_s=0
for row in myreader:
if row[1][0].lower() == "s":
print(row[0],",",row[1],",",row[2])
count_s += 1
count_rec += 1
print(count_rec, count_s)
i. What should be written in Line-1?
ii. In which mode should Priti open the file to print the data? Read mode
iii. What should be written in Line-2 and Line-3?