Diwali Ws
Diwali Ws
Diwali Ws
2024
CLASS : XI DIWALI VACATION ASSIGNMENT SUB DATE:11.11.2024
SUBJECT:COMPUTER SCIENCE TOPIC:PYTHON BASICS, STRING, LIST AND TUPLE
1. What will be the output of following code-
list1=[1, 3, 2]
list1 * 2
a) [1,1,2,2,3,3] b) [123,123] c) [1,3,2] d) [1,3,2,1,3,2]
2. Is Python case sensitive when dealing with identifiers?
a) yes b) no c) machine dependent d) none of the mentioned
3. Which of the following is invalid?
a) _a = 1 b) __a = 1 c) __str__ = 1 d) none of the mentioned
4. All keywords in Python are in
a) lower case b) UPPER CASE c) Capitalized d) None of the mentioned
5. Which is the correct operator for power(xy )?
a) X^y b) X**y c) X^^y d) None of the mentioned
6. What is the output of this expression, 3*1**3?
a) 27 b) 9 c) 3 d) 1
7. In python we do not specify types,it is directly interpreted by the compiler, so
consider the following operation to be performed.
>>>x = 13 ? 2
objective is to make sure x has a integer value, select all that apply (python 3.xx)
a) x = 13 // 2 b) x = int(13 / 2) c) x = 13 % 2 d) All of the mentioned
8. Which of the following commands will create a list?
a) list1 = list() b) list1 = []. c) list1 = list([1, 2, 3]) d) all of the mentioned
9. What will be the output of the following Python code snippet?
my_string = "hello world"
k = [(i.upper(), len(i)) for i in my_string]
print(k)
a) [(‘HELLO’, 5), (‘WORLD’, 5)]
b) [(‘H’, 1), (‘E’, 1), (‘L’, 1), (‘L’, 1), (‘O’, 1), (‘ ‘, 1), (‘W’, 1), (‘O’, 1), (‘R’, 1), (‘L’, 1), (‘D’, 1)]
c) [(‘HELLO WORLD’, 11)]
d) none of the mentioned
10. . What is the output when we execute list(“hello”)?
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]. b) [‘hello’]. c) [‘llo’]. d) [‘olleh’]
11. Which of the following is incorrect?
a) x = 0b101 b) x = 0x4f5 c) x = 19023 d) x = 03964
12. What will be the output of the following Python code snippet?
x = [i**+1 for i in range(3)]; print(x);
a) [0, 1, 2] b) [1, 2, 5] c) error, **+ is not a valid operator d) error, ‘;’ is
not allowed
13. How many times will the following loop run?
Given: p=4
for i in range (p,20,5):
(a) 3 times (b) 4 times (c) 5 times (d) infinite times
14. Li= [1, 5, 14, 28, 12]
print (Li.pop (2)+Li.pop (3))
(a) 19 (b) 42 (c) 62 (d) 26
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
15. Assertion(A)
In Python, each character of the string is assigned two-way indices.
Reason (R)
Strings are the sequences of characters where their indices start with 1 in the forward direction
and with -1 in the backward direction.
16. Assertion(A)
The list is a mutable collection of data in Python.
Reason (R)
It means that any change or alteration in data, is maintained in the same place. The
updated collection will use the same address for its storage.
17. What is the output of the following?
print("xyyzxyzxzxyy".count('yy', 2))
a) 2 b) 0 c) 1 d) none of the mentioned
18. Which of the following is valid arithmetic operator in Python ?
(a) // (b) ? (c) < (d) and
19. Suppose list Example is [‘h’,’e’,’l’,’l’,’o’], what is len(list Example)?
a) 5 b) 4 c) None d) Error
20. What will be the output of following program:
L1 = list()
L1.append([1, [2, 3], 4])
L1.extend([7, 8, 9])
print(L1[0][1][1] + L1[2])
21. What will be the output of following code-
a=[[[1,2],[3,4],5],[6,7]]
a[0][1][1]
22. Consider the following tuple:
monuments=( 'Kutub Minar', 10, 'Taj Mahal', 20, 'India Gate', 30, 'Char Minar', 40)
states=('Delhi', 'Kerala', 'Tamil Nadu', 'Bihar')
Write Python statements for the following. Kindly state the reason for the operations which is not
possible.
a) To insert “Red Fort” and “Jantar Mantar” in the tuple monuments
b) To add 50 at the end of the tuple
c) To add tuple of states at the end of the tuple of monuments
d) To replace 3rd, 4th and 5th element of the monuments tuple by “India”.
e) To remove the third element from the tuple monuments.
f) To delete the tuple monuments.
g) To store all elements 2 times in the tuple states.
h) To check whether the element 20 is present in the tuple or not.
i) To swap the elements of tuples, monuments and states.
j) To display all elements of a tuple states in different lines.