Logo

Python Questions Set 153:

Quiz Mode

Which of the following is not a built-in function in python.

1
2
3
4

Solution:

 

What will be the output of the following Python code?

def unpack(a,b,c,d):
   print(a+d)
x = [1,2,3,4]
unpack(*x)

1
2

Solution:

What is the output of the following Python code?

import random

print(random.randint(0,9))

1
2
3
4

Solution:

Using a comma as a separator in print statements, you can combine:

1
2
3
4

Solution:

Predict the output of the following code:


a = [1, 2, 10, 300, 500]

a[2] = 3

print(a)

1
2
3
4

Solution:

Which of the following Python regular expression functions returns a tuple containing the (start, end) positions of the match?

1
2
3
4

Solution:

When is the value of the module attribute, __name__, equal to 'main'?

1
2
3

Solution:

What is the output of the following code?


def function(lst, x, s, e):

    a = lst.index(x, s, e)

    return a


lst = [1, 2, 2, 3, 5, 6, 1, 2, 2, 2, 3, 4, 5, 2, 8, 9]

print(function(lst, 2, 5, 14))

print(function(lst, 1, 0, 8))

1
2
3
4
5

Solution:

 Which of the following statements is wrong about inheritance? 

1
2
3
4

Solution:

 

What Will Be The Output Of The Following Code Snippet?

class A:
   def __init__(self):
       self.calcI(30)
       print("i from A is", self.i)

   def calcI(self, i):
       self.i = 2 * i;

class B(A):
   def __init__(self):
       super().__init__()
       
   def calcI(self, i):
       self.i = 3 * i;

b = B()

1
2
3
4

Solution: