Skip to content

Commit e7bb3a8

Browse files
1718lesson
1 parent e768b3e commit e7bb3a8

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

1718lesson.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Logical Operators
2+
# p = True
3+
# print('not p value is : ', not p)
4+
5+
# Lesson18
6+
# Bitwise Operators
7+
# Bitwise operators are used to compare (binary) numbers:
8+
9+
# Bitwise AND
10+
a = 60
11+
b = 13
12+
c = 0
13+
c = a & b
14+
# print('bitwise and operation', c)
15+
16+
# 60 /2 & 13/2 , 2|60 - 0 2|13 -1
17+
# 2|30 - 0 2|6 - 0
18+
# 2|15 - 1 2|3 -1
19+
# 2|7 - 1 2|1
20+
# 2|3 - 1
21+
# 2|1
22+
# 1 1 1 1 0 0 # 1 1 0 1
23+
# 0 0 1 1 0 1
24+
# Ans Bitwise & 0 0 0 0 1 1 0 0 = 12
25+
26+
27+
# Bitwise OR
28+
e = 60
29+
f = 13
30+
g = 0
31+
g = e | f
32+
# print('bitwise or operation', g)
33+
34+
# 111100
35+
# 001101
36+
# Ans Bitwise | 00111101 = 61
37+
38+
39+
# Bitwise Nor
40+
a = ~ 10
41+
# print('Bitwise Nor', a)
42+
# format => - (num + 1 )
43+
44+
# decimal to binary 2|10 - 0
45+
# 2|5 - 1
46+
# 2|2 -0
47+
# 2|1
48+
# 1010 (need to add 1)
49+
# -(1011)
50+
51+
# Two's complement
52+
# 10 => 1010
53+
# inverse => 0101
54+
# plus one => 0110
55+
# and then change plus to minus , minus to plus
56+
57+
58+
59+
60+
61+

0 commit comments

Comments
 (0)