ExamVeda
Login
Home
41
What will be the output of the following Python code?
lst = [1, 2, 3]
lst[3]
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
42
What will be the output of the following Python code?
def a():
    try:
        f(x, 4)
    finally:
        print('after f')
    print('after f?')
a()
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
43
What will be the output of the following Python code?
x=10
y=8
assert x>y, 'X too small'
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
44
What will be the output of the following Python code?
#generator
def f(x):
    yield x+1
g=f(8)
print(next(g))
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
45
What will be the output of the following Python code if the input entered is 6?
valid = False
while not valid:
    try:
        n=int(input("Enter a number"))
        while n%2==0:
            print("Bye")
        valid = True
    except ValueError:
        print("Invalid")
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
46
What is the purpose of the sys.exc_info() function in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
47
What will be the output of the following Python code?
def foo():
    try:
        return 1
    finally:
        return 2
k = foo()
print(k)
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
What will happen if an exception is raised in a try block and is not handled in any of the except blocks?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
49
How can you create a custom exception class in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
50
Which of the following statements is true?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board