ProgrammingModerateInfosys · Accenture · Capgemini pattern
What is printed?
What is printed?
try:
print(1 / 0, end=" ")
except ZeroDivisionError:
print("Z", end=" ")
finally:
print("F")- A. F
- B. F Z
- C. Z
- D. Z F
Correct answer: D. Z F
Dividing by zero raises ZeroDivisionError before anything is printed, so the except block prints Z. The finally block always runs last and prints F.
More Python Programming questions
- What is printed? python print(list(range(10, 0, -3)))
- What is printed? python print(max("apple", "Banana", "cherry"))
- What is printed? python print(round(2.5), round(3.5), round(-0.5))
- What is printed? python class A: count = 0 a1, a2 = A(), A() a1.count += 1 print(A.count, a1.count, a2.count)
- What is printed? python a = [[0] 3] 3 a[0][0] = 1 print(a)
- What is printed? python def f(x, lst=[]): lst.append(x) return lst f(1) f(2) print(f(3))