Functions
def hello():
print("Hello functions")
hello()
Functions with Parameters
def add(i, j):
return i + j
print(add(12, 23))
Exception Handling
try:
i = int(input("Enter value 1 : "))
j = int(input("Enter value 2 : "))
res = i / j
print(res)
except ValueError:
print("Invalid Input")
except ZeroDivisionError:
print("Cannot divide by zero")
def divide():
try:
i = int(input("Enter value 1 : "))
j = int(input("Enter value 2 : "))
res = i / j
print(res)
except ValueError:
print("Invalid Input")
except ZeroDivisionError:
print("Cannot divide by zero")
divide()
No comments:
Post a Comment