Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

AISMV_XII_SOLVED_QB_REVIEW OF XI

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

AMITY INTERNATIONAL SCHOOL, MAYUR VIHAR

CLASS XII
SOLVED QUESTION BANK
REVIEW OF XI

1 mark

1) State True or False: The Python interpreter handles logical errors during code
execution.
Ans False
2) Identify the output of the following code snippet:
text = "PYTHONPROGRAM"
text=text.replace('PY','#')
print(text)
(A) #THONPROGRAM (B) ##THON#ROGRAM
(C) #THON#ROGRAM (D) #YTHON#ROGRAM
Ans) (A)
3) Which of the following expressions evaluates to False?
(A) not(True) and False (B) True or False
(C) not(False and True) (D) True and not(False)
Ans) (A)
4) What is the output of the expression?
country='International'
print(country.split("n"))
(A) ('I', 'ter', 'atio', 'al') (B) ['I', 'ter', 'atio', 'al'] (C) ['I', 'n', 'ter', 'n', 'atio', 'n', 'al'] (D) Error
Ans) (B) ['I', 'ter', 'atio', 'al']
5) What will be the output of the following code snippet?
message= "World Peace"
print(message[-2::-2])
Ans) ce lo
6) What will be the output of the following code?
tuple1 = (1, 2, 3)
tuple2 = tuple1
tuple1 += (4,)
print(tuple1 == tuple2)
(A) True (B) False (C)tuple1 (D)Error
Ans) (B) False
7) If my_dict is a dictionary as defined below, then which of the following
statements will raise an exception?
my_dict = {'apple': 10, 'banana': 20, 'orange': 30}
(A) my_dict.get('orange') (B) print(my_dict['apple', 'banana'])
(C) my_dict['apple']=20 (D) print(str(my_dict))
Ans) (B) print(my_dict['apple', 'banana'])
8) What does the list.remove(x) method do in Python?
(A) Removes the element at index x from the list
(B) Removes the first occurrence of value x from the list
(C)Removes all occurrences of value x from the list
(D)Removes the last occurrence of value x from the list
Ans) (B) Removes the first occurrence of value x from the list
9) State True or False: “In a Python program, if a break statement is given in a
nested loop, it terminates the execution of all loops in one go.”
Ans) False
10) What will be the output of the following statement:
print(3-2**2**3+99/11)
a. 244 b. 244.0 c. -244.0 d. Error
Ans) Option c -244.0
11) Select the correct output of the code:

Ans) PYTHON-is-Fun
12) Which of the following will delete key-value pair for key = “Red” from a dictionary
D1?
a. delete D1("Red") b. del D1["Red"] c. del.D1["Red"] d. D1.del["Red"]
Option b del D1["Red"]
13) Consider the statements given below and then choose the correct output from
the given options:
pride="#G20 Presidency" print(pride[-2:2:-2])
Options: a. ndsr b. ceieP0 c. ceieP d. yndsr
Ans) Option b ceieP0
14) Which of the following statement(s) would give an error during execution of the
following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
Options: a. Statement 1 b. Statement 2 c. Statement 3 d. Statement 4
Ans) Option d Statement 4
15) What possible outputs(s) will be obtained when the following code is executed?

Options:
a. RED*
WHITE*
BLACK*
b. WHITE*
BLACK*
c. WHITE* WHITE*
BLACK* BLACK*
d. YELLOW*
WHITE*WHITE*
BLACK* BLACK* BLACK*
Option b
WHITE*
BLACK*

16) Assertion(A): List is an immutable data type


Reasoning(R): When an attempt is made to update the value of an immutable
variable, the old variable is destroyed and a new variable is created by the same
name in memory
Ans) Option d A is false but R is True
17) Assertion(A): Python Standard Library consists of various modules.
Reasoning(R): A function in a module is used to simplify the code and avoids
repetition
Option b Both A and R are true but R is not the correct explanation for A
18) State True or False “Variable declaration is implicit in Python.”
Ans. TRUE
19) Which of the following is an invalid datatype in Python?
(a) Set (b) None (c)Integer (d)Real
Ans: (d) Real
20) Given the following dictionaries
dict_exam={"Exam":"AISSCE", "Year":2023}
dict_result={"Total":500, "Pass_Marks":165}
Which statement will merge the contents of both dictionaries?
a. dict_exam.update(dict_result)
b. dict_exam + dict_result
c. dict_exam.add(dict_result)
d. dict_exam.merge(dict_result)
Ans: (a) dict_exam.update(dict_result)
21) Consider the given expression: not True and False or True Which of the following
will be correct output if the given expression is evaluated?
(a) True (b) False (c) NONE (d) NULL
Ans: (a) True
22) Select the correct output of the code:
a = "Year 2022 at All the best"
a = a.split('2')
b = a[0] + ". " + a[1] + ". " + a[3]
print (b)
(a) Year . 0. at All the best (b) Year 0. at All the best (c) Year . 022. at All the best
(d) Year . 0. at all the best
Ans: (a) Year . 0. at All the best
23) Which of the following statement(s) would give an error after executing the
following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
(a) Statement 3 (b) Statement 4 (c) Statement 5
Ans: (b) – Statement 4
24) What will the following expression be evaluated to in Python?
print(15.0 / 4 + (8 + 3.0))
(a) 14.75 (b)14.0 (c) 15 (d) 15.5
Ans: (a) 14.75
25) Find the invalid identifier from the following a. none b. address c. Name d. pass
e. pass
26) Consider a declaration L = (1, 'Python', '3.14'). Which of the following represents
the data type of L? a. list b. tuple c. dictionary d. string
Ans) b tuple
27) Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90). What will be the output of
print (tup1 [3:7:2])?
a. (40,50,60,70,80) b. (40,50,60,70) c. [40,60] d. (40,60)
Ans) d. (40,60)
28) The return type of the input() function is a. string b. integer c. list d. tuple
Ans) a
29) Which of the following operator cannot be used with string data type?
a. + b. in c. * d. /
Ans) d
30) Consider a tuple tup1 = (10, 15, 25, and 30). Identify the statement that will
result in an error. a. print(tup1[2]) b. tup1[2] = 20 c. print(min(tup1))
Ans) b
31) Which one of the following is the default extension of a Python file? a. .exe b. .p++
c. .py d. .p
Ans) c py
32) Which of the following symbol is used in Python for single line comment?
a. / b. /* c. // d. #
Ans) d
33) Which of these about a dictionary is false? a) The values of a dictionary can be
accessed using keys b) The keys of a dictionary can be accessed using values c)
Dictionaries aren’t ordered d) Dictionaries are mutable
Ans) b
34) What is the output of following code:
T=(100) print(T*2)
a. Syntax error b. (200,) c. 200 d. (100,100)
Ans) c
35) Identify the output of the following Python statements.
x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
y = x[1][2]
print(y)
a. 12.0 b. 13.0 c. 14.0 d. 15.0
Ans) d. 15.0
36) Identify the output of the following Python statements.
x=2
while x < 9:
print(x, end='')
x=x+1
a. 12345678 b. 123456789 c. 2345678 d. 23456789
Ans) c. 2345678
37) Identify the output of the following Python statements.
b=1
for a in range(1, 10, 2):
b += a + 2
print(b)
a. 31 b. 33 c. 36 d. 39
Ans) c. 36
38) Identify the output of the following Python statements.
lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])
a. 2 b. 3 c. 4 d. 20
Ans) b 3
39) Evaluate the following expression and identify the correct answer.
16 - (4 + 2) * 5 + 2**3 * 4
a. 54 b. 46 c. 18 d. 32
Ans) c 18
40) Find the output of the following code:
Name="PythoN3.1"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#" print(R)
a. pYTHOn##@ b. pYTHOnN#@ c. pYTHOn#@ d. pYTHOnN@#
Ans) b. pYTHOnN#@

41) What will be the output of the following code?


tup1 = (1,2,[1,2],3)
tup1[2][1]=3.14
print(tup1)
a. (1,2,[3.14,2],3) b. (1,2,[1,3.14],3) c. (1,2,[1,2],3.14) d. Error Message
Ans) b. (1,2,[1,3.14],3)
42) State True or False : “In Python, tuple is a mutable data type”.
Ans) False
43) What will be the output of the following statement ?
print(6+5/4**2//5+8)
Ans) 14.0
44) Select the correct output of the code :
S = "text#next"
print(S.strip("t"))
(A) ext#nex (B) ex#nex (C) text#nex (D) ext#next
Ans) A
45) Identify the valid Python identifier from the following
(A) 2user (B) user@2 (C) user_2 (D) user 2
Ans) A
46) Consider the statements given below and then choose the correct output
from the given options :
Game="World Cup 2023"
print(Game[-6::-1])
(A) CdrW (B) ce o (C) puC dlroW (D) Error
Ans) C
47) Predict the output of the following Python statements :
>>>import statistics as s
>>>s.mode ([10, 20, 10, 30, 10, 20, 30])
(A) 30 (B) 20 (C) 10 (D) 18.57
Ans) C
48) Which of the following output will never be obtained when the given code is
executed ?
import random
Shuffle = random.randrange(10)+1
Draw = 10*random.randrange(5)
print ("Shuffle", Shuffle, end="#")
print ("Draw", Draw)
(A) Shuffle 1 # Draw 0 (B) Shuffle 10 # Draw 10 (C) Shuffle 10 # Draw 0
(D) Shuffle 11 # Draw 50
Ans) D

49) For the following Python statement :


N = (25) What shall be the type of N ?
(A) Integer (B) String (C) Tuple (D) List
Ans) A

50)

Ans) a

2 mark questions

51) Predict the output of the following code :


d={"IND":"DEL","SRI:"COL","CHI":"BEI"}
str1=""
for i in d:
str1=strl+str(d[i])+"@"
str2=str1[:–1]
print (str2)

Ans) DEL@COL@BEI

52) Write the Python statement for each of the following tasks using
BUILT-IN functions/methods only : 1+1=2
(i) To delete an element 10 from the list lst.
(ii) To replace the string "This" with "That" in the string str1.

Ans) lst.remove(10)
Str1=str1.replace(‘This’,’That’)

53) A dictionary dict2 is copied into the dictionary dict1 such that the common key’s
value gets updated. Write the Python commands to do the task and after that empty
the dictionary dict1.
Ans)
dict1.update(dict2)
dict1.clear()

54) Predict the output of the Python code given below :

s="India Growing"
n = len(s)
m=""
for i in range (0, n) :
if (s[i] >= 'a' and s[i] <= 'm') :
m = m + s [i].upper()
elif (s[i] >= 'O' and s[i] <= 'z') :
m = m +s [i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m + '@'
print (m)

Ans) iIDIA@gGroIiG
55) a. Given is a Python string declaration: myexam="@@CBSE Examination
2022@@" Write the output of: print(myexam[::-2])
b. Write the output of the code given below:
my_dict = {"name": "Aman", "age": 26}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items())

Ans) a @20 otnmx SC@


b) dict_items([('name', 'Aman'), ('age', 27), ('address', 'Delhi')])

56) Predict the output of the Python code given below:


tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

Ans) Ans: (22,44,66)

57) Predict the output of the code given below:


s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else: m = m +'&'
print(m)
Ans) sELCcME&Cc

58) A) Given in a Python string declaration


NAME = "Learning Python is Fun"
Write the output of : print(NAME[-5:-10:-1])

B) Write the output of the code given below :


dict1={1:["Rohit",20], 2:["Siya",90]}
dict2={1:["Rahul",95], 5:["Rajan",80]}
dict1.update(dict2)
print(dict1.values())

Ans) A) Output: si no
B) dict_values([['Rahul', 95], ['Siya', 90], ['Rajan', 80]])

59) What possible output(s) are expected to be displayed on screen at the time of
execution of the following code ?
Options :(I) Pencil:Book
(II) Pencil:Book
Eraser:Bag
(III) Pen:Book
Bag:Book
(IV) Bag:Eraser
Ans) I and IV
60) Predict the output of the code given below :
text="LearningCS"
L=len(text)
ntext=""
for i in range (0,L):
if text[i].islower():
ntext=ntext+text[i].upper()
elif text [i].isalnum():
ntext=ntext+text[i-1]
else:
ntext=ntext+'&&'
print(ntext)
Ans) SEARNINGgC
61) Predict the output of the code given below:
s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)
Ans) sELCcME&Cc
62)

Ans) Students.pop(“Nisha”)
print(Message.count(“is”))
63) What possible outputs(s) are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO+1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv) 40#50#70#
Ans) Max value of From = 3
To=4
ii)

64)

Ans) R*A*C*E*C*A*R*
C#A#R#
R*A*D*A*R*

65)

Ans)
Lst=list(subject)
Lst.pop()

You might also like