Question 1648422
Question 1648422
Rasipuram
1 ST 50
Class 12 - Computer Science
Time Allowed: 3 hours Maximum Marks: 86
1. Which among the following list of operators has the highest precedence? [1]
+, -, **, %, /, <<, >>, |
a) | b) <<, >>
c) % d) **
2. Which of the following expressions involves coercion (implicit type promotion) when evaluated in Python? [1]
a) s[: - 3] b) s[3:]
a) get() b) items()
c) keys() d) clear()
5. What is the output of the following code? [1]
1 = [None] * 10
print(len(l))
a) 0 b) None
c) 10 d) Syntax Error
6. Which of the following commands will create a list? [1]
a) 3 b) 27
c) 9 d) 1
8. What is the value of the following expression? [1]
21//4 + 6/3
a) 7.33 b) 7.25
c) 7 d) 7.0
1/9
Fuck
9. Which of the following will delete key:value pair for key="tiger" in dictionary? [1]
c) delete(di.["tiger"]) d) di["tiger"].delete()
10. What will the following code do? [1]
dict={"Phy":94,"Che":70,"Bio":82,"Eng":95}
dict.update({"Che":72,"Bio":80})
a) It will simply update the dictionary as dict = b) It will create new dictionary as dict =
{"Phy":94, "Che":72, "Bio":80, "Eng":95}. {"Che":72, "Bio" :80} and old dict will be
deleted.
c) It will not throw any error but it will not do d) It will throw an error as dictionary cannot
any changes in diet. be updated.
11. What is None literal in Python? [1]
12. What is the internal structure of Python strings? [1]
13. What is the length of the tuple shown below? [2]
t = (((('a', 1), 'b', 'c'), 'd', 2), 'e', 3)
14. What is the output of below questions? [2]
l1 = [23, 45, 19, 77, 10, 22]
i. l1. sort ( )
ii. max(l1)
15. Which of the following are invalid names and why? [2]
i. PaidInterest
ii. S-num
iii. Percent
iv. 123
v. abc km
vi. elif
16. Observe the output [2]
i. >>> x = ‘Sum' * '3'
ii. >>> x = ‘Sum' + '3'
17. Write a method in python to display the elements of list thrice if it is a number and display the element [2]
terminated with if it is not a number.
For example, if the content of list is as follows :
List =['41', 'DROND', 'GIRIRAJ', ’13', 'ZARA']
The output should be
414141
DROND#
GIRIRAD#
2/9
Fuck
131313
ZARA#
18. How many ways are there in Python to represent an integer literal? [3]
19. Write a program that takes a string with multiple words and then capitalizes the first letter of each word and [3]
forms a new string out of it.
20. What does each of the following expressions evaluate to? [3]
Suppose that L is the list
["These", ["are", "a"], ["few", "words"], "that", "we", "will", "use"].
i. L[3 : 4] + L [1 : 2]
ii. "few" in L [2 : 3]
iii. "few" in L [2]
iv. L [2][1 :]
v. L [1] + L[2]
21. Following code is not producing any output and seems to have gone in endless loop : [3]
lst = ['ab', ’cd']
for i in lst:
lst.append(i.upper())
print(lst)
i. What could be the reason?
ii. Could you suggest a solution for above code problem?
22. How are dictionaries different from lists? [3]
23. How are lists different from strings when both are sequences? [3]
24. Consider the following code: [3]
Inp = input ("Please enter a string)
while len (Inp) <= 4:
if Inp [-1] == 'z': # condition 1
Inp = Inp [0 : 3] + 'c'
elif 'a' in Inp: # condition 2
Inp = lnp [0] + 'bb'
elif not int (lnp [0]): # condition 3
Inp = '1' + Inp [1 :] + 'z'
else:
Inp = Inp + '*’
print(Inp)
What will be the output produced if the input is
i. 1bzz,
ii. '1a'
iii. 'abc'
iv. '0xy'
v. 'xyz'
25. Write a Python program with output to convert the centimeter value into meter and kilometer. [4]
26. Draw a flowchart to find biggest number among n numbers. [4]
3/9
Fuck
27. Assertion (A): Python does not allow programmers to develop the software for several computing platforms by [1]
writing a program only once.
Reason (R): Python is cross platform language.
a) Both A and R are true and R is the correct b) Both A and R are true but R is not the
explanation of A. correct explanation of A.
a) smiles[1pos] b) smiles[0]
c) smiles[-1] d) smiles[:-1]
29. Dictionaries are ________ data types of Python. [1]
a) immutable b) simple
a) B, C b) A, D
c) A, C d) C, D
31. Which of the following expressions is an example of type casting? [1]
A. 4.0 + float(6)
B. 5.3 + 6.3
C. 5.0 + 3
D. int(3.1) + 7
a) B, C b) A, D
c) A, D d) A, C
32. Which of the following will create an empty list? [1]
a. L = [ ]
b. L = list(0)
c. L = list()
d. L = List(empty)
4/9
Fuck
3. print(num[3][0])
4. print(num[5])
a) Line 1 b) Line 2
c) Line 4 d) Line 3
34. Given tp = (5,3,1,9,0). Which of the following two statements will give the same output? [1]
i. print(tp[:-1])
ii. print(tp[0:5])
iii. print(tp[0:4])
iv. print(tp[-4:])
a) AND b) IN
c) OR d) NOT
36. Choose the correct function to get the ASCII code of a character. [1]
c) ord('char') d) char('char')
37. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect? [1]
c) print(max(T)) d) print(len(T))
38. Choose the correct statement(s). [1]
a. In Python, a tuple can contain only integers as its elements.
b. In Python, a tuple can contain only strings as its elements.
c. In Python, a tuple can contain elements of different types.
d. In Python, a tuple can contain either string or integer but not both at a time.
a) section b) class
c) break d) name
40. Identify the valid declaration of L: [1]
L = ['Mon', '23', 'hello', '60.5']
a) list b) string
c) tuple d) dictionary
41. Identify the valid declaration of L: [1]
L = [1, 23, 'hi', 6]
5/9
Fuck
a) list b) tuple
c) array d) dictionary
42. Is Python case sensitive when dealing with identifiers? [1]
c) machine dependent d) no
43. Identify the output of the following Python statement. [1]
b = 1
for a in range(1, 10, 2):
b += a + 2
print (b)
a) 36 b) 31
c) 39 d) 33
44. Identify the output of the following Python statement. [1]
lst1 = [10,15,20,25,30]
lst1.insert(3,4)
lst1. insert(2,3)
print(lst1[-5])
a) 4 b) 20
c) 3 d) 2
45. State True or False: [2]
(a) Mathematical operations can be performed on a string. [1]
(b) For any index n, s[:n] + s[n:] will give you original string s. [1]
46. Read the text carefully and answer the questions: [6]
a = [36, 29, 21, 19, 50, 72, 34]
print("Original list:", a)
#iterating over a
for i in ________: #Fill 1
j = a.index(i)
#i is not the first element
while ________ #Fill 2
#not in order
if ________: #Fill 3
#swap
________ #Fill 4
else:
#in order
break
6/9
Fuck
j = ________ #Fill 5
print("Sorted list:", a)
(a) Choose the correct variable for Fill 1.
a) a b) 1
c) i d) list
(b) Choose the correct validation for Fill 2.
a) j = 0 b) j < 0:
c) j > 0 d) j > 0:
(c) Choose the correction condition for Fill 3.
a) a[j - 1], a[j] = a[j], a[j - 1] b) a[j - 3], a[j] = a[j], a[j - 2]
c) a[j - 2], a[j] == a[j], a[j - 1] d) a[j - 3], a[j - 2] = a[j], a[j - 2]
(e) Choose the correct condition for Fill 5.
a) j + 2 b) j
c) j - 1 d) j + 1
(f) What can be output obtained?
a) Original list: [36, 29, 21, 19, 50, 72, 34] b) Original list: [36, 29, 21, 19, 50, 72, 34]
Sorted list: [72, 50, 36, 34, 29, 21, 19] Sorted list: [34, 36, 50, 72, 19, 21, 29]
c) Sorted list: [19, 21, 29, 70, 50, 36, 34] d) Original list: [36, 29, 21, 19, 50, 72, 34]
Sorted list: [19, 21, 29, 34, 36, 50, 72]
47. Read the text carefully and answer the questions: [5]
Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take a job there, if he
is paid over ₹40000 a month. He hates Chennai and demands at least ₹100000 to work there. In any another
location, he is willing to work for ₹60000 a month. The following code shows his basic strategy for evaluating a
job offer.
pay =________
location = ________
if location = = "Mumbai":
print ("I’ll take it!") #Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way") #Statement 2
else:
print("I am willing!") #Statement 3
elif location == "Delhi" and pay >40000:
print("I am happy to join") #Statement 4
7/9
Fuck
elif pay > 60000:
print("I accept the offer") #Statement 5
else:
print("No thanks, I can find something better") #Statement 6
On the basis of the above code, choose the right statement which will be executed when different inputs for pay
and location are given.
(a) Input: location = "Chennai", pay = 50000
a) Statement 4 b) Statement 3
c) Statement 2 d) Statement 1
(b) Input: location = "Surat", pay = 50000
a) Statement 4 b) Statement 6
c) Statement 5 d) Statement 2
(c) Input: location = "Any Other City", pay = 1
a) Statement 1 b) Statement 6
c) Statement 2 d) Statement 4
(d) Input: location = "Delhi", pay = 50000
a) Statement 4 b) Statement 6
c) Statement 3 d) Statement 5
(e) Input : location = "Lucknow", pay = 65000
a) Statement 4 b) Statement 5
c) Statement 3 d) Statement 2
48. Read the text carefully and answer the questions: [4]
Program to check if elements of a list are same or not, it read from front or back
a = [1, 2, 3, 3, 2, 1]
i = (len(a))/2
same = True
while .....
if a[i] != ..... :
print ("No")
same = False
break
.....
if same == ..... :
print ("Yes")
8/9
Fuck
(d) What value will be come to satisfy the condition if in Line 11.
9/9
Fuck