- 1

Write an algorithm to find the given number is odd or even

answer

17th Oct 2018, 12:23 AM
SRP Narwal
SRP Narwal - avatar
3 Answers
+ 6
def is_even(num): if (num % 2) == 0: return True return False
17th Oct 2018, 12:41 AM
Dlite
Dlite - avatar
+ 6
print(["even", "odd"][int(input()) % 2]) https://code.sololearn.com/cXggOMfL00hB/?ref=app
17th Oct 2018, 1:30 AM
David Ashton
David Ashton - avatar
+ 2
print('It is even' if int(input()) % 2 == 0 else "It is odd") https://code.sololearn.com/cA2320m4lG03/?ref=app
17th Oct 2018, 2:33 AM
Sebriel
Sebriel - avatar