12 Computer Science SP 06 With Solution
12 Computer Science SP 06 With Solution
Maximum Marks: 70
Time Allowed: : 3 hours
General Instructions:
Section A
1. State true or false:
The max() and min() when used with tuples, can work if elements of the tuple are all of the same types.
a) True
b) False
2. Which of the following is an advantage of SQL?
a) Client/server language
b) High speed
c) All of these
d) Easy to learn
3. l1 = [1,2,3,4,5]
l1.append([5,6,[7,8,[9,10])
What will be the final length of l1?
a) 10
b) 5
c) 8
d) Error
4. Which of the following four code fragments will yield following output?
Eina
Nina
Dika
Select all of the function calls that result in this output
a) print(''' Eina
\nNina
\nDika''')
b) print('''EinaNinaDika''')
c) print('Eina
Nina
Dika')
d) print('Eina\nNina\nDika')
5. The checksum of 0000 and 0000 is .
a) 1110
b) 0111
c) 1111
d) 0000
6. Which of the following functions do you use to write data in the binary format?
a) write( )
b) output( )
c) dump( )
d) send( )
7. >>> m = [[x, x*2, x*3] for x in range (3,6)]
a) Error
b) [3,6,9,[4,8,12,[5,10,15]]]
c) [[3,6,9],[4,8,12],[5,10,15]]
d) [3,6,9,4,8,12,5,10,15]
8. Which clause is used with "aggregate functions"?
a) GROUP BY
b) WHERE
c) SELECT
d) Both GROUP BY and WHERE
9. For readline(), a line is terminated by
a) None of these
b) '\n'
c) EOF
d) Either '\n' or EOF
10. Non-void functions are also known as
a) Invalid functions
b) Valid functions
c) Fruitful functions
d) Non functions
11. Which of the following can delete an element from a list if the index of the element is given?
a) del
b) remove()
c) pop()
d) all of these
12. Which of the following items are present in the function header?
a) return value
b) parameter list only
c) both function name and parameter list
d) function name only
13. State true or false:
A client is the computer that asks for the action in a network.
a) True
b) False
14. What is the output of the following program :
print Hello World [:: -1]
a) Hello World
b) drW olH
c) dlroW olleH
d) HloWrd
15. Fill in the blanks:
To refer to a set of values needed for a condition, we can use the SQL operator .
16. Which of the following is a client-side scripting language?
a) Perl
b) PHP
c) VB Script
d) Ruby
17. Assertion (A): The code of the other programming language can't use in the Python source code.
Reason (R): In Python, we don't need to specify the data-type of the variable.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
18. Assertion (A): pandas is defined as an open-source library that is built on top of the NumPy library.
Reason (R): pandas provides fast analysis, data cleaning, and preparation of the data for the user.
a) Both A and R are true and R is the correct explanation of A.
b) Both A and R are true but R is not the correct explanation of A.
c) A is true but R is false.
d) A is false but R is true.
Section B
19. Answer:
1. i. What is frequency modulation?
ii. What is burst error?
2. OR
i. Explain any two switching techniques used in networking.
20. Write Python code to delete all the records from the Employee table whose age >60 the table has following fields.
Empid, EmpName, Deptid, age, Payscale
21. Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code.
Value = 30
for VAL in range(0,Value)
If val % 4 == 0:
print (VAL * 4)
Elseif val % 5 == 0:
print (VAL + 3)
else
print(VAL + 10)
OR
Construct logical expressions to represent the following conditions.
i. Weight is greater than or equal to 115 but less than 125.
ii. Donation is in the range of 4000-5000 or Guest is 1.
22. Answer:
1. Write a checklist before connecting to a database?
2. How is a database connection established?
23. What would be the output of following code?
ntpl = ("Hello", "Nita" , "How's", "life ?")
(a, b, c, d) = ntpl
print("a is:", a)
print("b is:", b)
print("c is:", c)
print("d is:", d)
ntpl= (a, b, c, d)
print(ntpl[0][0]+ntpl[1][1], ntpl[1])
OR
OR
Write a program to read the content of "percentage.txt" file. The "percentage.txt" file contains Id, Name and Percentage
fields. Assume that first field of the student status (between Id and Name) is separated with a comma(,).
25. What output will be generate when the following Python code is executed:
def ChangeList():
l = []
l1 = []
l2 = []
for i in range(1,10):
l.append(i)
for i in range(10,1,-2):
l1.append(i)
for i in range(len(l1)):
l2.append(l1[i]+l[i])
l2.append(len(l)-len(l1)
print(l2)
ChangeList()
Section C
26. Answer:
1. What is the output of the following?
i=4
while True:
if i% 0o8 == 0:
break
print(i, end = ' ')
i += 1
2. Which string built-in methods are used in following conditions?
i. Returns the length of the string.
ii. Removes all leading whitespace in string.
iii. Returns the minimum alphabetical character from the string.
27. Write a function that takes a number n and then returns a randomly generated number having exactly n digits (not
starting with zero) e.g., if n is 2 then the function can randomly return a number 10-99 but 07, 02, etc., are not valid two-
digit numbers.
28. Differentiate between char(n) and varchar(n) data types with respect to databases.
OR
Write the output of the queries (i) to (iv) based on the table FURNITURE given below.
Table : FURNITURE
FID NAME DATEOFPURCH ASE COST DISCOUNT
TABLE: STUDENT
TABLE: STREAM
STRCDE STRNAME
1 SCIENCE+COMP
2 SCIENCE+BIO
3 SCIENCE+ECO
4 COMMERCE+MATHS
5 COMMERCE+SOCIO
6 ARTS+MATHS
7 ARTS+SOCIO
i. To display the name of streams in alphabetical order from table STREAM.
ii. To display the number of students whose POINTS are more than 5.
iii. To update GRADE to ‘A’ for all those students, who are getting more than 8 as POINTS.
iv. ARTS+MATHS stream is no more available. Make necessary change in table STREAM.
v. To display student’s name whose stream name is science and computer.
Section E
33. China Middleton Fashion is planning to expand their network in India, starting with two cities in India of provide
infrastructure for distribution of their product. The company has planned to set up their main office units in Chennai at
the different locations and has named their offices as Production Unit, Finance Unit and Media Unit. The company has
its Corporate Unit in Delhi. A rough layout of the same is as follows:
From To Distance
Production Unit Finance Unit 70 m
Production Unit Media Unit 15 km
Production Unit Corporate Unit 2112 km
In continuation of the above, the company experts have planned to install the following number of computers in
each of their office units
Finance Unit 35
Media Unit 10
Corporate Unit 30
i. Suggest the kind of network required (out of LAN, MAN, WAN) for connecting each of the following office units:
Production Unit and Media Unit
Production Unit and Finance Unit.
ii. Which one of the following device will you suggest for connecting all the computers within each of their office
units?
Switch/Hub
Modem
Telephone
iii. Which of the following communication media, will you suggest to be procured by the company for connecting their
local office units in Chennai for very effective (high speed) communication?
Telephone cable
Optical fiber
Ethernet cable
iv. Suggest a cable/wiring layout for connecting the company's local office units located in Chennai. Also, suggest an
effective method/technology for connecting the company's office unit located in Delhi.
v. Suggest the most suitable place to install the server with reason.
34. Consider the following tables CABHUB and CUSTOMER and answer (b) and (c) parts of this question:
Table: CABHUB
Table: CUSTOMER
OR
Consider the following table DRESS. Write SQL commands for the following statements.
Table: DRESS
Table: GARMENT
TABLE: SCHOOL
TABLE: ADMIN
Solution
Section A
1. (a) True
Explanation: True
2. (c) All of these
Explanation: All of these
3. (b) 5
Explanation: A list is getting added in list l1 which will be counted as one item for the list.
4. (a) print(''' Eina
\nNina
\nDika''')
Explanation: Python’s triple quotes can be used to span strings over multiple lines.
5. (c) 1111
Explanation: 1111, 1’s complement arithmetic to get the sum.
6. (c) dump( )
Explanation: dump( )
7. (c) [[3,6,9],[4,8,12],[5,10,15]]
Explanation: The above code generates a list of lists each for an integer values between the values specified in the range
function inclusive the lower limit.
8. (a) GROUP BY
Explanation: The aggregate function is often used with the GROUP BY clause and HAVING clause of the SELECT
statement.
9. (d) Either '\n' or EOF
Explanation: Either '\n' or EOF
10. (c) Fruitful functions
Explanation: Fruitful functions
11. (a) del
Explanation: del
12. (c) both function name and parameter list
Explanation: both function name and parameter list
13. (a) True
Explanation: True
14. (c) dlroW olleH
Explanation: The string is traversed in reverse order due to -1 step size.
15. 1. IN
16. (c) VB Script
Explanation: VB Script and Java Script are examples of client-side scripting languages. Rest all are server-side scripting
languages.
17. (d) A is false but R is true.
Explanation: We can use Python source code in another programming language as well. It can embed other
programming languages into our code. In Python, we don't need to specify the data type of the variable. When we assign
some value to the variable, it automatically allocates the memory to the variable at run time.
18. (b) Both A and R are true but R is not the correct explanation of A.
Explanation: pandas is defined as an open-source library that is built on top of the NumPy library and it provides fast
analysis, data cleaning, and preparation of the data for the user.
Section B
19. Answer:
1. i. When a high-frequency carrier wave's frequency is varied in accordance with the frequency of information
(wave) to be transmitted, keeping the amplitude and phase of the carrier wave unchanged, this process is
called frequency modulation.
ii. Burst error means that 2 or more bits in the data unit have changed from 1 to 0 from 0 to 1 during
transmission.
2. OR
i. In large networks, there may be more than one paths for transmitting data from sender to receiver. Selecting
a path that data must take out of the available options is called switching.
Message Switching: It is similar to the Post-office mailing system. A temporary link is established for one
message transfer. In this technique, no physical path is established between source and destination in
advance.
Packet Switching: It is a form of store and forward switch system which stores the message as small
packets at the switch nodes and then transmits it to the destination.
20. Python code to delete all the records from the Employee table whose age >60:
import MySQLdb
db = MySQLdb.connect('localhost', 'HRMan', 'HRManexe@pwd', 'Emplyee')
cursor = db.cursor()
sql ="Delete from Employee where AGE>'%d" /(60)
try:
db.execute(sql)
db.commit()
except:
db.rollback()
db.close()
21. Corrected Code:
Value = 30
for VAL in range(0,Value): # Error 1 - colon missing
if val % 4 == 0: # Error 2 - if should be in lower case
print (VAL * 4)
elif val % 5 == 0: # Error 3 - it should be elif
print (VAL + 3)
else: # Error 4 - colon missing
print(VAL + 10)
OR
OR
OR
import os
f="percentage.txt"
if os.path.isfile(f):
fob=open(f)
print("Student Status")
print(" -------- ")
for per in fob:
print(per)
fob.close()
else:
print("File does not exist”)
25. Output
[11, 10, 9, 8, 7, 4]
Section C
26. Answer:
1. The above code will give syntax Error(Invalid token) because 0o8 is not a valid integer. Any number beginning with
0 is treated as octal number and octal numbers cannot have digits 8 and 9. Hence 0o8 is an invalid integer.
2. i. len()
ii. lstrip()
iii. min()
27. import random
def randomNDigitNumber(n):
num = " "
firstlteration = True
for i in range(n):
randomDigit = " "
if firstlteration:
randomDigit = str(random.randint(1, 9))
firstlteration = False
else:
randomDigit = str(random.randint(0, 9))
num = randomDigit + num
return num
print(randomNDigitNumber(7))
28. Differentiate between char(n) and varchar(n) are as follows
char(n) varchar(n)
It stores a fixed length string between 1 and 255
It stores a variable length string.
characters.
If the value is of smaller length, then it adds blank No blanks are added by varchar(n) even if value is of smaller
spaces. length.
OR
i. SUM(DISCOUNT)
29
iv.iv.
An effective method/technology for connecting the company’s office in Delhi and Chennai is broadband connection.
v. Production unit is suitable to install the server because it has maximum number of computers.
34. a. Primary key of CABHUB table given in question = Vcode alternate key of CABHUB table = Vehicle Name. The
Primary key of Customer table = Ccode Alternate Key of CUSTOMER = Cname.
b. i. SELECT VehicleName FROM CABHUB WHERE Colour = "WHITE";
ii. SELECT VehicleName, capacity From CABHUB ORDER BY Capacity ASC;
iii. SELECT MAX(Charges) FROM CABHUB;
iv. SELECT Cname, VehicleName FROM CABHUB, CUSTOMER WHERE CUSTOMER. Vcode= CABHUB.
Vcode;
c. i. 4
35 12
iii. 5
iv. SX4
C Class
OR
i. SELECT D_CODE , DESCRIPTION FROM DRESS ORDER BY D_CODE;
ii. SELECT * FROM DRESS WHERE LAUNCHDATE BETWEEN '05-DEC-07' AND '20-JUN-08' ;
iii. SELECT AVG(PRICE) FROM DRESS WHERE MCODE = 'M003' ;
iv. SELECT MCODE, MAX(PRICE), MIN(PRICE) FROM DRESS GROUP BY MCODE ;
35. Answer:
1. i. A relation is a two-dimensional table. It contains a number of rows (tuples) and columns (attributes).
A row in a relation is known as a tuple whereas a column of a table is known as an attribute.
ii. i. SELECT GCODE, Description FROM GARMENT ORDER BY GCODE DESC ;
ii. SELECT * FROM GARMENT WHERE READY DATE BETWEEN '08-DEC-07' AND '16-JUN-08' ;
iii. SELECT AVG(Price) FROM GARMENT WHERE FCODE = 'F03' ;
iv. SELECT FCODE, MAX(Price), MIN(Price) FROM GARMENT GROUP BY FCODE ;
2. OR
i. Out of the candidate keys, after selecting a key as primary key, the remaining keys are called an alternate
key. In Suppliers table if there are 2 candidate keys - Suppld and Supp_Name then Suppld is the primary
Key then Supp_Name is the alternate key.