-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path#9-operators.py
55 lines (44 loc) · 907 Bytes
/
#9-operators.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
x = 31
y = 3
# Addition Operators
z = x + y
# Subtraction Operators
z = x - y
# Multiplication Operators
z = x * y
# Division Operators
z = x / y
# Modulus Operators
z = x % y
# Exponent / Power Operators
z = x ** y
# Floor division Operators , round the float number
z = x // y
# comparisons operators
z = x == y
z = x != y
z = x > y
z = x < y
z = x >= y
z = x <= y
# logical operators
z = x < 5 or x == 31 # logical OR
z = x < 5 and x == 31 # logical AND
z = not(x < 5 and x == 31) # logical NOT
# assignment Operators
x = 32
x += 3
x -= 3
x *= 3
x //= 3
x **= 3
x &= 3
x %= 3
# identity operators
b = ["apple", "banana"]
a = ["apple", "banana"]
c = b
d = a is not c # return true if it not the s
d = a is b # return false because it not the same object also content is same
d = "banana" in c # returns true if it has the item
d = "cherry" not in c # returns true if it has not the item