0% found this document useful (0 votes)
51 views15 pages

Cs Paper-3

This document contains a multiple choice question paper with 27 questions across 3 sections. The questions cover topics related to Python, databases, networking and general computer concepts. Some questions have code snippets or table data and ask the student to interpret the output, find errors, write SQL queries or Python code. This appears to be a practice or sample question paper for an exam.

Uploaded by

rishabh
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)
51 views15 pages

Cs Paper-3

This document contains a multiple choice question paper with 27 questions across 3 sections. The questions cover topics related to Python, databases, networking and general computer concepts. Some questions have code snippets or table data and ask the student to interpret the output, find errors, write SQL queries or Python code. This appears to be a practice or sample question paper for an exam.

Uploaded by

rishabh
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/ 15

SECTION A Marks

1. Find output generated by the following code: 1


p=10
q=20
p*=q//3
q+=p=q**2
print(p,q)
2. A database can have only one table(True/False) 1

3. Which one of the following refers to the copies of the same data (or 1
information) occupying the memory space at multiple places.
a) Data Repository
b)Data Inconsistency
c)Data Mining
d)Data Redundancy

4. MAC address is of ___________ 1


a) 24 bits
b) 36 bits
c) 42 bits
d) 48 bits
5. Read following statement about features of CSV file and select which 1
statement is TRUE?
Statement1: Only database can support import/export to CSV format
Statement2: CSV file can be created and edited using any text editor
Statement3: All the columns of CSV file can be separated by comma only
a. Statement 1 and statement 2
b. Statement 2 and statement 3
c. Statement 2
d. Statement 3

251 | P a g e
6. What is the output of the following program if the student.csv file contains 1
following data?
Student.csv
Ronit, 200
Akshaj, 400

import csv
d = csv.reader(“student.csv”)
next (d)
for row in d:
print (row);
7. The command used to skip a row in a CSV file is 1
A. next()
B. skip()
C. omit()
D. bounce()
8.Inspecting the value at the stack’s top without removing it. 1
a) peak operation
b) insert operation
c) pop operation
d) push operation

9.Stacks serve major role in ______________ 1


a) Simulation of recursion
b) Simulation of linked list
c) Simulation of limited resource allocation
d) Simulation of all data

10. Which statement will give the output as : True from the following : 1
a) >>>not -5
b) >>>not 5 1
c) >>>not 0
d) >>>not(5-1)

252 | P a g e
11. Give the output of the following code: 1

>>>import math
>>>math.ceil(1.03)+math.floor(1.03)
a) 3
b) -3.0
c) 3.0
d) None of the above

12. The input() function always returns a value of ……………..type. 1

a) Integer
b) float
c) string
d) Complex

13. Directions: In the following questions, A statement of Assertion (A) is 1


followed by a statement of

Reason (R). 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 correct explanation for A.
(C) A is true but R is false.
(D) A is false but R is true.

Question.
Assertion (A): A referential integrity is a system of rules of DBMS.
Reason (R): It ensures that user don't accidently delete or change related data.

14. Directions: In the following questions, A statement of Assertion (A) is


followed by a statement of
Reason (R). Mark the correct choice as.

253 | P a g e
(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 correct explanation for A.
(C) A is true but R is false.
(D) A is false but R is true.

Question.
Assertion (A): The keyword DISTINCT is used with SELECT command.
Reason (R): DISTINCT keyword eliminates duplicate rows

15. To include non-graphic characters in python, which of the following is used? 1


a. Special Literals
b. Boolean Literals
c. Escape Character Sequence
d. Special Literal – None

16. 50. Which of the following statement creates a tuple? 1


a) t=[1,2,3,4]
b) t={1,2,3,4}
c) t=<1,2,3,4>
d) t=(1,2,3,4)

17. Which of the following operation is supported in python with respect to tuple 1
t?
a) t[1]=33
b) t.append(33)
c) t=t+t
d) t.sum()
1

18. A ………………is a virtual table that does not really exist in its own right 1
but is instead derived from one or more underlying base table(s) in DBMS

a)SQL b) map c) view d) query

254 | P a g e
SECTION B

19.
Littu wrote a code function to display Fibonacci series. Correct the errors and 2
rewrite it.

def Fibonacci()
nterms = int(input("How many terms? "))# first two terms

n1, n2 = 0, 1
count = 0
if nterms<= 0:# check if the number of terms is valid
print("Please enter a positive integer");
elifnterms == 1:# if there is only one term, return n1
print("Fibonacci sequence upto",nterms,":")
print(n1);
else:# generate fibonacci sequence
print("Fibonacci sequence:")
while count >nterms:
print(n1)
nth = n1 + n2
n1 = n2# update values
n2 = nth
count -= 1

20. What Are Cookies? Why are protocols neededin networking? 2


OR
Why a switch is called an intelligent hub?

21.
a)Predict the output of the following code fragments: 2
keepgoing = True
x=100
while keepgoing :
print (x)
x = x - 10
if x < 50 :
keepgoing = False

b)counter = {}
defaddToCounter(country):
if country in counter:
counter[country] += 1
else:
counter[country] = 1

255 | P a g e
addToCounter('China')
addToCounter('Japan')
addToCounter('china')
print (len(counter))

22.
The Mname Column of a table Members is given below 2

Mname
Aakash
Hirav
Vinayak
Sheetal
Rajeev
(i) SELECT Mname FROM Members WHERE Mname ' “%\v";
(ii) SELECT Mname FROM Members WHERE Mname LIKE "%e%";

23.
a. Give three examples of DDL & DML commands? 2

b. What is the referential integrity constraint?

24. How is HAVING clause similar to WHERE clause? How is HAVING clause 2
differentfrom WHEREclause? Explain with the help of examples of each.

OR

Give one difference between ROLLBACK and COMMIT commands used


in MySql.
25. What are python modules? Name some commonly used built-in modules in 2
Python?
OR

What is difference between tell() and seek() methods?

SECTION C

26. Write a method in python to write multiple line of text contents into a text 3
file mylife.txt.

256 | P a g e
OR

Write a method in Python to read lines from a text file INDIA.TXT, to find
and display the occurrence of the word 'India'. For example, if the content of
the file is:
India is the fastest-growing economy. India is looking for more investments
around the globe. The whole world is looking at India as great market. Most
of the Indians can foresee the heights that India is capable of reaching.
The output should be 4.

27. a)Define candidate key, Primary key and Foreign Key. 1+2

b)Write the SQL commands for the given questions below based on the table
STUDENT.
No Name Age Dept DOJ Fee Sex
1 Anu 24 CS 10-01-19 250 M
2 Manu 21 EE 09-02-17 480 M
3 Vinu 25 CS 23-01-19 400 M
4 Pallavi 26 IT 22-05-17 260 F
5 Sai 30 EE 16-03-20 310 F
6 Appu 34 BE 15-06-17 250 F
7 Minnu 23 CS 29-01-18 480 M

i)To count the number of students with age<26.


ii)To list the names of female students who are in EE department.

28. I)Consider the table given below. Write the output of 3

a)SELECTdistinct(color, fruit), sum(rating) FROM medleys;


b)SELECT distinct(fruit,color) FROM medleys WHERE color =”blue”;
c)SELECT DISTINCT fruit FROM medleys;
d)SELECT medley_id FROM medleys WHERE rating>10;

MEDLEYS
257 | P a g e
medley_id | color | fruit | rating
============================
1 red apple 25
2 blue pear 5
3 green apple 12
4 red apple 10
5 purple kiwi 5
6 purple kiwi 50
7 blue kiwi 3
8 blue pear 9
II) Write a COMMAND to delete the column DOP from the table
VEHICLE. Table have five columns V_ID, OWNER_NAME, ADDRESS,
MODEL_NO, COLOUR, DOP.
29. Write a python program using function to find the largest element in a list 3
and then reverse the list contents and display it. Don’t use in-built functions
for the program.
30. Write a code for the STACK PUSH and POP implementation. 3
a)Write functions AddPlayer(player) and DeletePlayer(player) in python to
add and remove a player by considering them as push and pop operations
in a stack.Write a function to display the stack elements.
OR
Vedika has created a dictionary containing names and marks as key-value pairs
of 5 students. Write a program, with separate user-defined functions to
perform the following operations:
Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
Pop and display the content of the stack.
The dictionary should be as follows:

d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60,


“Ishika”:95}

Then the output will be: Umesh Vishal Ishika

258 | P a g e
SECTION D

31. a. TellAbout Consultants are setting up a secured network for their 5


office campus at Gurgaon for their day-to-day office and web-based
activities. They are planning to have connectivity between three
buildings and the head office situated in Mumbai. Answer the
questions (i) to (iv) after going through the building positions in the
campus and other details, which are given below :
The given building blocks are named as Green, Blue and Red

i. Suggest the most suitable place (i.e., building) to house the server of
this organization. Also give a reason to justify your suggested
location.

259 | P a g e
ii. Suggest the placement of the following devices with justification:
a. Repeater.
b. Switch.
iii. Suggest a cable layout of connections between the buildings inside
the campus.
iv. The organization is planning to provide a high speed link with its
head office situated in Mumbai using a wired connection. Which
of the following cables will be most suitable for this job.
• Optical Fiber
• Co-axial Cable
• Ethernet Cable
v. While connecting the devices two modems are found to
be defected. What is the function of modem?
32. a) Write the output of the code 2+3
def L1(D):
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = D[CNT]
TOTAL = float (T) + C
print(TOTAL)
CNT-=1

TXT = ["20","50","30","40"]
L1(TXT)
b)The program to illustrate Insertion of records to database in Python is given
below. Note the following to establish connectivity between Python and
MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Company.
import mysql.connector as mysql
try:
det=ps.connect(host='localhost',user='root',password='tiger',database='
Company')
cmd=_________ #Statement 1
pid=input("Enter Product Id:")
pn=input("Enter Product Name:")
pr = input("Enter Product Rate:")
md = input("Enter Mf. Date:")
query="insert into products values('{}','{}',{},'{}')"
260 | P a g e
.format(pid,pn,pr, md)
____________ #Statement 2
____________ #Statement 3
det.close()
print("Record Submitted")
except Exception as e:
print(e)

OR

a) Write the output of the code


def fun(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+'bb'
print(m)
fun('school2@com')

b) The code given below search for a record using ID in Python


The employee table consists of the following details:
Employee Name
Salary
Designation
City
Birth Date
Note the following to establish connectivity between Python and
MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Company.

import mysql.connector as mysql


try:
db=mysql.connect(host="localhost",user="root",password='tiger',
database="Company")
261 | P a g e
cmd=________. # Statement1
id=input("Enter Id you Want to Search?")
q="Select * from employee where employeeid={0}".format(id)
___________ #Statement2
row=_______ #Statement3
if(row):
print("Employee Name:",row[1])
print("Salary:", row[2])
print("Designation:",row[3])
print("City:", row[4])
print("Birth Date:", row[5])
else:
print("Record Not Found....")
db.close()
except Exception as e:
print(e)

33. What is pickle module and why we use this module? 5


The table given below have the details of customer. The name of the file
is cust.csv , write a code to insert multiple rows in the csv file.

SNo Customer Name City Amount


1 Dhaval Anand 1500
2 Anuj Ahmedabad 2400
3 Mohan Vadodara 1000
4 Sohan Surat 700

OR
What is aBinary File? Give examples.
The detail of marks of class XII are stored in file named RESULTS.CSV.
Raman, the Maths teacher wants to search the details of one student. Write
a program to search the details based on name .

SECTION E

262 | P a g e
34. Consider the following DEPT and WORKER tables. Write SQL queries for 4
(i) to and (iv) find outputs for queries ©v) to (viii):

(i) To display Wno, Name, Gender from the table WORKER in descending
order of Wno.

(ii) To display the Name of all the FEMALE workers from the table
WORKER
.
(iii) Write statements

a) To display the Wno and Name of those workers from the table WORKER
who are born between '1987-01-01' and '1991-12-01'.
b) To count and display MALE workers who have joined after '1986-01-
01"..
OR(only for part iii)

(iii) Write the output for the given statements

a) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE


HAVING COUNT(*) > 1;

b) SELECT DISTINCT DEPARTMENT FROM DEPT;

263 | P a g e
35.
Arun, during Practical Examination of Computer Science, has been assignedan 4
incomplete search() function to search in a pickled file student.dat. The
Filestudent.dat is created by his Teacher and the following information is
knownabout the file.
• File contains details of students in [roll_no,name,marks] format.
• File contains details of 10 students (i.e. from roll_no 1 to 10) and
separate list of each student is written in the binary file using dump().
Arun has been assigned the task to complete the code and print details of
rollnumber 1.
def search():
f = open("student.dat",____)#Statement-1
____: #Statement-2
while True:
rec = pickle.____#Statement-3
if(____): #Statement-4
print(rec)
except:
pass
f.close()

I). In which mode Arun should open the file in Statement-1?


a) r
b) r+
c) rb
d) wb

II). Identify the suitable code to be used at blank space in line marked as
Statement2
a) if(rec[0]==1)
264 | P a g e
b) for i in range(10)
c) try
d) pass

III). Identify the function (with argument), to be used at blank space in


line marked
as Statement-3.
a) load()
b) load(student.dat)
c) load(f)
d) load(fin)

IV). What will be the suitable code for blank space in line marked as
Statement-4.
a) rec[0]==2
b) rec[1]==2
c) rec[2]==2
d) rec[0]==1

Computer Science(083)
Sample Question Paper – III Marking Scheme

Maximum Marks:70 Time Allowed: 3 hours

SECTION A
1) Find output generated by the following code: 1
p=10
q=20
p*=q//3
q+=p=q**2
print(p,q)

Answer: 60,480
2) A database can have only one table(True/False) 1
Answer False

265 | P a g e

You might also like