-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.py
More file actions
executable file
·65 lines (54 loc) · 1.3 KB
/
operators.py
File metadata and controls
executable file
·65 lines (54 loc) · 1.3 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
# Operator in Python3
# -----------------------------------------------------------------------------------------#
# Airthmetic operator
# Assignment operator
# Relational operator
# Logical operator
# Unary operator
# 1. Airthmetic Operator
x= 1
y=2
print(x+y)
# 2. Assignment
x= 2 # it is Assigment
x= x+2 #Adding the value 2 in the x
print(x)
x += 2 # same but this is like increment of 2 in the value x
print(x)
# Also --
x *=2
x/=2
print(x)
# 3 Assigning the multiple value
a, b = 3,4
#------------------------------------------------------------------------
# 2. Unary Operator ----> one
#-------------------------------------------
n = 12
n =-n
print(n) #it will be minus value
#------------------------------------------------------------------------
# 2. Relational Operator
#---------------------------------------------------------------
print(a<b)
print(a==b)
a=4
print(a==b,a<=b,a>=b,a!=b)
#------------------------------------------------------------------------
# 2. Logical Operator
#------------------------------------------------------------------------
# 1. AND
a= 12
b= 13
print(a<15 and b<14)
print(a>15 and b<15)
print(a<15 and b>16)
# 2. OR
print(a<15 or b<14)
print(a>15 or b<15)
print(a>15 or b>16)
# 3. NOT
x = True
print(x)
X = not x
print(X)