-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperators.py
More file actions
85 lines (63 loc) · 1.51 KB
/
Copy pathOperators.py
File metadata and controls
85 lines (63 loc) · 1.51 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
a = 34
b = 2
# Operators in Python :-
# Types of Operators
# Arithmetic Operators:
# + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus), ** (Exponentiation), // (Floor Division).
print("a + b = ", a + b)
print("a - b = ", a - b)
print("a * b = ", a * b)
print("a / b = ", a / b)
print("a % b = ", a % b)
print("a // b = ", a // b)
print("a ** b = ", a ** b)
# Comparison Operators:
# == (Equal), != (Not Equal), > (Greater Than), < (Less Than), >= (Greater Than or Equal), <= (Less Than or Equal).
print(a > 4)
print(a < 4)
print(a <= 4)
print(a >= 4)
print(a == 4) # Is a equal to 4?
print(a == 34) # Is a equal to 34?
print(a != 34) # Is a not equal to 34?
# Logical Operators: and, or, not.
c = True
d = False
print("\nFor AND Operator: .....")
print(True and False)
print(False and False)
print(True and True)
print(False and True)
print("\nFor OR Operator: ......")
print(True or False)
print(False or False)
print(True or True)
print(False or True)
print("\nFor NOT Operator: .....")
print(not(True))
print(not(False))
# Assignment Operator:
e = 24
f = 20
g = 28
print(e)
e += 4 # Equivalent to e = e + 4
print(e)
print(f)
f -= 4 # Equivalent to f = f - 4
print(f)
print(g)
g *= 4 # Equivalent to g = g x 4
print(g)
x = 10
print(x)
x %= 5 # Equivalent to x = x % 5
print(x)
y = 42
print(y)
y **= 5 # Equivalent to y = y ** 5
print(y)
z = 35
print(z)
z //= 4 # Equivalent to z = z // 4
print(z)