Header Ads

Python Basic MCQ

  

Python Basic MCQ 


1. What's the output?

def hello(k):

    k = [1]

x = [0]

hello(x)

print(x)

  1. A: [0]
  2. B: [1]
  3. C: [1,0]
  4. D: [0,1]


2. What's the output?

str1= '{3},{1} and {0}'. format('p','r','i')

print(str1)

  1. A: Tuple index out of range
  2. B: i,r and p
  3. C: ppp,r
  4. D: None


3. What's the output?

str1= '{1},{1},{2} and {0}'. format('p','r','i')

str2 = '{0}{1}{0}'.format('priya', 'cad')

print(str1,str2)

  1. A: r,r,i,p priyacad0
  2. B: r,r,i and p priyacad0
  3. C: r,r,i and p priyacadpriya
  4. D: p,p,r and i priyacadpriya


4. What's the output?

a=3

b=3.876

c= -5

str1 = '{0:.4f} {0:3d} {2} {1}'.format(a, b, c)

print(str1)

Here, hash(#) represent spaces.


  1. A: 3.0000 3 -5 3.876
  2. B: 3 3.876 -5 3.876
  3. C: 3.0000 ###3 -5 3.876
  4. D: 3.0000 ##3 -5 3.876


5. What's the output?

line1='And here you can learn '

line2='You will fall in love with python '

line3='Pyhton is interpreted language '

line4=line1 + line2 + line3

print(line1.find('you'),line4.count('python'))

  1. A: 9,2
  2. B: 9 1
  3. C: (9,1)
  4. D: True,1


Powered by Blogger.