• Qo`simcha metodlar int.bit_length()
  • 1. Python tili imkoniyatlari Pythonni ko`chirish




    Download 2.19 Mb.
    bet15/79
    Sana25.03.2024
    Hajmi2.19 Mb.
    #176376
    1   ...   11   12   13   14   15   16   17   18   ...   79
    Bog'liq
    1. Python tili imkoniyatlari Pythonni ko`chirish
    axborot-texnologiyalarini-rivojlanish-tarixi, 1-mavzu. Axborot texnologiyalarini kasbiy faoliyatda qo’llanilis-fayllar.org, DAVLATNING TA\'LIM PISIXOLOGIYA FANIDAN 1-MUSTAQIL ISHI, sen. bayroq www.sadikov.uz , Psixikaning filogenetik taraqqiyoti 1 psixikaning taraqqiyot bos, Shaxsning riojlanishi slayd, Binary heap tarzidagi ma, 9-amaliy, Документ Microsoft Word (3), 5-MUSTAQIL ISH OR, Robotlar haqida umumiy tushunchalar va ta’riflar. “Robot” so‘zi -fayllar.org (1), DIAGNOSTIKA 60 nazariy, DIAGNOSTIKA 60 nazariy (1), 6-mavzu Psixolog faoliyatini nazorat qiluvchi axloqiy me’yorlar-azkurs.org, Agrar munosabatlar va ularning o’ziga xos xususiyatlari reja
    Bitli operatsiyalar
    Bundan tashqari butun sonlar ustida bitli amallarni ham bajarish mumkin.

    x | y

    Bitli yoki

    x ^ y

    Bitli boshqasini inkor etuvchi yoki

    x & y

    Bitli va

    x << y

    Bitli chapga siljish

    x >> y

    Bitli o`ngga siljish

    ~ x

    Bitlar inversiyasi



    Qo`simcha metodlar
    int.bit_length() – ishora va boshidagi nollarni hisobga olmagan holda sonni ikkilik sanoq tizimida tasvirlash uchun kerakli bitlar soni.

    >>> n = -37
    >>> bin(n)
    '-0b100101'
    >>> n.bit_length()
    6


    int.to_bytes(length, byteorder, *, signed=False) – shu sonni tasvirlaydigan baytlar satrini qaytaradi.

    >>> (1024).to_bytes(2, byteorder='big')
    b'\x04\x00'
    >>> (1024).to_bytes(10, byteorder='big')
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00'
    >>> (-1024).to_bytes(10, byteorder='big', signed=True)
    b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
    >>> x = 1000
    >>> x.to_bytes((x.bit_length() // 8) + 1, byteorder='little')
    b'\xe8\x03'


    int.from_bytes(bytes, byteorder, *, signed=False) classmetodi – shu baytlar satridagi sonni qaytaradi.

    >>> int.from_bytes(b'\x00\x10', byteorder='big')
    16
    >>> int.from_bytes(b'\x00\x10', byteorder='little')
    4096
    >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True)
    -1024
    >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=False)
    64512
    >>> int.from_bytes([255, 0, 0], byteorder='big')
    16711680



    Download 2.19 Mb.
    1   ...   11   12   13   14   15   16   17   18   ...   79




    Download 2.19 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    1. Python tili imkoniyatlari Pythonni ko`chirish

    Download 2.19 Mb.