+ 1

defining functions in python

In python I have to define a function f(x). -If n is an integer, then is it even? If not even then say that it is not even. N needs to be an integer to prove that it is even or not (I hope that makes sense)

29th Jan 2018, 11:36 PM
Nick DiPaolo
Nick DiPaolo - avatar
1 Answer
+ 3
def f(x): if int(x)%2==0 : print("Even") else: print("Odd")
29th Jan 2018, 11:54 PM
code learner
code learner - avatar