forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfElseDemo.py
More file actions
44 lines (35 loc) · 781 Bytes
/
IfElseDemo.py
File metadata and controls
44 lines (35 loc) · 781 Bytes
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
# it follows indentation same indentation in if considered as in if block
from builtins import print
'''if True:
print("right")
print("wrong")'''
# above statement print both and this print only outer statement
'''if False:
print("right")
print("wrong")'''
a = int (input('Enter a number : '))
# using %
'''if a % 2 == 0:
print('Even')
else:
print('odd')
'''
# using bit wise
'''if a & 1 == 0:
print('Even')
else:
print('odd')'''
# using division operator
'''if (a // 2) * 2 == a:
print('Even')
else:
print('odd')'''
# using ternary operator
result ="Even" if a % 2 == 0 else "odd"
print(result)
# using only if
def find_even(a):
if(a % 2 == 0):
return "even"
return "odd"
print(find_even(int (input('Enter a number : '))))