Vidyalelo
Python · all questions

Python Introduction and basic
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

81

Questions

4/5

Page

Pick an option on a question to see the right answer and solution.

What will be the value of 'result' in following Python program?
list1 = [1,2,3,4]
list2 = [2,4,5,6]
list3 = [2,6,7,8]
result = list()
result.extend(i for i in list1 if i not in (list2+list3) and i not in result)
result.extend(i for i in list2 if i not in (list1+list3) and i not in result)
result.extend(i for i in list3 if i not in (list1+list2) and i not in result)

Select an option to see the answer and solution.

Which function is called when the following Python program is executed?
f = foo()
format(f)

Select an option to see the answer and solution.

What will be the output of the following Python program?
z=set('abc')
z.add('san')
z.update(set(['p', 'q']))
z

Select an option to see the answer and solution.

What will be the output of the following Python expression if x=56.236?
print("%.2f"%x)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
z=set('abc$de')
'a' in z

Select an option to see the answer and solution.

Which module in the python standard library parses options received from the command line?

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>list1 = [1, 3]
>>>list2 = list1
>>>list1[0] = 4
>>>print(list2)

Select an option to see the answer and solution.

What will be the output of the following Python code?
l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
    print(i)

Select an option to see the answer and solution.

What will be the output of the following Python statement?
>>>"a"+"bc"

Select an option to see the answer and solution.

What are the two main types of functions in Python?

Select an option to see the answer and solution.

What is output of print(math.pow(3, 2))?

Select an option to see the answer and solution.

What will be the output of the following Python program?
def addItem(listParam):
    listParam += [1]
 
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))

Select an option to see the answer and solution.

Which of the following statements is used to create an empty set in Python?

Select an option to see the answer and solution.

Which of the following is a feature of Python DocString?

Select an option to see the answer and solution.

Which of the following Python statements will result in the output: 6?
A = [[1, 2, 3],
     [4, 5, 6],
     [7, 8, 9]]

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

Select an option to see the answer and solution.

What will be the output of the following Python code snippet if x=1?
x<<2

Select an option to see the answer and solution.

What will be the output of the following Python code?
class tester:
    def __init__(self, id):
        self.id = str(id)
        id="224"
 
>>>temp = tester(12)
>>>print(temp.id)

Select an option to see the answer and solution.

What are the values of the following Python expressions?
2**(3**2)
 (2**3)**2
 2**3**2

Select an option to see the answer and solution.