-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoperators.py
More file actions
60 lines (44 loc) · 839 Bytes
/
operators.py
File metadata and controls
60 lines (44 loc) · 839 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#Operator : + - * / // **
a,b=30,5
print(a*b)
print(a/b)
print(a//b)
print(a-b)
print(a+b)
print(a**5)
print(a%b)
print('\nBoolean Operator:')
#Boolean
c,d = True, False
print(c or d)
print(c & d)
print(c and d)
print(not c)
print('\ncomparison operator :\n')
#Comparison : ==, >, <, !=
e,f = 8, 9
print(c == d)
print(c != d)
print(e > f)
print(e< f)
print(e >=f)
print('\n Bitwise Operator:')
#Bitwise Operator : ex with Higher Precedence
#Bitwise Unary -(num + 1)
print(~a)
#Bitwise Left Shift : a left shifted by b bits
print(a << b)
#Bitwise Right Shift : a right shifted by b bits
print(a >> b)
#Bitwise AND
print(a & b)
#bitwise XOR (exclusive OR)
print(a ^ b) # 27
#Bitwise OR
print(a | b)
#Membership Operator : in , not in
str9 ='sdfghjk;a'
if ';' in str9 :
print(True)
if 'o' not in str9 :
print(False)