Computer Science

Carefully go through the code given below and answer the questions based on it :

theStr = " This is a test "         
inputStr = input(" Enter integer: ")
inputlnt = int(inputStr)            
testStr = theStr
while inputlnt >= 0 :               
    testStr = testStr[1:-1]        
    inputlnt = inputlnt - 1
testBool = 't' in testStr
print (theStr)             # Line 1 
print (testStr)            # Line 2 
print (inputlnt)           # Line 3 
print (testBool)           # Line 4 

Given the input integer 2, what output is produced by Line 3?

  1. 0
  2. 1
  3. 2
  4. 3
  5. None of these

Python String Manipulation

3 Likes

Answer

Option 5 — None of these

Explanation

Value of inputlnt will be -1 as till inputlnt >= 0 the while loop will continue executing.

Answered By

3 Likes


Related Questions