#I have done using exception handling. But I want to raise Arithmetic exception #without using try catch block class Maths: def operation(self,a): try: div = a / 0 except ArithmeticError: print("This will raise an Error. Because Numbers cannot be divisible by 0.") else: print(div) division = Maths() division.operation(15)
Discy Latest Questions
I want to apply access modifiers to constructor in python. class Flats: def __init__(self): print("We have varities of flats like 1BHK, 2HK, 3BHK, 4BHK, 5BHK.") @classmethod def building_no(self,number): print(f"The number of building is {number} ") @classmethod def building_details(self,name,area): print(f"The name of building is {name} ,located in {area}. ")
Welcome to the community.