Write a function that recieves integer and returns 1 if received integer is an even number elss returns -1
Answers
Answered by
2
Answer:
def is_ok (x): # checks if x is a positive integer is_int = False is_pos = False try: if type (eval (x)) == int: is_int = True if x > 0: is_pos = True else: pa ss else: pa ss except NameError: is_int = False print "not even a number!" return is_int, is_pos. if I try to pa ss a positive int it would return True, True as expected.
Explanation:
Similar questions