Skip to content

Commit 0d7bcb0

Browse files
Merge pull request #10 from coderpyaephyothant/212223lesson
212223lesson
2 parents 8d7e5ba + e13bd2d commit 0d7bcb0

File tree

3 files changed

+180
-0
lines changed

3 files changed

+180
-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+

1920lesson.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Xor RightShift Leftshifi
2+
a = 5
3+
b = 2
4+
c = a^b
5+
# print('Xor value is ', c)
6+
# 5 => 101
7+
# 2 => 10
8+
# 101
9+
# 10
10+
# 00000111
11+
12+
# Right shift >> more younger
13+
x = 10
14+
y = x>>2
15+
# print('right shift ', y)
16+
17+
# x => 00001010
18+
# remove (right2place) and add two zero infront of
19+
# x => 00000010 (Answer)
20+
21+
# Left shift << more older
22+
p = 15
23+
t = p << 3
24+
25+
# print('Left shift value is ', t)
26+
27+
# p => 00001111
28+
# remove lefplace 01111 + 000
29+
# p => 01111000
30+
31+
32+
33+
34+

212223lesson.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Special Operators . .
2+
# 1.Identity Operator
3+
# - is , is not (memory location)
4+
# 2.Membership Operator
5+
6+
# a = 10
7+
# b = 20
8+
# c = a is b
9+
# print('memory location using is word : ', c)
10+
11+
p = 10
12+
t = 10
13+
# if p is t:
14+
# print('They are same location')
15+
# else:
16+
# print('The are not the same location')
17+
# p = 20
18+
# if p is t:
19+
# print('second time, They are same location')
20+
# else:
21+
# print(' second time, They are not the same location')
22+
23+
# if p is not t:
24+
# print('they are not the same location')
25+
# else:
26+
# print('they are same location')
27+
28+
###### checking type by using is keyword
29+
30+
w = type(p) is int
31+
# print('type() by is ', w)
32+
33+
r = type(p) is not int
34+
# print('type() check by is not', r)
35+
36+
y = type(p) is float
37+
# print('type() check by is for float',y)
38+
39+
40+
# String check
41+
42+
u = 'Pyae Phyo Thant'
43+
o = 'Pyae Phyo Thant'
44+
# print(id(u),id(o))
45+
e = u is o
46+
# print('e',e)
47+
48+
# if u is o:
49+
# print('they are same location')
50+
# else:
51+
# print('they are not the same location')
52+
53+
# Membership
54+
# - in , not in
55+
56+
mylist = ["apple", "banana", "cherry"]
57+
checkItem = "banana" in mylist
58+
# print('check item has or not', checkItem)
59+
checkItem2 = "banana" not in mylist
60+
# print('check item not has', checkItem2)
61+
# def pver():
62+
# return 0
63+
# print('return 0', pver())
64+
65+
pptList1 = [1,2,3,4,5]
66+
pptList2 = [6,7,8,9]
67+
68+
def overLap(pptList1,pptList2):
69+
p = 0
70+
t = 0
71+
for i in pptList1:
72+
p+=1
73+
for i in pptList2:
74+
t+=1
75+
for i in range(0,p):
76+
for j in range(0,t):
77+
if pptList1[i] == pptList2[j]:
78+
return 1
79+
return 0
80+
81+
# Notes => if the return value is 0 => falsy!!!!
82+
if overLap(pptList1,pptList2):
83+
print(overLap(pptList1,pptList2))
84+
else:
85+
print('____________________')

0 commit comments

Comments
 (0)