In this article, we are going to discuss 20 High-Order Thinking Skills (HOTS) Questions with Solutions – Class 12 Computer Science (Python). Let us begin !
20 High-Order Thinking Skills (HOTS) Questions with Solutions – Class 12 Computer Science (Python)
These questions are taken from the below given topics:
- Tokens
- Variable Assignments
- Expressions
- Flow of control
- Strings
- Lists
- Tuples
- Dictioanries
These topics are from the chapter Python revision tour. So let us begin:
[1] Identify the tokens from the given code:
if age >= 18 and age <= 60:
print("Eligible for vote")
else:
print("Not Eligible not eligible for vote")
[3] Predict the output:
a = 5
b = 3.14
c = "Hello"
d = True
print(type(a), type(b), type(c), type(d))
[4] What will be the result of the following expression? Explain the order of operations.
result = 10 + 2 * 5 / (3 - 1) ** 2
print(result)
[5] Identify the errors in the given program and rewrite the correct code and underline the corrections:
num = int("Enter a number: ")
if num > 0
print("Positive")
else if num < 0:
print("Negative")
else:
print(Zero)
Ans.:
num = int(input("Enter a number: ")) #input function is missing
if num > 0: #colon is mising
print("Positive")
elif num < 0: #elif not else if
print("Negative")
else:
print("Zero") #Zero should be enclosed in double quotation
[6] What will be the output of the following code:
a, b = 0, 1
for _ in range(4):
print(a, end=" ")
a, b = b, a + b
[7] What will be the output of given code:
a = b = c = 100
a += 10
b -= 5
c *= 2
print(a, b, c)
[8] What will be the output for the following:
for Name in ['John', 'Garima','Seema','Karan']:
print(Name)
if Name[-1]=='a':
break
else:
print('Completed!')
print('Weldone!')
[9] Name the function/method required to
(i) check if a string contains only alphabets
(ii) reutrn the position of specified character
[10] Out of the following, find those identifiers, which cannot be used as identifiers in a Python program:
Total*Tax, While, class, switch, 3rdRow, finally, Column31, _Total
[11] Name the Python Library modules which need to be imported to invoke the following functions.
(i) mean()
(ii) randint()
[12] Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code.
for Name in <'Rachana','Komal','Kapil','Paresh'>:
IF Name[0]='K':
print(name)
Ans.:
for Name in ['Rachana', 'Komal', 'Kapil', 'Paresh']:#Changed to a valid list form
if Name[0] == 'K': #Changed 'IF' to 'if'
#Used == instead of '='
print(name) #Name instead of Name
[13] Find and write the output of the following Python code:
v = [11, 20, 33, 40]
for i in v:
for j in range(1, i % 5):
print(j, "*", end="")
[14] Which of the following can be used as valid variable identifier(s) in Python ?
(i) elif
(ii) BREAK
(iii) in
(iv) _Total
[15] Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code.
NUM1=1234
1=DAY1
for C in range[1,4]:
NUM1+C=NUM1
DAY1=DAY1+2
print(C)
print(NUM1:DAY1)
Ans.:
NUM1=1234
l=DAY1 #Replace l with 1
for C in range(1,4): #Replace square brackets with round brackets
NUM1=NUM1+C #Replace lvalue with rvalue
DAY1=DAY1+2
print(C)
print(NUM1,DAY1) #Use comma inplace of colon
[16] Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code.
Val = int(input("Value:"))
Adder = 0
for C in range(1,Val,3)
Adder=+C
if C%2=0:
Print(C*10)
else:
print(C+10)
print(Adder)
[17] 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)
[18] Which of the following are valid operators in Python :
(i) **
(ii) */
(iii) like
(iv) | |
(v) is
(vi) ^
(vii) between
(viii) in
[19] Find and write the output of the following python code :
Text1="AISSCE 2018"
Text2=" "
I=0
while I<len(Textl) :
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)
[20] Write the names of any four data types available in Python.