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.

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ân

Bướ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:

Python3

Input: 111101111011
1
Input: 111101111011
2

Input: 111101111011
3
Input: 111101111011
4
Input: 111101111011
5
Input: 111101111011
6
Input: 111101111011
7

Input: 111101111011
3
Input: 111101111011
9
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
3
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
5

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
5

Input: 111101111011
3
(1111)(0111)(1011) = F7B
1
Input: 111101111011
5
(1111)(0111)(1011) = F7B
3
(1111)(0111)(1011) = F7B
4
(1111)(0111)(1011) = F7B
5
(1111)(0111)(1011) = F7B
6
(1111)(0111)(1011) = F7B
7

Input: 111101111011
3
(1111)(0111)(1011) = F7B
9
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1

Input: 111101111011
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
4
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
5
Input: 111101111011
4
Input: 111101111011 = (111101111011)2
2
Input: 111101111011 = (111101111011)2
3

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Input: 111101111011
9
Input: 111101111011
5
Input: 111101111011
9
Input: 111101111011 = (111101111011)2
8
Input: 111101111011 = (111101111011)2
9
(1111)(0111)(1011) = F7B
6
(111101111011)2 = (3963)10
1

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(111101111011)2 = (3963)10
3
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011 = (111101111011)2
2
(111101111011)2 = (3963)10
6
Input: 111101111011
5
Input: 111101111011
5

(3963)10 = (F7B)16
1
(111101111011)2 = (3963)10
3
(3963)10 = (F7B)16
3
Input: 111101111011 = (111101111011)2
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

(3963)10 = (F7B)16
6
(3963)10 = (F7B)16
77____15
(3963)10 = (F7B)16
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
0
Input: 111101111011 = (111101111011)2
8
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
2
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

(3963)10 = (F7B)16
1
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
5
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

(3963)10 = (F7B)16
6
(3963)10 = (F7B)16
77____15
(3963)10 = (F7B)16
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
0
Input: 111101111011 = (111101111011)2
8
0xf
0x35
0x10f
0xf7b
3
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

(3963)10 = (F7B)16
1
111101111011 = (1111)(0111)(1011)
3
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
5

(3963)10 = (F7B)16
1
Input: 111101111011
9
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1

(3963)10 = (F7B)16
1
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
5

(3963)10 = (F7B)16
1
(1111)(0111)(1011) = F7B
9
Input: 111101111011
5
Input: 111101111011
10
Input: 111101111011 = (111101111011)2
8
111101111011 = (1111)(0111)(1011)
5

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
5
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

(3963)10 = (F7B)16
1
111101111011 = (1111)(0111)(1011)
3
Input: 111101111011
5
Input: 111101111011
19
(1111)(0111)(1011) = F7B
6
Input: 111101111011
21

(3963)10 = (F7B)16
1
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011
5
Input: 111101111011
25
Input: 111101111011 = (111101111011)2
8
111101111011 = (1111)(0111)(1011)
5

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Input: 111101111011
4
Input: 111101111011
5
Input: 111101111011
6
Input: 111101111011
32
Input: 111101111011
33
Input: 111101111011 = (111101111011)2
3
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
(111101111011)2 = (3963)10
3
Input: 111101111011
38
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
5
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(3963)10 = (F7B)16
77____15
(3963)10 = (F7B)16
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
0
Input: 111101111011 = (111101111011)2
8
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
2
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
(111101111011)2 = (3963)10
3
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011
5
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
5
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(1111)(0111)(1011) = F7B
9
Input: 111101111011
5
Input: 111101111011
10
Input: 111101111011
61
111101111011 = (1111)(0111)(1011)
5

Input: 111101111011
3
Input: 111101111011
64
Input: 111101111011
65
Input: 111101111011
66
Input: 111101111011
67
Input: 111101111011
68
Input: 111101111011
69
Input: 111101111011
5
Input: 111101111011
71

Input: 111101111011
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
Input: 111101111011
74
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Input: 111101111011
64
Input: 111101111011
80
Input: 111101111011
5
Input: 111101111011
82

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(1111)(0111)(1011) = F7B
9
Input: 111101111011
5
Input: 111101111011
10
Input: 111101111011
61
111101111011 = (1111)(0111)(1011)
5

Input: 111101111011
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
Input: 111101111011
74
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Input: 111101111011
3
Input: 111101111011
96
Input: 111101111011
97
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
01
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
05
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
09
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

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

(111101111011)2 = (3963)10
3
Input: 111101111011
90
Input: 111101111011
5
Input: 111101111011
5
Input: 111101111011
93
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7
Input binary number.

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:

Python3

Bướ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: 111101111011
1
111101111011 = (1111)(0111)(1011)
12

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
14
Input: 111101111011
5
Input: 111101111011
6
111101111011 = (1111)(0111)(1011)
17

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
19
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1
111101111011 = (1111)(0111)(1011)
22221
111101111011 = (1111)(0111)(1011)
222221

Input: 111101111011
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
111101111011 = (1111)(0111)(1011)
28
Input: 111101111011
5
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:  F7B
8
111101111011 = (1111)(0111)(1011)
33
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
14
Input: 111101111011 = (111101111011)2
2
Input: 111101111011 = (111101111011)2
3

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
111101111011 = (1111)(0111)(1011)
39
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
39
Input: 111101111011 = (111101111011)2
8
111101111011 = (1111)(0111)(1011)
33__

Input: 111101111011
3
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:  F7B
8
111101111011 = (1111)(0111)(1011)
14
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
52
Input: 111101111011
33
Input: 111101111011
33
Input: 111101111011 = (111101111011)2
3

Input: 111101111011
3
(1111)(0111)(1011) = F7B
1
Input: 111101111011
5
(1111)(0111)(1011) = F7B
3
(1111)(0111)(1011) = F7B
4
(1111)(0111)(1011) = F7B
5
(1111)(0111)(1011) = F7B
6
(1111)(0111)(1011) = F7B
7

Input: 111101111011
3
(1111)(0111)(1011) = F7B
9
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1

Input: 111101111011
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
4
Input: 111101111011
5
111101111011 = (1111)(0111)(1011)
1
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
5
Input: 111101111011
4
Input: 111101111011 = (111101111011)2
2
Input: 111101111011 = (111101111011)2
3

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Input: 111101111011
9
Input: 111101111011
5
Input: 111101111011
9
Input: 111101111011 = (111101111011)2
8
Input: 111101111011 = (111101111011)2
9
(1111)(0111)(1011) = F7B
6
(111101111011)2 = (3963)10
1

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(111101111011)2 = (3963)10
3
111101111011 = (1111)(0111)(1011)
96
Input: 111101111011 = (111101111011)2
3
111101111011 = (1111)(0111)(1011)
31

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(111101111011)2 = (3963)10
3
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011 = (111101111011)2
2
(111101111011)2 = (3963)10
6
Input: 111101111011
5
Input: 111101111011
5

(3963)10 = (F7B)16
1
(111101111011)2 = (3963)10
3
(3963)10 = (F7B)16
3
Input: 111101111011 = (111101111011)2
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
5
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

(3963)10 = (F7B)16
6
(3963)10 = (F7B)16
77____15
(3963)10 = (F7B)16
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
0
Input: 111101111011 = (111101111011)2
8
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
2
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

(3963)10 = (F7B)16
1
(111101111011)2 = (3963)10
3
(3963)10 = (F7B)16
3
Input: 111101111011 = (111101111011)2
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

(3963)10 = (F7B)16
6
(3963)10 = (F7B)16
77____15
(3963)10 = (F7B)16
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
0
Input: 111101111011 = (111101111011)2
8
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
2
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

(3963)10 = (F7B)16
6
(3963)10 = (F7B)16
77____15
(3963)10 = (F7B)16
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
0
Input: 111101111011 = (111101111011)2
8
0xf
0x35
0x10f
0xf7b
3
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
(1111)(0111)(1011) = F7B
46
Input: 111101111011
5
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:  F7B
8
Input: 111101111011
64
(1111)(0111)(1011) = F7B
52
Input: 111101111011
5
Input: 111101111011
71

Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
8
(1111)(0111)(1011) = F7B
39
Input: 111101111011
5
(1111)(0111)(1011) = F7B
39
Input: 111101111011
61
111101111011 = (1111)(0111)(1011)
5

Input: 111101111011
3
Input: 111101111011
64
(1111)(0111)(1011) = F7B
63

Input: 111101111011
1
Input: 111101111011
2

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
39
Input: 111101111011
5
(1111)(0111)(1011) = F7B
69

Input: 111101111011
3
Input: 111101111011
64
Input: 111101111011
65
(1111)(0111)(1011) = F7B
73
Input: 111101111011
67
Input: 111101111011
68
(1111)(0111)(1011) = F7B
76

Input: 111101111011
3
(1111)(0111)(1011) = F7B
78

(111101111011)2 = (3963)10
3
Input: 111101111011
90
Input: 111101111011
5
Input: 111101111011
5
Input: 111101111011
93
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Input: 111101111011
3
Input: 111101111011
96
Input: 111101111011
97
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
01

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
05
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
09
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
3

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ước

Ví 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 ().

Python3

Input: 111101111011
1
Input: 111101111011
2

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
39
Input: 111101111011
5
(1111)(0111)(1011) = F7B
69

(111101111011)2 = (3963)10
3
Input: 111101111011
90
Input: 111101111011
5
Input: 111101111011
5
Input: 111101111011
93
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
62
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
17

(111101111011)2 = (3963)10
3
Input: 111101111011
90
Input: 111101111011
5
Input: 111101111011
5
Input: 111101111011
93
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
Input: 111101111011
97
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
111101111011 = (1111)(0111)(1011)
01
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
111101111011 = (1111)(0111)(1011)
05
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
111101111011 = (1111)(0111)(1011)
09
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Output:

0xf
0x35
0x10f
0xf7b

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
01

Phương pháp 3: Sử dụng các chức năng được xác định trước

Python3

Input: 111101111011
1
Input: 111101111011
2

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
39
Input: 111101111011
5
(1111)(0111)(1011) = F7B
69

(111101111011)2 = (3963)10
3
Input: 111101111011
90
Input: 111101111011
5
Input: 111101111011
5
Input: 111101111011
93
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Input: 111101111011
3
111101111011 = (1111)(0111)(1011)
62
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
17

(111101111011)2 = (3963)10
3
Input: 111101111011
90
Input: 111101111011
5
Input: 111101111011
5
Input: 111101111011
93
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
7

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
Input: 111101111011
97
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Input: 111101111011
3
Input: 111101111011
96
111101111011 = (1111)(0111)(1011)
01

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
111101111011 = (1111)(0111)(1011)
05
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Input: 111101111011
3
Input: 111101111011
64
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
26
111101111011 = (1111)(0111)(1011)
09
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
28

Output:

Input: 111101111011
0

Làm thế nào để bạn chuyển đổi nhị phân thành thập lục phân trong Python?

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ó.use int() and hex() to convert a binary number to its equivalent hexadecimal number.

Làm thế nào để bạn chuyển đổi nhị phân thành thập lục phân?

Nhị phân đến thập lục phân..
Bắt đầu ở chữ số ngoài cùng bên phải và chia số nhị phân thành các nhóm bốn chữ số.Chúng được gọi là Nibble.....
Tiếp theo, chuyển đổi từng nhóm bốn chữ số thành thập phân ..
Chuyển đổi từng giá trị thập phân thành tương đương hex của nó ..
Đặt các chữ số hex lại với nhau ..

Làm thế nào để bạn chuyển đổi một số thành thập lục phân trong Python?

Chức năng hex () là một trong những hàm tích hợp trong python3, được sử dụng để chuyển đổi số nguyên thành dạng hexadecimal tương ứng.Cú pháp: Hex (x) Tham số: X - Số nguyên (đối tượng int) Trả về: Trả về chuỗi HexAdeCimal. is one of the built-in functions in Python3, which is used to convert an integer number into it's corresponding hexadecimal form. Syntax : hex(x) Parameters : x - an integer number (int object) Returns : Returns hexadecimal string.

Làm thế nào để bạn chuyển đổi 1010 nhị phân thành thập lục phân?

Bắt đầu từ bên phải (bit ít quan trọng nhất), tách số nhị phân của bạn thành các nhóm 4 chữ số mỗi chữ số: 0101 1010 ..
Chuyển đổi từng nhóm gồm 4 chữ số nhị phân thành chữ số thập lục phân: nhị phân 0101 = Hex 5, nhị phân 1010 = hex a ..