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 3, what output is produced by Line 1?
- This is a test
- This is a
- is a test
- is a
- None of these
Python String Manipulation
5 Likes
Answer
Option 1 — This is a test
Answered By
4 Likes
Related Questions
What will be the output produced by following code fragments?
x = "hello" + \ "to Python" + \ "world" for char in x : y = char print (y, ' : ', end = ' ')
What will be the output produced by following code fragments?
x = "hello world" print (x[:2], x[:-2], x[-2:]) print (x[6], x[2:4]) print (x[2:-3], x[-4:-2])
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 3, what output is produced by Line 2?
- This is a test
- s is a t
- is a test
- is a
- None of these
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?
- 0
- 1
- 2
- 3
- None of these