Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet452/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   448   449   450   451   452   453   454   455   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

greater or equal in value than the second,

giving True if it is and False otherwise.

x = 2**10

x >= 1024

Evaluates to True.

<=

Tests whether the value of the first operand is



smaller or equal in value than the second,

giving True if it is and False otherwise.

x = 2**10

x <= 512


Evaluates to False.

is

Tests whether two operands represent the same



Python object, giving True if they do and False

otherwise.

x = True

if x is True:

print("Success")

is not


Tests whether two operands represent different

Python objects, giving True if they are different

and False if they are the same.

value =


myDict.get(key)

if value is not

None:

print('Found



key')

Binary operators

The following are standard bitwise binary operations that are built into Python.



Operator

Description

Example

x & y


The bitwise binary AND operation, giving 1 if

both bits at a position are 1, and 0 otherwise.

x = 0b11111000

y = 0b10011111

print(bin(x & y))

Result is

0b10011000.

x | y


The bitwise binary OR operation, giving 1 if

any of the bits at a position are 1, and 0

otherwise.

x = 0b11010000

y = 0b00001101

print(bin(x | y))

Result is

0b11011101.

x ^ y

The bitwise binary XOR operation, giving 1



only if one of the bits, but not both, at a

position is 1, and 0 otherwise.

x = 0b11111000

y = 0b00011111

print(bin(x ^ y))

Result is




0b11100111.

x << n


The left-shift bit operation. Moves the bits of

x by n places to the left. The same as

multiplying x by 2**n.

x = 0b00010101 #

21 in decimal

print(bin(x << 2))

Result is

0b1010100; 84 in

decimal.

x >> n


The right-shift bit operation. Moves the bits of

x by n places to the right. The same as the

integer part of dividing x by 2**n.

x = 0b01010101 #

85 in decimal

print(bin(x >> 1))

Result is 0b101010;

42 in decimal.

~x

The bitwise binary NOT operation; forms the



complementary binary number by flipping 1

for 0 and 0 for 1. Note this flips all bits in the

full binary representation whether they are

directly represented or not (i.e. have implicit

leading zeros).

from numpy import

int8

x =


int8(0b11000011)

print(bin(~x))

Result is 0b111100.

Note use of 8-bit

integers from

NumPy to avoid

implicit zeros in

normal Python

integers.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   448   449   450   451   452   453   454   455   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish