-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperators.py
More file actions
49 lines (37 loc) · 782 Bytes
/
Operators.py
File metadata and controls
49 lines (37 loc) · 782 Bytes
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
# Program to demonstrate arithmetic, relational, and logical operators
# Declare variables
j = 10
k = 20
# Demonstrate and display addition
print(j + k)
# Do the same for subtraction
print(k - j)
print(j - k)
# Likewise for multiplication
print(j * k)
# Ditto for division
print(j / k)
print(k / j)
# Demonstrate greater than operator
print(j < k)
print(k < k)
# Demonsrate less than operator
print(j > k)
print(j > k)
# Demonstrate equal to operator
print(j == k)
# Demonsrate not equal to operator
print(j != k)
# Redeclare variables as booleans
j = True
k = False
# Demonstrate AND operator
print(j & k)
print(k & j)
print(j & j)
print(k & k)
# Demonsrate OR operator
print(j | k)
print(k | j)
print(j | j)
print(k | k)