-
Notifications
You must be signed in to change notification settings - Fork 0
/
parity.py
45 lines (38 loc) · 836 Bytes
/
parity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# x = int(input("What's is x? "))
# if x % 2 == 0:
# print("Even")
# else:
# print("Odd")
# create my own function to determine even and odd numbers
# def main():
# x = int(input("What's is x? "))
# if is_even(x):
# print("Even")
# else:
# print("Odd")
# def is_even(n):
# if n % 2 == 0:
# return True
# else:
# return False
# main()
#pythonic way of rewriting the above code
# def main():
# x = int(input("What's is x? "))
# if is_even(x):
# print("Even")
# else:
# print("Odd")
# def is_even(n):
# return True if n % 2 == 0 else False
# main()
#simplify it even better
def main():
x = int(input("What's is x? "))
if is_even(x):
print("Even")
else:
print("Odd")
def is_even(n):
return n % 2 == 0
main()