ComputerScience-SQP Set1
ComputerScience-SQP Set1
Page: 1/11
12. What will be the output of the following code?
x=3
def myfunc():
global x
x+=2
print(x,end=’ ‘)
print(x,end=’ ‘)
myfunc() (1)
print(x,end=’ ‘)
(a) 3 5 5 (b) 5 5 5 (c) 5 3 5 (d) 3 3 5
13. In SQL, what is the use of IS NULL operator? (1)
14. Abhay want to remove the table STORE from the database MyStore. Which command will (1)
he use from the following:
a) DELETE FROM store; (b) DROP TABLE store;
c) DROP DATABASE mystore; (d) DELETE store FROM mystore;
15. Which function is used to display the total number of records/cardinality from table in a (1)
database?
(a) sum(*) (b) total(*) (c) count(*) (d) return(*)
16. Which of the following types of table constraints will prevent the entry of duplicate rows? 1 (1)
(a) Unique (b) Distinct (c) Primary Key (d) NULL
17. Which of the following is NOT a standard Python exception? (1)
(a) KeyError (b) ValueException (c) IndexError (d) TypeError
18. Which transmission media is capable of having a much higher bandwidth (data capacity? (1)
(a) Coaxial (b) Twisted pair cable (c) Untwisted cable (d) Fiber optic
19. Switch is a (1)
(a) Broadcast device (b) Uni-cast device
(c) Multi-cast device (d) None of the above
Q20 and Q21 are Assertion(A) and Reason(R) 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 explanationfor A
(C) A is True but R is False
(D) A is False but R is True
20. Assertion (A): Default parameters are used in Python functions to specify values for (1)
arguments that are not explicitly passed by the caller.
Reasoning (R): This allows the function to have a default behaviour when the caller does
not provide a value for an argument.
21. Assertion (A): The BETWEEN operator in SQL is used to match a within a range of
values.
Reasoning (R): The BETWEEN operator can only be used with numerical values in SQL. (1)
Page: 2/11
OR
B) Write a statement to reverse the elements of list L2.
25. What are the possible outcome(s) will get after execution of the following code? (2)
import random
lst=[‘a’, ‘b’, ‘c’, ‘d’, ‘e’]
for i in range(3):
print(ord(random.choice(lst)+1,’@’, end= “”)
(a) 102@99@100@ (b) 98@99@98@ (c) 103@100@98 (d) 97@99@101@
26. Write a program to replaces elements having even values with its half and elements having
odd values with twice its value in a list.
eg: if the list contains
3, 4, 5, 16, 9
then rearranged list as
6, 2,10,8, 18
However, there are syntax and logical errors in the code. Rewrite it after removing all
errors. Underline all the corrections made.
Def rearranged(L):
L=[3, 4, 5, 16, 9]
for i in range(n):
if L[i] % 2 == 0:
L[i] =/ 2
else:
L[i] =/ 2
print (L)
27. A) List one advantage and one disadvantage of Ring topology.
OR
B) Expand the term MODEM. What is the use of MODEM? (2)
28. (i) a) An attribute A of datatype varchar(20) has the value “Amit” . The attribute B of (2)
datatype char(20) has value ”Karanita” . How many characters are occupied in attribute
A ? How many characters are occupied in attribute B?
OR
b) While creating a table named “Employee”, Mr. Rishi got confused as which data type
he should choose for the column “EName” out of char and varchar. Help him in
choosing the right data type to store employee name. Give valid justification for the
same.
(ii) a) While creating a table named “Employee”, Mr. Rishi got confused as which data
type he should choose for the column “EName” out of char and varchar. Help him in
choosing the right data type to store employee name. Give valid justification for the
same.
OR
b) While creating a table named “Employee”, Mr. Rishi got confused as which data type
he should choose for the column “EName” out of char and varchar. Help him in
choosing the right data type to store employee name. Give valid justification for the
same.
Section-C ( 3 x 3 = 9 Marks)
29. A) A text file contains alphanumeric text (say an.txt). Write a program that reads this text
file and prints only the numbers or digits from the file.
OR (3)
B) Write a function remove_lowercase() that accepts two filenames, and copies all the
lines that do not start with a lowercase letter from the first file into the second.
Page: 3/11
30. A) Julie has created a dictionary containing names and marks as key value pairs of 6
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 75.
● Pop and display the content of the stack.
For example: If the sample content of the dictionary is as follows:
R={"OM":76, "JAI":45, "BOB":89, "ALI":65, "ANU":90, "TOM":82}
The output from the program should be: TOM ANU BOB OM
OR
(B) Write a program to create a Stack for storing only odd numbers out of all the
numbers entered by the user. Display the content of the Stack along with the largest
odd number in the Stack. (Hint. Keep popping out the elements from stack and (3)
maintain the largest element retrieved so far in a variable. Repeat till Stack is empty)
31. Predict the output of the following 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: (3)
m=m+'bb'
print(m)
fun('school2@com')
OR
Predict the output of the following code:
v=50
def display(n):
global v
v=25
if n%7==0:
v=v+n
else:
v=v-n
print(v,end="#")
display(20)
print(v)
Section-D ( 4 x 4 = 16 Marks)
32. Write the characteristics of CSV files. (4)
Write a Program in Python that defines and calls the following user defined functions:
i) APPEND() – To add two records of book to a CSV file „BOOK.csv‟. Each record
consists of a list with field elements as bookid, bname and price to store book id, book name
and book price respectively.
ii) DISP() – To count and display the number of records in the following format. Books
above price 500 :
BookID Bname price
101 Computer Application 450
102 Computer Science 670
105 Informatics Practices 500
Page: 4/11
33. Consider the tables PRODUCT and BRAND Given table:
Table: BOOK
CODE BNAME TYPE
F101 The Priest Fiction
L102 German easy Literature
C101 Tarzan in the lost world Comic
F102 Untold story Fiction.
C102 War heroes Comic
TABLE: MEMBER (4)
MNO MNAME CODE ISSUEDATE
M101 Raghav Sinha L102 2016-10-13
M103 Sarthak John F102 2017-02-23
M102 Anisha Khan C101 260-06-12
Write SQL queries for the following:
(i) To display all details from table MEMBER in descending order of ISSUEDATE.
(ii) To display the CODE and BNAME of all Fiction Type books from the table Book.
(iii) To display each Member name and corresponding Bookname.
(iv) To display Booknames, Member name and issue date for books of type 'Fiction'.
OR
Write the output of the queries (i) to (iv) based on the table, SALES given below:
Page: 5/11
35. Aarya has created a table named Emp in MySQL:
EmpNo – integer
EmpName – string
Age– integer
Salary – integer
Note the following to establish connectivity between Python and MYSQL:
• Username - root
• Password - tiger
• Host - localhost (4)
• The Emp table exists in a MYSQL database named company.
• The details of Emp table (EmpNo, EmpName, Age and Salary)
Aarya wants to display All Records of Emp relation whose age is greater than 55. Help
Aarya to write program in python.
Q.No. SECTION E (2 X 5 = 10 Marks) Marks
36. A binary file "Book.dat" has structure [BookNo, Book_Name, Author, Price]. (5)
i. Write a user defined function createFile() to input data for a record and add to Book.dat.
ii. Write a function to increase price 100/- those Book name has ‘Computer Science’.
iii. Write a function countRec(Author) in Python which accepts the Author name as
parameter and count and return number of books by the given Author are stored in the
binary file "Book.dat".
37. Bias Methodologies is planning to expand their network in India starting with three cities
in India to build infrastructure for research and development of their chemical products.
The company has planned to setup their main office in Pondicherry at three different
locations and have named their offices as Back Office, Research Lab and Development
Unit. The company has one more research office namely Corporate Unit in Mumbai. A
rough layout of the same is as follows:
(5)
In continuation of the above, the company experts have planned to install the following
number of computers in each of these offices.
(i) Suggest the kind of network required (out of LAN, MAN, WAN) for connection each
Page: 6/11
of the following office unit
(a) Research Lab and Back Office
(b) Research Lab and Development Unit
(ii) Which of the following devices will you suggest for connecting all the computers with
each of their office units?
(a) Switch/Hub (b) Modem (c) Telephone
(iii) Which of the following communication media, will you suggest to be procured by the
company for connecting their local office units in Pondicherry for very effective (high
speed) communications?
(a) Telephone cable (b) Optical fiber (c) Ethernet cable
(iv) Suggest a cable/wiring layout for connecting the company’s local office units located
in Pondicherry. Also, suggest an effective method/technology for connecting the
company’s office located in Mumbai.
(v) Suggest the most appropriate location of the server inside the Pandicharry campus.
Justify your choice.
Page: 7/11