NEW
Font size
WorksheetsPE2 Module 3
Total questions: 11
Worksheet time: 4mins
Go through the below code and predict the output:
num1=100
num2=0
try:
result=num1/num2
print(result)
except ZeroDivisionError:
print("Zero Division Error Occurred")
100
0
Zero Division Error Occurred
What will be the output of the code given below?
def division(a,b):
try:
return int(a)/b
except TypeError:
print("Type error")
except ValueError:
print("Value error")
finally:
print("Finally")
print("Done")
division('A',10)
Value error
Finally
Done
Type error
Finally
Done
Type error
Finally
Value error
Finally
What is the output of the following python code?
balance=1000
amount="300Rs"
def take_card():
print("Take the card out of ATM")
try:
if balance>=int(amount):
print("Withdraw")
else:
print("Invalid amount")
except TypeError:
print("Type Error Occurred")
except ValueError:
print("Value Error Occurred")
except:
print("Some error Occurred")
finally:
take_card()
Value Error Occurred
Take the card out of ATM
Type Error Occurred
Take the card out of ATM
Some Error occured
Invalid amount
