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:

  1. Tokens
  2. Variable Assignments
  3. Expressions
  4. Flow of control
  5. Strings
  6. Lists
  7. Tuples
  8. 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)

Ans.:

Val = int(input("Value:"))
Adder = 0
for C in range(1,Val,3): #Colon is missing
    Adder+=C             #The operator is incorrect =+ replaced with +=
    if C%2==0:           #Single equal to is given, required ==
      print(C*10)        #Print is given, replaced with print
    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 = "SSCE 2025"
Text2 = " "
I = 0

while I < len(Text1):      
    if Text1[I] >= "0" and Text1[I] <= "9":  
        Val = int(Text1[I])  
        Val = Val + 1  
        Text2 = Text2 + str(Val)  
    elif Text1[I] >= "A" and Text1[I] <= "Z":   
        if I + 1 < len(Text1):  
            Text2 = Text2 + Text1[I + 1]  
        else:
            Text2 = Text2 + "*"
    else:  
        Text2 = Text2 + "*"  
    I = I + 1  

print(Text2)

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

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

[23] Identify the valid keywords in Python from the following :
(i) Queue
(ii) False
(iii) in
(iv) Number
(v) global
(vi) method
(vii) import
(viii) List

[24] Rewrite the following code in Python after removing all syntax error(s). Underline each correction done in the code.

W = raw_input('Enter a word')
If W <> 'HELLO':
  print W + 2
else
  print W * 2

[25] Evaluate the following Python expressions :
(a) 2 * 3 + 4 ** 2 5 // 2
(b) 6 < 12 and not (20 > 15) or (10 > 5)

[26] Rewrite the following code in Python after removing all syntax error(s) . Underline each correction done in the code.

Runs = ( 10, 5, 0, 2, 4, 3 )
for I in Runs:
    if I=0:
        print(Maiden Over)
    else
        print(Not Maiden)

Leave a Reply


Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://api.aspose.cloud/connect/token` resulted in a `429 Too Many Requests` response in /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\Exception\RequestException::create() #1 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}() #2 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler() #3 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() #4 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run() #5 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn() #6 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending() #7 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList() #8 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending() #9 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/guzzle/src/Client.php(123): GuzzleHttp\Promise\Promise->wait() #10 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(50640): GuzzleHttp\Client->send() #11 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(50648): Aspose\Words\WordsApi->_requestToken() #12 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(50654): Aspose\Words\WordsApi->_checkAuthToken() #13 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(50666): Aspose\Words\WordsApi->_getKey() #14 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/aspose-cloud/aspose-words-cloud/src/Aspose/Words/WordsApi.php(80): Aspose\Words\WordsApi->_checkRsaKey() #15 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/src/AsposeWords/Util.php(24): Aspose\Words\WordsApi->__construct() #16 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/src/AsposeWords/ExportEngine.php(87): AsposeWords\Util::getWordsApi() #17 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/src/AsposeWords/AutoExport.php(26): AsposeWords\ExportEngine->convert() #18 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-includes/class-wp-hook.php(324): AsposeWords\AutoExport->export() #19 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #20 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-includes/plugin.php(517): WP_Hook->do_action() #21 /home/u251245109/domains/tutorialaicsip.com/public_html/wp-includes/load.php(1279): do_action() #22 [internal function]: shutdown_action_hook() #23 {main} thrown in /home/u251245109/domains/tutorialaicsip.com/public_html/wp-content/plugins/aspose-doc-exporter/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113