Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 84f2cc7

Browse files
Create operators.py
1 parent 4073a63 commit 84f2cc7

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

‎Python Basics/operators.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Examples of Arithmetic Operator
2+
a = 9
3+
b = 4
4+
5+
# Addition of numbers
6+
add = a + b
7+
8+
# Subtraction of numbers
9+
sub = a - b
10+
11+
# Multiplication of number
12+
mul = a * b
13+
14+
# Division(float) of number
15+
div1 = a / b
16+
17+
# Division(floor) of number
18+
div2 = a // b
19+
20+
# Modulo of both number
21+
mod = a % b
22+
23+
# Power
24+
p = a ** b
25+
26+
# print results
27+
print(add)
28+
print(sub)
29+
print(mul)
30+
print(div1)
31+
print(div2)
32+
print(mod)
33+
print(p)
34+
35+
# Examples of Relational Operators
36+
a0 = 13
37+
b0 = 33
38+
39+
# a > b is False
40+
print(a0 > b0)
41+
42+
# a < b is True
43+
print(a0 < b0)
44+
45+
# a0 == b0 is False
46+
print(a0 == b0)
47+
48+
# a0 != b0 is True
49+
print(a0 != b0)
50+
51+
# a >= b is False
52+
print(a0 >= b0)
53+
54+
# a <= b is True
55+
print(a0 <= b0)
56+
57+
58+
# Examples of Logical Operator
59+
a1 = True
60+
b1 = False
61+
62+
# Print a and b is False
63+
print(a1 and b1)
64+
65+
# Print a or b is True
66+
print(a1 or b1)
67+
68+
# Print not a is False
69+
print(not a1)
70+
71+
# Examples of Bitwise operators
72+
a2 = 10
73+
b2 = 4
74+
75+
# Print bitwise AND operation
76+
print(a2 & b2)
77+
78+
# Print bitwise OR operation
79+
print(a2 | b2)
80+
81+
# Print bitwise NOT operation
82+
print(~a2)
83+
84+
# print bitwise XOR operation
85+
print(a2 ^ b2)
86+
87+
# print bitwise right shift operation
88+
print(a2 >> 2)
89+
90+
# print bitwise left shift operation
91+
print(a2 << 2)
92+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /