51. Syntax errors are also known as parsing errors.
52. What is the purpose of the assert statement in Python?
53. The error displayed in the following Python code is?
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))
54. Which built-in Python function can be used to retrieve the error message associated with an exception?
55. What is the purpose of the except clause without specifying an exception type in a try block?
56. What will be the output of the following Python code?
def f(x):
for i in range(5):
yield i
g=f(8)
print(list(g))
def f(x):
for i in range(5):
yield i
g=f(8)
print(list(g))
57. What will be the output of the following Python code?
try:
if '1' != 1:
raise "someError"
else:
print("someError has not occurred")
except "someError":
print ("someError has occurred")
try:
if '1' != 1:
raise "someError"
else:
print("someError has not occurred")
except "someError":
print ("someError has occurred")
58. Is the following Python code valid?
try:
# Do something
except:
# Do something
else:
# Do something
try:
# Do something
except:
# Do something
else:
# Do something
59. What is the purpose of the assert statement in Python?
60. What will be the output of the following Python code, if the time module has already been imported?
4 + '3'
4 + '3'