Q. Carefully go through the code given below and answer the questions based on it:
theStr = 'This is a test ' inputStr = input ("Enter integer: ") inputInt = int (inputStr) testStr = theStr while inputInt >= 0 : testStr = testStr[1:-1] inputInt = inputInt - 1 testBool = 't' in testStr print (theStr)# Line 1 print (testStr)# Line 2 print (inputInt)# Line 3 print (testBool)# Line 4
(i) Given the input integer 3, what output is produced by Line 1?
(a) This is a test
(b) This is a
(c) is a test
(d) is a
(e) None of these
(ii) Given the input integer 3, what output is produced by Line 2?
(a) This is a test
(b) This is a
(c) is a test
(d) is a
(e) None of these
(iii) Given the input integer 2. What output is produced by Line 3?
(a) 0
(b) 1
(c) 2
(d) 3
(e) None of these
(iv) Given the input integer 2. What output is produced by Line 4?
(a) False
(b) True
(c) 0
(d) 1
(e) None of these
(a) This is a test
(b) This is a
(c) is a test
(d) is a
(e) None of these
(ii) Given the input integer 3, what output is produced by Line 2?
(a) This is a test
(b) This is a
(c) is a test
(d) is a
(e) None of these
(iii) Given the input integer 2. What output is produced by Line 3?
(a) 0
(b) 1
(c) 2
(d) 3
(e) None of these
(iv) Given the input integer 2. What output is produced by Line 4?
(a) False
(b) True
(c) 0
(d) 1
(e) None of these
Answer :-
(i) Option (a) This is a test
(ii) Option (e) is a t
(iii) Option (e) -1
(iv) Option (b) True
I think first answer is option d
ReplyDeletesorry I got my mistake the given ans is correct
DeleteOk, : )
Deletei think second question has answer D and third one has answer A
ReplyDeleteAll are correct Please check it again in your IDLE Python.
Delete(ii) will be option (b) s is a t
ReplyDeleteThank you ✨
Welcome : ) , you can run code in IDLE Python.
DeleteI thik (iii) is wrong the answer (e) is none of these
ReplyDeleteAll are correct Please run it your PC.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )