- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path6-operators.py
More file actions
Latest commit
104 lines (68 loc) · 1.45 KB
/
Copy path6-operators.py
File metadata and controls
104 lines (68 loc) · 1.45 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Arithematic operators
x=2
y=7
total=x+y
print(total)
total=x-y
print(total)
total=x*y
print(total)
total=y/x
print(total)
total=y%x# modulus operator will give you the reminder value
print(total)
total=y**x# it means y power x y^x
print(total)
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Comparison Operator
a=30
b=60
out=a<b
print (out)
out=a>b
print (out)
out=a==b
print (out)
out=a!=b
print (out)
out=a<=b
print (out)
out=a>=b
print (out)
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Assignment Operators
c=0
d=1
c+=d# c = c+d
print(c)
c-=d# c = c-d
print(c)
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Logical Operators
# AND
# OR
a=40
b=60
x=2
y=3
out= (a<b) or (x>y) # If any of them is false value will be false
print(out)
out= (a<b) and (x>y) # If any of them is true value will be true
print(out)
out=not(x>y) # If it is false it will return true. true will false
print(out)
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Membership Operator
tuple1= ("IOT", "Devops", 47, 12, 1.5)
ans="Devops"intuple1# help you to find something from the list
print(ans)
ans="Devops"notintuple1
print(ans)
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Identity Operators
a=12
b=12
result=aisb
print(result)
result=aisnotb
print(result)