-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.py
More file actions
77 lines (69 loc) · 1.15 KB
/
operators.py
File metadata and controls
77 lines (69 loc) · 1.15 KB
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
74
75
76
77
#This is a program to show how different operators work
a=4
b=2
#examples of arithmetic operators
#addition of numbers
add=a+b
#subtraction of numbers
sub=a-b
#multiplication of numbers
mul=a*b
#division (float) of numbers
div=a/b
#division (floor)of numbers
div2=a//b
#modulo of numbers
mod=a%b
#print results
print(add)
print(sub)
print(mul)
print(div)
print(div2)
print(mod)
#examples of relaional operators
#a > b is True
print(a>b)
#a < b is False
print(a<b)
# a != b is true
print(a!=b)
#a == b is false
print(a==b)
#a >= b is True
print(a>=b)
#a <= b is false
print(a<=b)
#Examples of Logical operators
x=True
z=False
#print x or z is true
print(x or z)
#print X AND z is False
print(x and z)
#print not is True
print(not z)
#Bitwise operators
a=6
b=6
#Prints Bitwise AND operation
print(a & b)
#prints Bitwise Or operation
print(a | b)
#prints Bitwise Not operation
print( ~b)
#prints Bitwise XOR operation
print(a ^ b)
#Prints Right shift operation
print(a >> 2)
#prints left shift operation
print(a << 2)
#membership operators
z='pelu jeremiah'
q='loves coding'
#prints True
print('p' in z)
#prints true
print('loves' not in z)
#prints false
print('c'in z)