Q. Below are seven segments of code, each with a part colored . Indicate the data type of each colored part by choosing the correct type of data from the following type.

 

(a) int (b) float (c) bool (d) str (e) function (f) list of int (g) list of str

 

(i) 
if temp < 32 :
        print("Freezirg")
 
Answer = function

(ii) 
L = [ 'Hiya', 'Zoya', Preet' ]
print(L[1])

Answer = str

(iii)
M = [ ]
for i in range (3) :
M. append (i)
print(M)

Answer = list of int

(iv)
L = [ 'Hiya', 'Zoya', 'Preet' ]
n = len (L)
if ‘Donald’ in L[1: n] :
print (L) (i2)

Answer = int

v) 
if n% 2 == 0 :
print("Freezing") 

Answer = bool

(vi) L = inputline.split()
while L != ( ) :
        print (L)
L = L[1:]

Answer = list of str

(vii) 
L= [ 'Hiya', Zoya', 'Preet' ]
print (L[0] + L[1] )  

Answer = str

13 Comments

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

  1. Replies
    1. No nothing is wrong . if you found mistake then please tell us .!!!

      Delete
    2. (i) bool
      (ii) str
      (iii) list of int
      (iv) int
      (v) bool
      (vi) list of str
      (vii) str

      Please check the first ans of this question
      i) bool

      Delete
    3. temp < 32 is either false or true so it's answer is bool.

      Delete
  2. Replies
    1. Please run it in your IDLE Python and print Data Type of that part of Question.

      Delete
  3. How is n%2==0: a bool value

    ReplyDelete
    Replies
    1. Because n %2 can give only two output that is True or False.

      Delete
  4. Very useful thanks

    ReplyDelete

Post a Comment

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

Previous Post Next Post