31. How can you catch and handle multiple exceptions in a single except block in Python?
32. What is the output of the following code:
try:
x = 10 / 0
except ZeroDivisionError:
print("Error!")
finally:
print("Finally!")
try:
x = 10 / 0
except ZeroDivisionError:
print("Error!")
finally:
print("Finally!")
33. What will be the output of the following Python code?
def foo():
try:
print(1)
finally:
print(2)
foo()
def foo():
try:
print(1)
finally:
print(2)
foo()
34. What will be the output of the following Python code?
int('65.43')
int('65.43')
35. How can you catch and handle multiple exceptions in a single except block in Python?
36. What is the syntax to raise an exception manually in Python?
37. An exception is . . . . . . . .
38. What will be the output of the following Python code?
def f(x):
yield x+1
print("test")
yield x+2
g=f(10)
print(next(g))
print(next(g))
def f(x):
yield x+1
print("test")
yield x+2
g=f(10)
print(next(g))
print(next(g))
39. Which of the following statements is true regarding the order of except clauses?
40. Compare the following two Python codes shown below and state the output if the input entered in each case is -6?
CODE 1
import math
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))
CODE 2
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))
CODE 1
import math
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))
CODE 2
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))