Worksheet 2 Class 12th
Worksheet 2 Class 12th
Worksheet-2
Subject- Computer Science(083)
1. State True or False: The Python interpreter handles logical errors during code execution.
text = "PYTHONPROGRAM"
text=text.replace('PY','#') print(text)
(A) not(True) and False (B) True or False (C) not(False and True) (D) True and not(False)
str='International'
print(str.split("n"))
(A) ('I', 'ter', 'atio', 'al') (B) ['I', 'ter', 'atio', 'al'] (C) ['I', 'n', 'ter', 'n', 'atio', 'n', 'al'] (D) Error
5. What will be the output of the following code snippet? str= "World Peace" print(str[-2::-2])
tuple1 = (1, 2, 3)
tuple2 = tuple1
tuple1 += (4,)
print(tuple1 == tuple2)
7. If my_dict is a dictionary as defined below, then which of the following statements will raise an
exception?
(A) my_dict.get('orange')
(C) my_dict['apple']=20
(D) print(str(my_dict))
The finally block in Python is executed only if no exception occurs in the try block.
c = 10
def add():
global c c = c + 2 print(c,end='#') add() c=15
print(c,end='%')
(A) 12%15# (B) 15#12% (C) 12#15% (D) 12%15#
13. Which SQL command can change the degree of an existing relation?
15. In which datatype the value stored is padded with spaces to fit the specified length.
16. Which aggregate function can be used to find the cardinality of a table?
18. Which network device is used to connect two networks that use different protocols?
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 explanation for A
20. Assertion (A): In the case of positional arguments, the function call and function definition
statements match in terms of the number and order of arguments.
Reasoning (R): During a function call, positional arguments should precede keyword arguments in
the argument list. (1)
21. Assertion (A): A SELECT command in SQL can have both WHERE and HAVING clauses.
Reasoning (R): WHERE and HAVING clauses are used to check conditions, therefore, these can be
used interchangeably.
22. How is a mutable object different from an immutable object in Python? Identify one mutable
object and one immutable object from the following: (1,2), [1,2], {1:1,2:2}, ‘123’
OR
(II) A) Write a statement to insert all the elements of L2 at the end of L1.
OR
25. Identify the correct output(s) of the following code. Also write the minimum and the maximum
possible values of the variable b.
b=random.randint(1,6)
for i in range(0,b,2):
print(a[i],end='#')
OR