Revision Tour - Practice Questions
Revision Tour - Practice Questions
[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.
[7] If the following code is executed, what will be the output of the following code?
name="ComputerSciencewithPython"
print(name[3:10])
[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
[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
[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
[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)
[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
[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
[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!')
[1] What do you understand by the term Iteration? Write the types of iterative statements
supported by python.
[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
[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)
[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)