Tuesday, April 7, 2020

Python -2 - මෙහෙයවන තව දුරටත්



Python -2 කොටස - මෙහෙයවන තව දුරටත්

සැසඳුම් මෙහෙයවන(comparison operators  )

අගයයන් 2 ක් සන්සන්දනය කිරීම සඳහා මෙහි දැක්වෙන සැසඳුම් මෙහෙයවන භාවිතා කෙරේ. 

නම
උදා
 Equal
x == y
Not equal
x != y
Greater than
x > y
Less than
x < y
Greater than or equal to
x >= y
Less than or equal to
x <= y

පහත සැසැඳුම්  පරීක්ෂා කර පිළිතුරු ලබා ගන්න.
උදා  >>>34>23 ලෙස ඇතුලත් කර තහවුරු (Enter) කරන්න.

34 >23

34>=34

a=34
b=54
b>a

23=23

23==23

23!=23

b!=a

b %2 ==0




 තාර්කික මෙහෙයවන- Logical Operators

මෙහෙයවනය
උදාහරණය
ප්‍රතිඵලය
and 
8 < 5 and  1< 10

or
4 < 5 or 8 < 4


X=10 ,  y=45

not
not(x < 15 and  y < 10)


Python Membership Operators

 x = ["apple", "banana"]
 “banana" in x     ………………………………
“banana" not in x   ……………………………………………

>>>  “k” in “sarath bogahapitiya”

>>>  “a” in “sarath bogahapitiya”


Python Bitwise Operators -බිටු අනුසාරිත මෙහෙයවන


x=10  සහ y = 4  වේ නම් පහත වගුවේ සඳහන් බිටු අනුසාරිත මෙහෙයවන වල පිළිතුරු  ලබාගන්න


10   -->     1 0 1 0
4-->          0 1 0 0
AND--->  0 0 0 0
ඉහත සංඛ්‍යා 2 හි අනුරෑප බිටු එකිනෙක සලකමින් ඒවායේ තාර්කික AND කර්මය ක්‍රියාත්මක කළ විට පිළිතුර ලෙස 0 ලැබේ.

මෙහෙයවනය
තේරුම
උදා

&
Bitwise AND
x& y

|
Bitwise OR
x | y

~
Bitwise NOT
~x

^
Bitwise XOR
x ^ y

>> 
Bitwise right shift
x>> 2

<< 
Bitwise left shift
x<< 2















No comments:

Post a Comment

Blog Archive

Memory Locatıons and Addresses (Week 3) - ppt download

Memory Locatıons and Addresses (Week 3) - ppt download : Memory Locations and addresses We will first consider how the memory of a computer...

Total Pageviews

Followers