lst = [1, 2, 3]
lst[3]Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
65
Questions
3/4
Page
Pick an option on a question to see the right answer and solution.
lst = [1, 2, 3]
lst[3]Select an option to see the answer and solution.
def a():
try:
f(x, 4)
finally:
print('after f')
print('after f?')
a()Select an option to see the answer and solution.
x=10
y=8
assert x>y, 'X too small'Select an option to see the answer and solution.
#generator
def f(x):
yield x+1
g=f(8)
print(next(g))Select an option to see the answer and solution.
valid = False
while not valid:
try:
n=int(input("Enter a number"))
while n%2==0:
print("Bye")
valid = True
except ValueError:
print("Invalid")Select an option to see the answer and solution.
Select an option to see the answer and solution.
def foo():
try:
return 1
finally:
return 2
k = foo()
print(k)Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
import itertools
l1=(1, 2, 3)
l2=[4, 5, 6]
l=itertools.chain(l1, l2)
print(next(l1))Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
def f(x):
for i in range(5):
yield i
g=f(8)
print(list(g))Select an option to see the answer and solution.
try:
if '1' != 1:
raise "someError"
else:
print("someError has not occurred")
except "someError":
print ("someError has occurred")Select an option to see the answer and solution.
try:
# Do something
except:
# Do something
else:
# Do somethingSelect an option to see the answer and solution.
Select an option to see the answer and solution.
4 + '3'Select an option to see the answer and solution.