WorksheetsPython For All
Total questions: 10
Worksheet time: 11mins
What is the output of the following code :
L = ['a','b','c','d']
print("".join(L))
Error
abcd
None
[‘a’,’b’,’c’,’d’]
What is the output of the following program :
y = 8
z = lambda x : x * y
print (z(6))
48
14
64
None of the above
What is called when a function is defined inside a class?
Module
Class
Another Function
Method
Which of the following is the use of id() function in python?
Every object doesn’t have a unique id
Id returns the identity of the object
All of the mentioned
None of the mentioned
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
[3, 4, 5, 20, 5, 25, 1, 3]
[1, 3, 4, 5, 20, 5, 25]
[1, 3, 3, 4, 5, 5, 20, 25]
[3, 5, 20, 5, 25, 1, 3]
Given a string s = “Welcome”, which of the following code is incorrect?
print s[0]
print s.lower()
s[1] = ‘r’
print s.strip()
Which function overloads the >> operator?
more()
gt()
ge()
None of the above
What is the output of the following program :
i = 0
while i < 3:
print i
i++
print i+1
0 1 2 3 4 5
0 2 1 3 2 4
Error
1 0 2 4 3 5
Which of the following function convert a string to a float in python?
float(x)
long(x [,base] )
int(x [,base])
str(x)
Find the output of the following program:
D = dict()
for x in enumerate(range(2)):
D[x[0]] = x[1]
D[x[1]+7] = x[0]
print(D)
{0: 1, 7: 0, 1: 1, 8: 0}
{1: 1, 7: 2, 0: 1, 8: 1}
KeyError
{0: 0, 7: 0, 1: 1, 8: 1}
