0% found this document useful (0 votes)
57 views10 pages

Revision Tour - Practice Questions

The document contains a series of Python revision questions for a class 12 computer science curriculum, focusing on various topics such as identifiers, data types, operators, and control structures. It includes both 1-mark and 2-mark questions that test knowledge on Python syntax, data structures, and programming concepts. The questions are designed to assess understanding and application of Python programming principles.

Uploaded by

Suparswa Manna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views10 pages

Revision Tour - Practice Questions

The document contains a series of Python revision questions for a class 12 computer science curriculum, focusing on various topics such as identifiers, data types, operators, and control structures. It includes both 1-mark and 2-mark questions that test knowledge on Python syntax, data structures, and programming concepts. The questions are designed to assess understanding and application of Python programming principles.

Uploaded by

Suparswa Manna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Revision Tour

Computer Science class 12 previous year questions


Python revision tour class 12 – 1 Mark Questions

[1] Find the invalid identifier from the following:


a. MyName b. True c. 2ndName d. My_Name

[2] Given the lists L=[1,3,6,82,5,7,11,92] , write the output of print(L[2:5]).

[3] Identify the valid arithmetic operator in Python from the following.
a. ? b. < c. ** d. and

[4] Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is
incorrect?
a. print(T[1]) b. T[2] = -29 c. print(max(T)) d. print(len(T))

[5] Write a statement in Python to declare a dictionary whose keys are 1, 2, 3 and values
are Monday, Tuesday and Wednesday respectively.

[6] A tuple is declared as T = (2,5,6,9,8) What will be the value of sum(T)?

[7] If the following code is executed, what will be the output of the following code?
name="ComputerSciencewithPython"
print(name[3:10])

[8] Find the invalid identifier from the following:


a. none b. address c. Name d. pass

[9] 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

[10] 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)

[11] Which of the following operator cannot be used with string data type?
a. + b. in c. * d. /

[12] 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)) d. print(len(tup1)

[13] Which one of the following is the default extension of a Python file?
a. .exe b. .p++ c. .py d. .p

[14] Which of the following symbol is used in Python for single-line comment?
a. / b. /* c. // d. #
[15] 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

[16] What is the output of the following code:


T=(100)
print(T*2)

a. Syntax error b. (200,) c. 200 d. (100,100)

[17] 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

[18] 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

[19] Identify the output of the following Python statements.


b=1
for a in range(1, 10, 2):
b += a + 2
printb.
a. 31 b. 33 c. 36 d. 39

[20] 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

[21] Evaluate the following expressions and identify the correct answer.
i) 16 – (4 + 2) * 5 + 2**3 * 4
ii) 1+(2-3)*4**5//6

[22] State True or False “Variable declaration is implicit in Python.”

[23] Which of the following is an invalid datatype in Python?


a. Set b. None c. Integer d. Real
[24] 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)

[25] Consider the given expression:


not True and False or True
Which of the following will be the correct output if the given expression is evaluated?
a. True b. False c. NONE d. NULL

[26] 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

[27] 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 d. Statement 4 and 5

[28] 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

[29] 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

[30] Which is the correct form of declaration of dictionary?


a. Day={1:’monday’,2:’tuesday’,3:’wednesday’}
b. Day=(1;’monday’,2;’tuesday’,3;’wednesday’)
c. Day=[1:’monday’,2:’tuesday’,3:’wednesday’]
d. Day={1’monday’,2’tuesday’,3’wednesday’]

[31] Kunj has declared a variable as follows:


L=[1,45,’hello’,54.6]
Identify L?
a. List b. Tuple c. Dictionary d. Function
[32] Write the output of following:
x = "abcdef"
i = "a"
while i in x:
print(i, end = " ")

a. abcdef b. abcde c. bcde d. infinite loop

[33] Observe the following code written by Rupal. She has used ++ in place of the
exponential operator. Rewrite the correct code after removing all errors.
r=3.5,h=2.5
area=2*pi*r*h+2*(r++2)
print (area)

Which of the following operator will replace ++?


a. // b. * c. ** d. %

[34] Given is a Python string declaration:


myexam="@@CBSE Examination 2022@@"
Write the output of: print(myexam[::-2])
a. @20 otnmx SC@ b. @@CBSE Examination 2022
c. @2202 noitanimaxE ESBC d. None of these

[35] 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())
a. dict_items([(‘name’, ‘Aman’), (‘age’, 27), (‘address’, ‘Delhi’)])
b. dict_items([(‘name’,’Aman’),(‘age’,26)])
c. dict_items({name:’Aman’,age:27,’address’:’Delhi’})
d. Error Message

[36] For the given declaration in Python as s=’WELCOME’:


Which of the following will be the correct output of print(S[1::2])?
a. WEL b. COME c. WLOE d. ECM

[37] Which of the following is the correct output for the execution of the following Python
statement?
print (5 + 3 ** 2 /2)
a. 82 b. 9.5 c. 8.0 d. 32.0

[38] Which of the following is not a Tuple in Python?


a. (1,2,3) b. (“One”,”Two”, “Three”)
c. (10,) d. (“one”)

[39] Which of the following is not a valid Python string operation?


a. ‘Welcome’ + ’10’ b. Welcome’ * 10 c. ‘Welcome’ * 10.0 d. “10” + ‘Welcome”
[40] What will be the output for the following Python statements?
L =[10, 20, 30, 40, 50]
L=L+5
print (L)
a. [10, 20, 30, 40, 50, 5] b. [15, 25, 35, 45,55]
c. [5,10, 20, 30, 40, 50] d. Error

[41] What will be the output for the following Python statements:
D={ "AMIT" :90, "RESHMA" : 96,”SUKHBIR”:92, “JOHN”:95}
print(“JOHN” in D, 90 in D, sep=’#’)
a. True#False b. False#True c. True#True d. False#False

[42] Nitish has declared a tuple T in Python as follows:


T = (10, 20, 30)
Now, he wants to insert an element 40 after these three elements of T so that the
tuple may contain (10,20, 30, 40).
Which of the following statements shall Nitish write to accomplish the above task?
a. T = T + 40
b. T = T+ (40)
c. T = T + (40,)
d. Nitish cannot insert 40 into the tuple since Tuples are immutable

[43] Identify the output of the following Python statements:


L = []
for i in range (4):
L.append (2*i+1)
print (L[::-1])
a. [4,3,2,1] b. [9,7,5,3] c. [7,5,3,1] d. [1,2,3,4]

[44] Identify the output of the following Python statements:


D={}
T= ("ZEESHAN", "NISHANT", "GURMEET" , "LISA")
for i in range (1,5):
D[i]=T[i-1]
print (d)

a. {“ZEESHAN”, “NISHANT”, “GURMEET”,”LISA”}


b. “ZEESHAN”, “NISHANT”, ” GURMEET”,”LISA”
c. [1, “ZEESHAN”], [2, “NISHANT”], [3, “GURMEET”], [4,” LISA”]
d. {1:” ZEESHAN” , 2:”NISHANT”, 3: “GURMEET” , 4: “LISA”}

[45] Identify the output of the following Python statements :


L1, L2= [10, 15, 20, 25], []
for i in range (len (L1)):
L2. insert( i,Ll.pop ())
print (LI, L2, sep="&" )

a. [] & [25, 20, 15, 10]


b. [10, 15, 20, 25] & [25, 20, 15,10]
c. [10, 15, 20, 25]&[10, 15, 20, 25]
d. [25, 20, 15, 10]&[]
[46] Which of the following option can be the output for the following Python code?
Ll= [10,20,30,20,10]
L2=[]
for i in Ll:
if i not in L2:
L2.append (i)
print (Ll, L2,sep="&")

a. [10,20,30,20,10]&[10,20,30, 20,10] b. [10,20,30,20,10] [10,20,30,20,10]&


c. [10,20,30,20,10]&[30,20,10] d. [10,20,30,20,10]&[10,20,30]

[47] Identify the output of the following Python code:


D={1:"One", 2:"Two", 3: "Three"}
L=[]
for K,V in D. items ():
if V[0l=="T":
L.append (K)
print (L)
a. [1,2,3] b. [“One”, “Two”, “Three”]
c. [2,3] d. [“Two”, “Three”]

[48] What will be the output of the following Python code ?


L = [10, 201]
L1=[30,40]
L2=[50,60]
L.append (L1)
L.extend (L2)
print (L)
a. [60, 50, 40, 30, 20, 10] b. [10, 20, 30, 40, 50, 60]
c. [10, 20, 30, 40, [50, 60]] d. [10, 20, [30, 40], 50, 60]

[49] Find and write the output of the following python code :
for Name in ['John', 'Garima','Seema','Karan']:
print(Name)
if Name[0]=='S':
break
else:
print ('Completed!')
print('Weldone!')

[50] What will be the output of the following Python code?


S="UVW" ;L=[10,20,301]
D={}
N=len (S)
for I in range (N):
D[I] = S[I]
for K,V in D.items ():
print (K,V, sep="*" ,end="")

a. U*10,V*20,W*30, b. 10*U, 20*v, 30*W,


c. 10,20,30,u*v*w* d. Error
Python revision tour class 12 – 2 Marks Questions

[1] What do you understand by the term Iteration? Write the types of iterative statements
supported by python.

[2] What is a dictionary? How to create a dictionary in python?

[3] Write type of operators from the following:


1. /=
2. ==
3. =
4. and

[4] Identify only arithmetic operators from the following:


//=, //, ** ,==, %, +

[5] Yashvi has given the following symbols and word to identify which types of tokens are
they, help her to identify them:
1. If
2. r_no
3. True
4. in

[6] Rewrite the following code after removing errors:


30=To
for i in range(0,To)
IF i%4==0
print (i*4) -
Else
print (i+3)

[7] Find the output for the following:


l = [6 , 3 , 8 , 10 , 4 , 6 , 7]
print( '@', l[3] - l[2])
for i in range (len(l)-1,-1,-2) :
print( '@',l[i],end='' )

[8] Evaluate the following expressions:


a. 6 * 3 + 4**2 // 5 – 8
b. 10 > 5 and 7 > 12 or not 18 > 3

[9] 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)
[10] 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)

[11] 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)

[12] Find and write the output of the following python code :
for Name in ['John', 'Garima','Seema','Karan']:
print(Name)
if Name[0]=='S':
break
else:
print('Completed!')
print('Weldone!')

[13] Write a program in python to display the elements of list twice, if it is a number and
display the element terminated with ‘*’ if it is not a number. For example, if the content
of list is as follows : MyList=[‘RAMAN’,’21’,’YOGRAJ’,’3′,’TARA’]
The output should be
RAMAN*
2121
YOGRAJ*
33
TARA*
[14] Rewrite the following code in Python after removing all syntax errors. Underline the
corrections.
for Name in [Ramesh, Suraj, Priya]
IF Name[0]=’S’:
print(Name)
[14] Find the output of the following:
values = [10,20,30,40]
for v in values:
for i in range(1, v%9):
print(i,’*’,end=’’)
print()

[15] Find and write the output of the following Python code :
Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = ""
Add = 0
for C in range(1,6,2):
Times = Times + C
Alpha = Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times,Add,Alpha)

[16] Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
25=Val
for I in the range(0,Val)
if I%2==0:
print I+1
Else:
print (I–1)

[17] Find and write the output of the following python code :
Text1="SSCE 2023"
Text2=" "
I=0
while I<len(Text1):
if Textl[I]>="0" and Textl[I]<="9":
Val = int(Textl[I])
Val = Val + 1
Text2=Text2 + str(Val)
elif Textl[I]>="A" and Textl[I] <="Z":
Text2=Text2 + (Text1[I+1])
else :
Text2=Text2 + "*"
I=I+1
print(Text2)

[18] Write the names of any four data types available in Python.
[19] Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
250 = Number
WHILE Number<=1000:
if Number=>750:
print Number
Number=Number+100
else
print Number*2
Number=Number+50

[20] Find and write the output of the following python code :
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print(Msg3)

You might also like