NEW
Font size
WorksheetsPython MCQs
Total questions: 20
Worksheet time: 10hrs 0mins
What is the maximum length of a Python identifier?
32
16
28
No fixed length is specified
What will be the output of the following code snippet?
print(2**3 + (5 + 6)**(1 + 1))
129
8
121
None of the above
What will be the output of the following code snippet?
a = [1, 2] print(a * 3)
[1, 2]
[1, 2, 1, 2]
Error
[1, 2, 1, 2, 1, 2]
Which of the following is the proper syntax to check if a particular element is present in a list?
if ele in list
if not ele not in list
Both A and B
None of the above
What will be the output of the following code snippet?
numbers = (4, 7, 19, 2, 89, 45, 72, 22) sorted_numbers = sorted(numbers) odd_numbers = [x for x in sorted_numbers if x % 2 != 0] print(odd_numbers)
[7, 19, 45, 89]
[2, 4, 22, 72]
[4, 7, 19, 2, 89, 45, 72, 22]
[2, 4, 7, 19, 22, 45, 72, 89]
Which of the following functions converts date to corresponding time in Python?
strptime()
strftime()
Both A and B
None of the above
What will be the output of the following code snippet?
square = lambda x: x ** 2 a = [] for i in range(5): a.append(square(i)) print(a)
[0, 1, 4, 9, 16]
[1, 4, 9, 16, 25]
[1, 2, 3, 4, 5]
[0, 1, 2, 3, 4]
What will be the output of the following code snippet?
def tester(*argv): for arg in argv: print(arg, end = ' ') tester('Sunday', 'Monday', 'Tuesday', 'Wednesday')
Sunday
Wednesday
Sunday Monday Tuesday Wednesday
None of the above
As what datatype are the *args stored, when passed into a function?
List
Tuple
Dictionary
None of the above
Which of the following blocks will always be executed whether an exception is encountered or not in a program?
try
except
finally
None of these
What keyword is used in Python to raise exceptions?
raise
try
goto
except
What will be the output of the following code snippet?
s1 = {1, 2, 3, 4, 5} s2 = {2, 4, 6} print(s1 ^ s2)
{1, 2, 3, 4, 5}
{1, 3, 5, 6}
{2, 4}
None of the above
What will be the output of the following code snippet?
a = [[], "abc", [0], 1, 0] print(list(filter(bool, a)))
['abc',[0][1]
[1]
["abc"]
None of the above
What will be the output of the following code snippet?
count = 0 while(True): if count % 3 == 0: print(count, end = " ") if(count > 15): break; count += 1
0 1 2 .....15
Infiniote Loop
0 3 6 9 12 15
0 3 6 9 12
What will be the output of the following Python code?
x = [[0], [1]] print((' '.join(list(map(str, x))),))
01
[0] [1]
(’01’)
(‘[0] [1]’,)
What is output of print(math.pow(3, 2))?
9.0
None
9
None of the mentioned
What will be the output of the following Python expression?
print(round(4.576))
4
4.6
5
4.5
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))
5
8
2
1
What are the two main types of functions in Python?
System function
Custom function
Built-in function & User defined function
User function
To add a new element to a list we use which Python command?
list1.addEnd(5)
list1.addLast(5)
list1.append(5)
list1.add(5)
