Sample Paper CS 083 Preboard 1
Sample Paper CS 083 Preboard 1
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 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
Ans = True
2. Which of the following identifier names are valid: 1
a. 100_Percent. =90
b. True = 1
c. Total Marks=500
d. SerialNo=10
Ans: d
3. Consider the given statement and state whether it’s True or False: 1
Ans: True
4. Write logical expressions corresponding to the following statements in 1
Python and evaluate the expressions:
The sum of 20 and –10 is less than 12.
a. (20 + (-10)) < 12
b. if 20-10 < 12
c. If sum(20-10)< 12
d. None
Ans: a
5. Select the correct output of the given code: 1
var2 = -3+7.2j
print(var2, type(var2))
a. (-3+7.2j)
b. (-3+7.2j) <class 'complex'>
c. (-3+7.2j) <class 'float'>
d. None
Ans: b
6. Select the correct output of the given code: 1
s= 'Congratulations'
print(.replace('a','@'))
print(s.split('ra',4))
a. Congr@tul@tions
['Cong', 'tulations']
b. Congr@tul@tions
['ra', 'tulations']
c. Congr@tul@tions
['Cong', 'ra']
d. None
Ans: a
7. Fill in the blanks: 1
___ will open the text file for reading only and ___will do the same for
binary format file. This is also the default mode. The file pointer is
placed at the beginning for reading purpose, when the file is open in this
mode.
a. r,rb
b. +r, rb
c. r+,+rb
d. None
Ans: a
8. The DISTINCT keyword is used to ____________in a particular column. 1
a. remove duplicate values
b. delete values
c. drop values
d. None
Ans: a
9. Ms. Ravina is using a table 'customer' with custno, name, address and 1
phonenumber. She needs to display name of the customers, whose
name start with letter 'S'.
She wrote the following command, which did not give the result.
Select * from customer where name="S";
Help Ms. Ravina to run the query by removing the errors and write the
correct query.
a. Select * from customer where name like "S%";
b. Select * from customer where name = "S";
c. Select * from customer where name = "S%";
d. None
Ans: a
10. Pooja has created a table Hospital having columns: 1
Patient_No
Patient_Name
Age
Symptom
Now she wants to add a new column ‘Address’ in the above given table.
Suggest to her suitable MySQL command for the same.
a. Alter table Hospital add Address varchar(20);
b. Add address varchar(20);
c. Alter table Hospital Address varchar(20);
d. None
Ans: a
11. Fill in the blank 1
________can be used to store any kind of object in file as it allows us to
store python objects with their structure for storing data in binary
format.
a. Pickle module
b. Seek()
c. Tell()
d. None
Ans: a.
12. _____________provides an error free connection which is always faster 1
than the latest conventional modems.
a. Telnet
b. VoIP
c. IRS
d. MSN relay chat
Ans: a
13. What will the following expression be evaluated to in Python? 1
print(23/3 -5 * 7+(14 -2))
a. -15.33
b. 'int' object is not callable
c. Will give a type error
d. -40.00
Ans: a.
Apply PEMDAS
14. The ______________is used to retrieve data that meet some specified 1
conditions.
a. WHERE clause
b. Orderby
c. Distinct
d. Groupby
Ans: a
15. To create a connection between the MySQL database and Python, 1
the _____ method of mysql.connector module is used.
a. connector()
b. connect()
c. pip install()
d. mysql.connector()
Ans: b
16. This method is used to position the file object at a particular position in
a text file.
a. seek()
b. tell()
c. offset()
d. fileobject()
Ans: a
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): Explicit conversion, or type casting happens when data 1
type conversion takes place.
Reasoning(R): With explicit type conversion, there is a risk of loss of
information since we are forcing an expression to be of a specific type.
Ans: (a) Both A and R are true and R is the correct explanation for A
18. Assertion (A): The pickle module deals with binary files. Here, data are 1
not written but dumped and similarly, data are not read but loaded.
Reason(R): Hence, the Pickle Module must be imported to load and
dump data.
Ans: (a) Both A and R are true and R is the correct explanation for A
SECTION B
19. Rao has written a code to showcase division operation. His code is 2
having no validation for zero division, validate and rewrite the correct
code
print ("Handling Devision")
try:
numerator=50
denom=int(input("Enter the denominator: "))
print (numerator/denom)
print ("Division performed successfully")
except ValueError:
print ("Only INTEGERS should be entered")
Ans:
print ("Handling Devision")
try:
numerator=50
denom=int(input("Enter the denominator: "))
print (numerator/denom)
print ("Division performed successfully")
except ZeroDivisionError:
print ("Denominator as ZERO is not allowed")
except ValueError:
print ("Only INTEGERS should be entered")
except:
print(" OOPS.....SOME EXCEPTION RAISED")
20. Write two points of difference between SMTP and POP3 2
Ans:
OR
Name The transmission media best suitable for connecting to hilly
areas. Write the expanded form of wifi
Ans:
CS SEAIAINfr@2
30 o OTNMX CEB
Ans:
{"John" : 01, "Rick" : 02, "Sam" : 03}
{'John': 1, 'Sam': 3, 'liking': 'programing'}
22. What is the use of Candidate key in RDBMS. Can candidate key be used 2
as primary key, justify.
Ans:
A relation can have one or more attributes that takes distinct values.
Any of these attributes can be used to uniquely identify the tuples in the
relation. Such attributes are called candidate keys as each of them are
candidates for the primary key.
Ans:
Telnet stands for Teletype Network
Simple Mail Transfer Protocol
Ans:
[('a', 23), ('b', 37), ('c', 10), ('d', 29)]
(('c', 10),)
OR
Predict the output of the python code given below:
def change(tuple1):
list1 =list(tuple1)
print(tuple1)
del(list1[1])
return list1
Ans:
(11, [222, 33], 44, 55)
[11, 44, 55]
25. What is the purpose of the following clauses in a select statement? 2
i) ORDER BY
ii) GROUP BY
OR
Ans:
Cartesian product operation combines tuples from two relations. It
results in all pairs of rows from the two input relations, regardless of
whether or not they have the same values on common attributes. It is
denoted as ‘X’.
Students to support the answer by providing an example
SECTION C
Table: Sale
(i) SELECT CustID, COUNT(*) "Number of Cars" FROM SALE
GROUP BY CustID;
(ii) SELECT CustID, COUNT(*) FROM SALE GROUP BY CustID
HAVING Count(*)>1;
(iii) SELECT PaymentMode, COUNT(PaymentMode) FROM SALE
GROUP BY Paymentmode ORDER BY Paymentmode
(iv) SELECT PaymentMode, Count(PaymentMode) FROM SALE
GROUP BY Paymentmode HAVING COUNT(*)>1 ORDER BY
Paymentmode;
Ans:
(i)
(ii)
(iii)
(iv)
27. Write a method display() to read lines from a text file MYNOTES.TXT, 3
and display those line that begins with the letter ‘M’.
Ans:
OR
Write a function overlap in python to read two .txt files, prime
numbers.txt and happynumbers.txt, that have lists of numbers in
them, find the numbers that are overlapping.
Ans:
28. a. Write the output of the SQL queries (i) to (iv) based on the relations 3
tables INSTITUTE and ADMIN given below:
Table: INSTITUTE
Table: ADMIN
(i) Select Designation Count (*) From Admin Group By Designation
Having Count (*) <2;
(ii) SELECT max (EXPERIENCE) FROM INSTITUTE;
(iii) SELECT TEACHER FROM INSTITUTE WHERE EXPERIENCE >12
ORDER BY TEACHER;
(iv) SELECT COUNT (*), GENDER FROM ADMIN GROUP BY GENDER;
Ans:
Ans:
30. Write a program to accept a string from the user and reverse the string 3
using following user define functions:
POP()- to check underflow and pop an element from the stack.
PUSH()- to add an element in the stack
ReverseString()-to reverse a string using, push the string elements in to
the string, pop the elements and display the reverse string.
OR
Rishi has created a dictionary containing names and total marks of the
students. Write a program having following user defined functions to
perform the following operations.
func_push()- push the keys ie the names of the students with their
corresponding marks where the marks > 75
func_pop() – pop and displays the content of the dictionary.
Sample input:
OUTPUT:
TOM
ANU
BOB
OM
Ans:
SECTION D
Number of Computers:
Wing A 11
Wing S 210
Wing J 105
Wing H 55
print('x is:::', x)
print('This is Global x:::', x)
def outer():
x = 10
print('x is:::', x)
print('This is enclosed x:::', x)
def inner():
x = 30
print('Now x is :::',x)
print('This is local x:::', x)
print("Builtin", len("abc"))
inner()
outer()
Ans:
x is::: 40
This is Global x::: 40
x is::: 10
This is enclosed x::: 10
Now x is ::: 30
This is local x::: 30
Builtin 3
Ans:
OR
a. Convert the following program using while loop and predict the
output
for i in range(4):
for j in range(i):
print('$', end='')
print('\n ')
Ans:
i=0
while i < 4:
j=0
i=i+1
while j < i:
print('$', end='')
j=j+1
print('\n')
Ans:
$
$$
$$$
$$$$
b. The code given below is to create a table school having following
fields:
stud_id varchar 200, stud_name varchar 215, address v
archar 215, city char 200
for x in _______: # statement 3 to display the inserted data from the Table
print(x)
Ans:
my_database = mysql.connector.connect ( host = 'localhost', database = 'col
lege', user = 'root', password = 'root@123' )
cursor = my_database.cursor() #to form a cursor object
cursor. execute( " CREATE TABLE school ( stud_id varchar(200) PRIMARY KEY,
stud_name VARCHAR(215), address VARCHAR(215), city char(100)) " )
cursor = my_database.cursor() # to form the cursor object
33. Amritya Seth is a programmer, who has recently been given a task to 5
write a python code to perform the following binary file operations with
the help of two user defined functions/modules:
a. AddStudents() to create a binary file called STUDENT.DAT containing
student information – roll number, name and marks (out of 100) of each
student.
b. GetStudents() to display the name and percentage of those students
who have a percentage greater than 75. In case there is no student
having percentage > 75 the function displays an appropriate message.
The function should also display the average percent.
Ans:
OR
Define pickling. What is the difference between dump() and load()
methods.
Ans:
Pickling is the process by which a Python object is converted to a byte
stream.
dump() method is used to write the objects in a binary file.
load() method is used to read data from a binary file
students are suppose of support their answer with a sample code/
solution.
SECTION E
34. A shop called Wonderful Garments who sells school uniforms maintains 4
a database SCHOOLUNIFORM as shown below. It consisted of two
relations - UNIFORM and COST. They made UniformCode as the primary
key for UNIFORM relations. Further, they used UniformCode and Size to
be composite keys for COSTrelation. By analysing the database schema
and database state, specify SQL queries to rectify the following
anomalies.
a. Write sql query to change the name of relation from price to cost.
b. M/S Wonderful Garments also keeps handkerchiefs of red colour,
medium size of Rs. 100 each. Insert this record in cost table.
c. Add the constraint so that the price of an item is always greater
than zero.
Ans:
35. Rohit, a student of class 12th, is learning CSV File Module in Python. 4
During examination, he has been assigned an incomplete python code
(shown below) to create a CSV File 'Student.csv' (content shown below).
Help him in completing the code which creates the desired CSV File.
1, ASHIS, XII, A
2, AMRIT, XII, A
3, ABHAY, XII, A
Write the suitable code for statement 1 to statement 5
Ans:
1. csv
2. "Student.csv","w"
3. writer(fh)
4. roll_no,name,Class,section
5. writerows()
Reference:
NCERT BOOKS
https://ncert.nic.in/textbook.php?kecs1=0-11
https://cbseportal.com/ncert-books/class-12-computer-science
https://www.teachoo.com/16336/3712/Question-8-Choice-1/category/CBSE-Class-12-
Sample-Paper-for-2022-Boards--Term-2----Computer-Science/
https://brainly.in/textbook-solutions/q-pooja-created-table-bank-sql-later-column
https://www.zigya.com/study/book?class=12&board=CBSE&subject=Computer+and+Comm
unication+Technology&book=Computer+Science+With+Python&chapter=Inheritance&q_ty
pe=SAT&q_topic=&question_id=COEN12163471
https://byjus.com/question-answer/write-logical-expressions-corresponding-to-the-
following-statements-in-python-and-evaluate-the-expressions-assuming/
https://csiplearninghub.com/computer-network-class-12-questions-answers/
https://www.sarthaks.com/443792/indian-public-school-darjeeling-setting-network-
between-different-wings-senior-junior
https://cbseacademic.nic.in/web_material/QuestionBank/ClassXII/ComputerScienceXII.pdf
https://techtipnow.in/a-shop-called-wonderful-garments-that-sells-school-uniforms-
maintain-a-database-school_uniform-as-shown-below-it-consisted-of-two-relations-
uniform-and-price/