Advertisements
Advertisements
प्रश्न
You have learnt how to use math module in Class XI. Write a code where you use the wrong number of arguments for a method (say sqrt() or pow()). Use the exception handling process to catch the ValueError exception.
टीपा लिहा
Advertisements
उत्तर
Code to show the wrong number of arguments with exception handling.
import math
try:
print(math.sqrt(25,6))
except TypeError:
print("Wrong number of arguments used in sqrt() ")
finally:
print("Okay, Correct it")
Output:
Wrong number of arguments used in sqrt()
Okay, Correct itshaalaa.com
Handling Exceptions in Python
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
