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

 

inputStr = input("Give me a string: ")

bigint = 0

littlelnt = 0

otherlnt = 0

for ele in inputStr :

    if ele >= 'a' and ele <= 'm' :#Line 1

        littleInt = littleInt + 1

    elif ele > 'm' and ele <= 'z' :

        bigint  = bigint + 1

    else :

        otherInt - otherInt + 1

 

print (bigInt)#Line 2

print (littlelnt)#Line 3

print (otherInt)#Line 4

print (inputStr.isdigit())#Line 5

 

(i) Given the input abcd what output is produced by Line 2?

 

(a) o

(b) 1

(c) 2

(d) 3

(e) None of these

 

(ii) Given the input Hi Mom what output is produced by Line 3?

 

(a) 0

(b) 1

(c) 2

(d) 3

(e) None of these

 

(iii) Given the input Hi Mom what output is produced by Line 4?

 

(a) 0

(b) 1

(c) 2

(d) 3

(e) None of These

 

(iv) Given the input 1+ 2 = 3 what output is produced by Line 5?

 

(a) 0

(b) 1

(c) True

(d) False

(e) None of these

 

(v) 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'?

 

(a) No change

(b) otherInt would be larger

(c) littlelet would be larger

(d) bigint would be larger

(e) None of these

 

Answer =

 

(i) Option (a)

(ii) Option (c)

(iii) Option (d)

(iv) Option (d)

(v) Option (b)

1 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post