Q. Carefully go through the code given below and answer the questions based on it:
in1Str = input ("Enter string of digits: ")
in2Str = input ("Enter string of digits: ")
if len(in1Str) > len(in2Str) :
small = in2Str
large = in1Str
else :
small = in1Str
large = in2Str
newStr = ''
for element in small :
result = int(element) + int(large[0])
newStr = newStr + str(result)
large = large[1:]
print (len(newStr))#Line 1
print(newStr)#Line 2
print (large)#Line 3
print (small)#Line 4
(i) Given a first input of 12345 and a second input of 246, what result is produced by a Line 1?
(a) 1
(b) 3
(c) 5
(d) 0
(e) None of these
(ii) Given a first input of 12345 and a second input of 246, what result is produced by Line 2?
(a) 369
(b) 246
(c) 234
(d) 345
(e) None of these
(iii) Given a first input of 123 and a second input of 4567, what result is produced by Line 3?
(a) 3
(b) 7
(c) 12
(d) 45
(e) None of these
(iv) Given a first input of 123 and a second input of 4567, what result is produced by Line 4?
(a) 123
(b) 4567
(c) 7
(d) None of these
Answer =
(i) Option (b)
(ii) Option (a)
(iii) Option (b)
(iv) Option (a)
in 9th line, there shouldn't be a space between the quotes. thanks for the answers
ReplyDeleteOk : )
Delete1 ka answer is (b)
ReplyDeleteSorry, I have corrected it.
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )