Skip to content

212223lesson #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions 1718lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Logical Operators
# p = True
# print('not p value is : ', not p)

# Lesson18
# Bitwise Operators
# Bitwise operators are used to compare (binary) numbers:

# Bitwise AND
a = 60
b = 13
c = 0
c = a & b
# print('bitwise and operation', c)

# 60 /2 & 13/2 , 2|60 - 0 2|13 -1
# 2|30 - 0 2|6 - 0
# 2|15 - 1 2|3 -1
# 2|7 - 1 2|1
# 2|3 - 1
# 2|1
# 1 1 1 1 0 0 # 1 1 0 1
# 0 0 1 1 0 1
# Ans Bitwise & 0 0 0 0 1 1 0 0 = 12


# Bitwise OR
e = 60
f = 13
g = 0
g = e | f
# print('bitwise or operation', g)

# 111100
# 001101
# Ans Bitwise | 00111101 = 61


# Bitwise Nor
a = ~ 10
# print('Bitwise Nor', a)
# format => - (num + 1 )

# decimal to binary 2|10 - 0
# 2|5 - 1
# 2|2 -0
# 2|1
# 1010 (need to add 1)
# -(1011)

# Two's complement
# 10 => 1010
# inverse => 0101
# plus one => 0110
# and then change plus to minus , minus to plus






34 changes: 34 additions & 0 deletions 1920lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Xor RightShift Leftshifi
a = 5
b = 2
c = a^b
# print('Xor value is ', c)
# 5 => 101
# 2 => 10
# 101
# 10
# 00000111

# Right shift >> more younger
x = 10
y = x>>2
# print('right shift ', y)

# x => 00001010
# remove (right2place) and add two zero infront of
# x => 00000010 (Answer)

# Left shift << more older
p = 15
t = p << 3

# print('Left shift value is ', t)

# p => 00001111
# remove lefplace 01111 + 000
# p => 01111000





85 changes: 85 additions & 0 deletions 212223lesson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Special Operators . .
# 1.Identity Operator
# - is , is not (memory location)
# 2.Membership Operator

# a = 10
# b = 20
# c = a is b
# print('memory location using is word : ', c)

p = 10
t = 10
# if p is t:
# print('They are same location')
# else:
# print('The are not the same location')
# p = 20
# if p is t:
# print('second time, They are same location')
# else:
# print(' second time, They are not the same location')

# if p is not t:
# print('they are not the same location')
# else:
# print('they are same location')

###### checking type by using is keyword

w = type(p) is int
# print('type() by is ', w)

r = type(p) is not int
# print('type() check by is not', r)

y = type(p) is float
# print('type() check by is for float',y)


# String check

u = 'Pyae Phyo Thant'
o = 'Pyae Phyo Thant'
# print(id(u),id(o))
e = u is o
# print('e',e)

# if u is o:
# print('they are same location')
# else:
# print('they are not the same location')

# Membership
# - in , not in

mylist = ["apple", "banana", "cherry"]
checkItem = "banana" in mylist
# print('check item has or not', checkItem)
checkItem2 = "banana" not in mylist
# print('check item not has', checkItem2)
# def pver():
# return 0
# print('return 0', pver())

pptList1 = [1,2,3,4,5]
pptList2 = [6,7,8,9]

def overLap(pptList1,pptList2):
p = 0
t = 0
for i in pptList1:
p+=1
for i in pptList2:
t+=1
for i in range(0,p):
for j in range(0,t):
if pptList1[i] == pptList2[j]:
return 1
return 0

# Notes => if the return value is 0 => falsy!!!!
if overLap(pptList1,pptList2):
print(overLap(pptList1,pptList2))
else:
print('____________________')