Logo

Python Questions Set 77:

Quiz Mode

while True print('Hello world')

1
2
3
4

Solution:

 The pickle module defines ______ exceptions and exports _______ classes.

1
2
3
4

Solution:

 

Is the following Python code valid?

>>> a=(1,2,3)
>>> b=('A','B','C')
>>> c=zip(a,b)

1
2

Solution:

 Given a function that does not return any value, What value is thrown by default when executed in shell. 

1
2
3
4

Solution:

What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
   x = 'a'
   print(x)

1
2
3
4

Solution:

 

What will be the output of the following Python code?

A = [[1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]]
[A[i][i] for i in range(len(A))]

1
2

Solution:

What will be the output of the following Python code?

l1=[10, 20, 30]
l2=l1
id(l1)==id(l2)
 
l2=l1.copy()
id(l1)==id(l2)

1
2
3
4

Solution:

 Suppose you need to print pi constant defined in math module. Which of the following code can do this task? 

1
2
3
4

Solution:

In a shallow copy, the modification done on one list affects the other list. In a deep copy, the modification done on one list does not affect the other list.

1
2
3
4

Solution:

Why are local variable names beginning with an underscore (e.g., _my_variable) discouraged in Python?

1
2
3
4

Solution: