-
Notifications
You must be signed in to change notification settings - Fork 0
/
Python_Operators_12.py
73 lines (62 loc) · 1 KB
/
Python_Operators_12.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Operators In Python
# Arithmetic Op
# Assignment Op
# Comparison Op
# Logical Op
# Identity Op
# Membership Op
# Bitwise Op
# Arithmetic Operator
print(5 + 6)
print(5 - 6)
print(5 * 6)
print(5 ** 6) # --> ** Is Power Operator
print(5 / 6)
print(45 // 6) # --> // is Floor Divison Operator
print(5 % 6)
# Assignment Operators
x = 5
print(x)
x += 7
print(x)
x -= 5
print(x)
x /= 2
print(x)
x %= 7
print(x)
# Comparison Operators
i = 12
print(i == 9)
print(i != 9)
print(i > 9)
print(i >= 9)
print(i < 9)
print(i <= 9)
# Logical Operators
a = True
b = False
print(a and a)
print(a and b)
print(a or a)
print(a or b)
# Identity Operator
a = True
b = False
print(a is not a)
print(a is not b)
print(a is a)
print(a is b)
# Membership Operators
list = [1,2,3,6,4,8,9,10,54,23]
print(32 in list)
print(23 in list)
# Bitwise Operators
print( 0 & 1)
print( 1 & 1)
print( 1 & 0)
print( 0 & 0)
print( 0 | 0)
print( 0 | 1)
print( 1 | 1)
print( 1 | 0)