Hướng dẫn binary to hexadecimal in python - nhị phân sang thập lục phân trong python
Với một số nhị phân, nhiệm vụ là viết một chương trình Python để chuyển đổi số nhị phân đã cho thành một số thập lục phân tương đương. tức là chuyển đổi số với giá trị cơ sở 2 thành giá trị cơ sở 16. trong biểu diễn thập lục phân, chúng tôi 16 giá trị để biểu diễn một số. Các số 0-9 được biểu thị bằng các chữ số 0-9 và 10-15 được biểu diễn bằng các ký tự từ A-F. Show
Example: Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F Phương pháp 1: Mã do người dùng xác định để chuyển đổi nhị phân thành thập lục phânBước 1: & NBSP; Số nhị phân đầu vào. Input binary number. Input: 111101111011 Bước 2: Chia số nhị phân của bạn thành các nhóm bốn người, bắt đầu từ bên phải. & NBSP; Divide your binary number into groups of four, starting from right. 111101111011 = (1111)(0111)(1011) Bước 3: Chuyển đổi một nhóm 4 chữ số của một số nhị phân thành một chữ số thập lục phân. & NBSP; Convert one 4-digit group of a binary number to one hexadecimal digit. (1111)(0111)(1011) = F7B Dưới đây là việc thực hiện Python của phương pháp trên: Python3Input: 1111011110111 Input: 1111011110112 Input: 1111011110113 Input: 1111011110114 Input: 1111011110115 Input: 1111011110116 Input: 1111011110117 Input: 1111011110113 Input: 1111011110119 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Input: 1111011110113 111101111011 = (1111)(0111)(1011)3 Input: 1111011110115 111101111011 = (1111)(0111)(1011)5 Input: 1111011110113 111101111011 = (1111)(0111)(1011)7 Input: 1111011110115 111101111011 = (1111)(0111)(1011)5 Input: 1111011110113 (1111)(0111)(1011) = F7B1 Input: 1111011110115 (1111)(0111)(1011) = F7B3 (1111)(0111)(1011) = F7B4 (1111)(0111)(1011) = F7B5 (1111)(0111)(1011) = F7B6 (1111)(0111)(1011) = F7B7 Input: 1111011110113 (1111)(0111)(1011) = F7B9 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Input: 1111011110113 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B4 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B9 Input: 1111011110115 Input: 1111011110114 Input: 111101111011 = (111101111011)22 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Input: 1111011110119 Input: 1111011110115 Input: 1111011110119 Input: 111101111011 = (111101111011)28 Input: 111101111011 = (111101111011)29 (1111)(0111)(1011) = F7B6 (111101111011)2 = (3963)101 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (111101111011)2 = (3963)103 111101111011 = (1111)(0111)(1011)7 Input: 111101111011 = (111101111011)22 (111101111011)2 = (3963)106 Input: 1111011110115 Input: 1111011110115 (3963)10 = (F7B)161 (111101111011)2 = (3963)103 (3963)10 = (F7B)163 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 (3963)10 = (F7B)166 (3963)10 = (F7B)1677____15 (3963)10 = (F7B)169 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B0 Input: 111101111011 = (111101111011)28 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B2 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 (3963)10 = (F7B)161 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 (3963)10 = (F7B)166 (3963)10 = (F7B)1677____15 (3963)10 = (F7B)169 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B0 Input: 111101111011 = (111101111011)28 0xf 0x35 0x10f 0xf7b3 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 (3963)10 = (F7B)161 111101111011 = (1111)(0111)(1011)3 Input: 1111011110115 111101111011 = (1111)(0111)(1011)5 (3963)10 = (F7B)161 Input: 1111011110119 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 (3963)10 = (F7B)161 111101111011 = (1111)(0111)(1011)7 Input: 1111011110115 111101111011 = (1111)(0111)(1011)5 (3963)10 = (F7B)161 (1111)(0111)(1011) = F7B9 Input: 1111011110115 Input: 11110111101110 Input: 111101111011 = (111101111011)28 111101111011 = (1111)(0111)(1011)5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 (3963)10 = (F7B)161 111101111011 = (1111)(0111)(1011)3 Input: 1111011110115 Input: 11110111101119 (1111)(0111)(1011) = F7B6 Input: 11110111101121 (3963)10 = (F7B)161 111101111011 = (1111)(0111)(1011)7 Input: 1111011110115 Input: 11110111101125 Input: 111101111011 = (111101111011)28 111101111011 = (1111)(0111)(1011)5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Input: 1111011110114 Input: 1111011110115 Input: 1111011110116 Input: 11110111101132 Input: 11110111101133 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 (111101111011)2 = (3963)103 Input: 11110111101138 Input: 1111011110115 111101111011 = (1111)(0111)(1011)5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (3963)10 = (F7B)1677____15 (3963)10 = (F7B)169 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B0 Input: 111101111011 = (111101111011)28 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B2 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 (111101111011)2 = (3963)103 111101111011 = (1111)(0111)(1011)7 Input: 1111011110115 Input: 1111011110115 111101111011 = (1111)(0111)(1011)5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (1111)(0111)(1011) = F7B9 Input: 1111011110115 Input: 11110111101110 Input: 11110111101161 111101111011 = (1111)(0111)(1011)5 Input: 1111011110113 Input: 11110111101164 Input: 11110111101165 Input: 11110111101166 Input: 11110111101167 Input: 11110111101168 Input: 11110111101169 Input: 1111011110115 Input: 11110111101171 Input: 1111011110113 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 11110111101174 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Input: 11110111101164 Input: 11110111101180 Input: 1111011110115 Input: 11110111101182 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (1111)(0111)(1011) = F7B9 Input: 1111011110115 Input: 11110111101110 Input: 11110111101161 111101111011 = (1111)(0111)(1011)5 Input: 1111011110113 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 11110111101174 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Input: 1111011110113 Input: 11110111101196 Input: 11110111101197 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 Input: 11110111101196 111101111011 = (1111)(0111)(1011)01 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 Input: 11110111101196 111101111011 = (1111)(0111)(1011)05 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 Input: 11110111101196 111101111011 = (1111)(0111)(1011)09 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Output: Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8Input: 11110111101164Input: 11110111101180Input: 1111011110115Input: 11110111101182
Input: 111101111011 = (111101111011)2 Phương pháp 2: Đầu tiên chuyển đổi nhị phân thành thập phân và sau đó thập phân sang thập lục phân Convert binary number to decimal number. (111101111011)2 = (3963)10 Bước 1: & NBSP; Số nhị phân đầu vào. Convert the above decimal number to a hexadecimal number. (3963)10 = (F7B)16 Bước 2: Chuyển đổi số nhị phân thành số thập phân. above approach: Python3Bước 3: Chuyển đổi số thập phân ở trên thành số thập lục phân. Dưới đây là việc thực hiện Python của phương pháp tiếp cận TheaBove: Input: 1111011110111 111101111011 = (1111)(0111)(1011)12 Input: 1111011110113 111101111011 = (1111)(0111)(1011)14 Input: 1111011110115 Input: 1111011110116 111101111011 = (1111)(0111)(1011)17 Input: 1111011110113 111101111011 = (1111)(0111)(1011)19 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 111101111011 = (1111)(0111)(1011)22221 111101111011 = (1111)(0111)(1011)222221 Input: 1111011110113 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 111101111011 = (1111)(0111)(1011)28 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 111101111011 = (1111)(0111)(1011)31 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 111101111011 = (1111)(0111)(1011)33 Input: 1111011110115 111101111011 = (1111)(0111)(1011)14 Input: 111101111011 = (111101111011)22 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 111101111011 = (1111)(0111)(1011)39 Input: 1111011110115 111101111011 = (1111)(0111)(1011)39 Input: 111101111011 = (111101111011)28 111101111011 = (1111)(0111)(1011)33__ Input: 1111011110113 111101111011 = (1111)(0111)(1011)62 111101111011 = (1111)(0111)(1011)63 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 111101111011 = (1111)(0111)(1011)14 Input: 1111011110115 111101111011 = (1111)(0111)(1011)52 Input: 11110111101133 Input: 11110111101133 Input: 111101111011 = (111101111011)23 Input: 1111011110113 (1111)(0111)(1011) = F7B1 Input: 1111011110115 (1111)(0111)(1011) = F7B3 (1111)(0111)(1011) = F7B4 (1111)(0111)(1011) = F7B5 (1111)(0111)(1011) = F7B6 (1111)(0111)(1011) = F7B7 Input: 1111011110113 (1111)(0111)(1011) = F7B9 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Input: 1111011110113 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B4 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B9 Input: 1111011110115 Input: 1111011110114 Input: 111101111011 = (111101111011)22 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Input: 1111011110119 Input: 1111011110115 Input: 1111011110119 Input: 111101111011 = (111101111011)28 Input: 111101111011 = (111101111011)29 (1111)(0111)(1011) = F7B6 (111101111011)2 = (3963)101 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (111101111011)2 = (3963)103 111101111011 = (1111)(0111)(1011)96 Input: 111101111011 = (111101111011)23 111101111011 = (1111)(0111)(1011)31 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (111101111011)2 = (3963)103 111101111011 = (1111)(0111)(1011)7 Input: 111101111011 = (111101111011)22 (111101111011)2 = (3963)106 Input: 1111011110115 Input: 1111011110115 (3963)10 = (F7B)161 (111101111011)2 = (3963)103 (3963)10 = (F7B)163 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B5 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 (3963)10 = (F7B)166 (3963)10 = (F7B)1677____15 (3963)10 = (F7B)169 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B0 Input: 111101111011 = (111101111011)28 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B2 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 (3963)10 = (F7B)161 (111101111011)2 = (3963)103 (3963)10 = (F7B)163 Input: 111101111011 = (111101111011)23 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 (3963)10 = (F7B)166 (3963)10 = (F7B)1677____15 (3963)10 = (F7B)169 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B0 Input: 111101111011 = (111101111011)28 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B2 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 (3963)10 = (F7B)166 (3963)10 = (F7B)1677____15 (3963)10 = (F7B)169 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B0 Input: 111101111011 = (111101111011)28 0xf 0x35 0x10f 0xf7b3 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 (1111)(0111)(1011) = F7B46 Input: 1111011110115 111101111011 = (1111)(0111)(1011)1 111101111011 = (1111)(0111)(1011)31 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 Input: 11110111101164 (1111)(0111)(1011) = F7B52 Input: 1111011110115 Input: 11110111101171 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B8 (1111)(0111)(1011) = F7B39 Input: 1111011110115 (1111)(0111)(1011) = F7B39 Input: 11110111101161 111101111011 = (1111)(0111)(1011)5 Input: 1111011110113 Input: 11110111101164 (1111)(0111)(1011) = F7B63 Input: 1111011110111 Input: 1111011110112 Input: 1111011110113 111101111011 = (1111)(0111)(1011)39 Input: 1111011110115 (1111)(0111)(1011) = F7B69 Input: 1111011110113 Input: 11110111101164 Input: 11110111101165 (1111)(0111)(1011) = F7B73 Input: 11110111101167 Input: 11110111101168 (1111)(0111)(1011) = F7B76 Input: 1111011110113 (1111)(0111)(1011) = F7B78 (111101111011)2 = (3963)103 Input: 11110111101190 Input: 1111011110115 Input: 1111011110115 Input: 11110111101193 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Input: 1111011110113 Input: 11110111101196 Input: 11110111101197 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 Input: 11110111101196 111101111011 = (1111)(0111)(1011)01 Input: 1111011110113 Input: 11110111101196 111101111011 = (1111)(0111)(1011)05 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Input: 1111011110113 Input: 11110111101196 111101111011 = (1111)(0111)(1011)09 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B3 Output: Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B Phương pháp 3: Sử dụng các chức năng được xác định trướcVí dụ 1: Sử dụng int () và hex ()Chúng tôi sử dụng int () và hex () để chuyển đổi số nhị phân thành số thập lục phân tương đương của nó. Dưới đây là triển khai Python sử dụng int () và hex (). Python3Input: 1111011110111 Input: 1111011110112 Input: 1111011110113 111101111011 = (1111)(0111)(1011)39 Input: 1111011110115 (1111)(0111)(1011) = F7B69 (111101111011)2 = (3963)103 Input: 11110111101190 Input: 1111011110115 Input: 1111011110115 Input: 11110111101193 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Input: 1111011110113 111101111011 = (1111)(0111)(1011)62 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B17 (111101111011)2 = (3963)103 Input: 11110111101190 Input: 1111011110115 Input: 1111011110115 Input: 11110111101193 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B7 Input: 1111011110113 Input: 11110111101164 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B26 Input: 11110111101197 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B28 Input: 1111011110113 Input: 11110111101164 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B26 111101111011 = (1111)(0111)(1011)01 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B28 Input: 1111011110113 Input: 11110111101164 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B26 111101111011 = (1111)(0111)(1011)05 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B28 Input: 1111011110113 Input: 11110111101164 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B26 111101111011 = (1111)(0111)(1011)09 Hexadecimal equivalent of 1111: F Hexadecimal equivalent of 110101: 35 Hexadecimal equivalent of 100001111: 10F Hexadecimal equivalent of 111101111011: F7B28 Output: 0xf 0x35 0x10f 0xf7b
|