Python -2 කොටස - මෙහෙයවන තව දුරටත්
සැසඳුම් මෙහෙයවන(comparison operators )
නම
|
උදා
|
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
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 වේ නම් පහත වගුවේ සඳහන් බිටු අනුසාරිත මෙහෙයවන වල පිළිතුරු ලබාගන්න
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