Computer Science
Carefully go through the code given below and answer the questions based on it :
inputStr = input(" Give me a string:")
biglnt = 0
littlelnt = 0
otherlnt = 0
for ele in inputStr:
if ele >= 'a' and ele <= 'm': # Line 1
littlelnt = littlelnt + 1
elif ele > 'm' and ele <= 'z':
biglnt = biglnt + 1
else:
otherlnt = otherlnt + 1
print (biglnt) # Line 2
print (littlelnt) # Line 3
print (otherlnt) # Line 4
print (inputStr.isdigit()) # Line 5
Given the input 1+2 =3 what output is produced by Line 5?
- 0
- 1
- True
- False
- None of these
Related Questions
Carefully go through the code given below and answer the questions based on it :
inputStr = input(" Give me a string:") biglnt = 0 littlelnt = 0 otherlnt = 0 for ele in inputStr: if ele >= 'a' and ele <= 'm': # Line 1 littlelnt = littlelnt + 1 elif ele > 'm' and ele <= 'z': biglnt = biglnt + 1 else: otherlnt = otherlnt + 1 print (biglnt) # Line 2 print (littlelnt) # Line 3 print (otherlnt) # Line 4 print (inputStr.isdigit()) # Line 5
Given the input Hi Mom what output is produced by Line 3?
- 0
- 1
- 2
- 3
- None of these
Carefully go through the code given below and answer the questions based on it :
inputStr = input(" Give me a string:") biglnt = 0 littlelnt = 0 otherlnt = 0 for ele in inputStr: if ele >= 'a' and ele <= 'm': # Line 1 littlelnt = littlelnt + 1 elif ele > 'm' and ele <= 'z': biglnt = biglnt + 1 else: otherlnt = otherlnt + 1 print (biglnt) # Line 2 print (littlelnt) # Line 3 print (otherlnt) # Line 4 print (inputStr.isdigit()) # Line 5
Given the input Hi Mom what output is produced by Line 4?
- 0
- 1
- 2
- 3
- None of these
Carefully go through the code given below and answer the questions based on it :
inputStr = input(" Give me a string:") biglnt = 0 littlelnt = 0 otherlnt = 0 for ele in inputStr: if ele >= 'a' and ele <= 'm': # Line 1 littlelnt = littlelnt + 1 elif ele > 'm' and ele <= 'z': biglnt = biglnt + 1 else: otherlnt = otherlnt + 1 print (biglnt) # Line 2 print (littlelnt) # Line 3 print (otherlnt) # Line 4 print (inputStr.isdigit()) # Line 5
Give the input Hi Mom, what changes result from modifying Line 1 from
if ele >= 'a' and ele <='m' to the expression
if ele >= 'a' and ele < 'm'?- No change
- otherlnt would be larger
- littlelnt would be larger
- biglnt would be larger
- None of these
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
Given a first input of 12345 and a second input of 246, what result is produced by Line 1?
- 1
- 3
- 5
- 0
- None of these