1)
def painter():
print("painting")
painter()
//
painting
2) Create a function called add(),sub(), and get the input for a and b inside every function then print the result.
def add():
a=int(input("enter a"))
b=int(input("enter b"))
print(a+b)
print("ok")
add()
//
enter a 10
enter b 20
30
ok
def sub():
print("subtraction")
a=int(input("enter a"))
b=int(input("enter b"))
print(a-b)
sub()
//
subtraction
enter a 30
enter b 20
10
3) Get a integer number from user and pass it to the function called findevenorodd().Let the function print whether the number is even or odd.
def findevenorodd(a):
if (a%2==0):
print("even")
else:
print("odd")
findevenorodd(10)
even
Top comments (0)