Hướng dẫn python binary string to hex - chuỗi nhị phân python thành hex

 x = int(input("press 1 for dec to oct,bin,hex \n press 2 for bin to dec,hex,oct \n press 3 for oct to bin,hex,dec \n press 4 for hex to bin,dec,oct \n"))


   if x is 1:

  decimal =int(input('Enter the decimal number: '))

  print(bin(decimal),"in binary.")
 print(oct(decimal),"in octal.")
    print(hex(decimal),"in hexadecimal.")

      if x is 2:

       binary = input("Enter number in Binary Format: ");

  decimal = int(binary, 2);
  print(binary,"in Decimal =",decimal);
  print(binary,"in Hexadecimal =",hex(decimal));
  print(binary,"in octal =",oct(decimal));

    if x is 3:

      octal = input("Enter number in Octal Format: ");

      decimal = int(octal, 8);
      print(octal,"in Decimal =",decimal);
      print(octal,"in Hexadecimal =",hex(decimal));
      print(octal,"in Binary =",bin(decimal));

          if x is 4:

         hex = input("Enter number in hexa-decimal Format: ");

      decimal = int(hex, 16);
        print(hex,"in Decimal =",decimal);
      print(hex,"in octal =",oct(decimal));
        print(hex,"in Binary =",bin(decimal));

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:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
2
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
3

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
5
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
7
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
111101111011 = (1111)(0111)(1011)
2
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
4
111101111011 = (1111)(0111)(1011)
5
111101111011 = (1111)(0111)(1011)
6
111101111011 = (1111)(0111)(1011)
7
111101111011 = (1111)(0111)(1011)
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
4
(1111)(0111)(1011) = F7B
5
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
(1111)(0111)(1011) = F7B
8

(1111)(0111)(1011) = F7B
9
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
5
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

(1111)(0111)(1011) = F7B
9
Input: 111101111011
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
0
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011 = (111101111011)2
0
111101111011 = (1111)(0111)(1011)
7
Input: 111101111011 = (111101111011)2
2

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

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
22
(1111)(0111)(1011) = F7B
8

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

(111101111011)2 = (3963)10
7
(111101111011)2 = (3963)10
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(3963)10 = (F7B)16
0
(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
9
(3963)10 = (F7B)16
3
(3963)10 = (F7B)16
4

(111101111011)2 = (3963)10
2
(3963)10 = (F7B)16
6
(1111)(0111)(1011) = F7B
8

(111101111011)2 = (3963)10
7
(111101111011)2 = (3963)10
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(3963)10 = (F7B)16
0
(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
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
4
(3963)10 = (F7B)16
4

(111101111011)2 = (3963)10
2
Input: 111101111011
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
6

(111101111011)2 = (3963)10
2
Input: 111101111011
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2

(111101111011)2 = (3963)10
2
Input: 111101111011
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
6

(111101111011)2 = (3963)10
2
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
11
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
6

(1111)(0111)(1011) = F7B
9
(3963)10 = (F7B)16
6
(1111)(0111)(1011) = F7B
8

(111101111011)2 = (3963)10
2
Input: 111101111011
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
20
111101111011 = (1111)(0111)(1011)
7
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
22

(111101111011)2 = (3963)10
2
Input: 111101111011
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
26
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
6

(1111)(0111)(1011) = F7B
9
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
5
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
7
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
33
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
34
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
4
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011 = (111101111011)2
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
39
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
6
(1111)(0111)(1011) = F7B
8

(1111)(0111)(1011) = F7B
9
(111101111011)2 = (3963)10
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(3963)10 = (F7B)16
0
(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
9
(3963)10 = (F7B)16
3
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011 = (111101111011)2
4
Input: 111101111011
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
6
(1111)(0111)(1011) = F7B
8

(1111)(0111)(1011) = F7B
9
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
11
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
62
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
66
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
67
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
68
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
69
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
70
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
72

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
75
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
(1111)(0111)(1011) = F7B
8

(1111)(0111)(1011) = F7B
9
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
81
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
83

(1111)(0111)(1011) = F7B
9
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
11
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
62
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
75
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
(1111)(0111)(1011) = F7B
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
98
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input: 111101111011
02
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input: 111101111011
06
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input: 111101111011
10
(3963)10 = (F7B)16
4

Output:

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

(1111)(0111)(1011) = F7B9Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F65Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F81Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F6Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F83

Input: 111101111011 = (111101111011)2
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
91
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
94
(1111)(0111)(1011) = F7B
8
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:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
2
Input: 111101111011
13

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
15
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
7
Input: 111101111011
18

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
20
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
Input: 111101111011
23
Input: 111101111011
222223
Input: 111101111011
2

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
4
Input: 111101111011
29
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
Input: 111101111011
32

(1111)(0111)(1011) = F7B
9
Input: 111101111011
34
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
15
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

(1111)(0111)(1011) = F7B
9
Input: 111101111011
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
40
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
34__

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
63
Input: 111101111011
64

(1111)(0111)(1011) = F7B
9
Input: 111101111011
15
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
53
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
34
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
34
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
111101111011 = (1111)(0111)(1011)
2
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
4
111101111011 = (1111)(0111)(1011)
5
111101111011 = (1111)(0111)(1011)
6
111101111011 = (1111)(0111)(1011)
7
111101111011 = (1111)(0111)(1011)
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
4
(1111)(0111)(1011) = F7B
5
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
(1111)(0111)(1011) = F7B
8

(1111)(0111)(1011) = F7B
9
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
5
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

(1111)(0111)(1011) = F7B
9
Input: 111101111011
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
92
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
3
Input: 111101111011
94

(1111)(0111)(1011) = F7B
9
Input: 111101111011 = (111101111011)2
4
Input: 111101111011
97
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
4
Input: 111101111011
32

(111101111011)2 = (3963)10
2
(111101111011)2 = (3963)10
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(3963)10 = (F7B)16
0
111101111011 = (1111)(0111)(1011)
04
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
(3963)10 = (F7B)16
3
(3963)10 = (F7B)16
4

(111101111011)2 = (3963)10
2
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(1111)(0111)(1011) = F7B
0
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
6

(1111)(0111)(1011) = F7B
9
(3963)10 = (F7B)16
6
(1111)(0111)(1011) = F7B
8

(111101111011)2 = (3963)10
2
(111101111011)2 = (3963)10
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(3963)10 = (F7B)16
0
111101111011 = (1111)(0111)(1011)
04
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
4
(3963)10 = (F7B)16
4

(111101111011)2 = (3963)10
2
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(1111)(0111)(1011) = F7B
0
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Input: 111101111011
6

(111101111011)2 = (3963)10
2
(111101111011)2 = (3963)10
8
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(3963)10 = (F7B)16
0
111101111011 = (1111)(0111)(1011)
04
Hexadecimal equivalent of 1111:  F
Hexadecimal equivalent of 110101:  35
Hexadecimal equivalent of 100001111:  10F
Hexadecimal equivalent of 111101111011:  F7B
9
Hexadecimal equivalent of 1111: 
F
Hexadecimal equivalent of 110101: 
35
Hexadecimal equivalent of 100001111: 
10F
Hexadecimal equivalent of 111101111011: 
F7B
4
(3963)10 = (F7B)16
4

(1111)(0111)(1011) = F7B
9
Input: 111101111011
92
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
7
111101111011 = (1111)(0111)(1011)
35
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
34
Input: 111101111011
94
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
(1111)(0111)(1011) = F7B
0
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
62
Input: 111101111011
6

(1111)(0111)(1011) = F7B
9
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
111101111011 = (1111)(0111)(1011)
53
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
72

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
(1111)(0111)(1011) = F7B
4
111101111011 = (1111)(0111)(1011)
47
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input: 111101111011
2
Input: 111101111011
32

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
111101111011 = (1111)(0111)(1011)
64

(1111)(0111)(1011) = F7B
9
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
62
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
2
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
3

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
66
111101111011 = (1111)(0111)(1011)
74
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
68
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
69
111101111011 = (1111)(0111)(1011)
77

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
111101111011 = (1111)(0111)(1011)
79

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
70

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
98
(3963)10 = (F7B)16
4

Input: 111101111011 = (111101111011)2
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
91
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
94
(1111)(0111)(1011) = F7B
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input: 111101111011
06
(3963)10 = (F7B)16
4

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input: 111101111011
10
(3963)10 = (F7B)16
4

Output:

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

Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F4Input: 1111 Output: F Input: 110101 Output: 35 Input: 100001111 Output: 10F97Input: 111101111011022

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 ()

Python3

(1111)(0111)(1011) = F7B
9
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
62
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
2
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
3

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
70

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
63
(1111)(0111)(1011) = F7B
18

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
70

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
98
(1111)(0111)(1011) = F7B
29

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input: 111101111011
02
(1111)(0111)(1011) = F7B
29

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input: 111101111011
06
(1111)(0111)(1011) = F7B
29

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input: 111101111011
10
(1111)(0111)(1011) = F7B
29

Output:

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
0

Input: 111101111011 = (111101111011)2
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
91
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
94
(1111)(0111)(1011) = F7B
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
97
Input: 111101111011
022

Python3

(1111)(0111)(1011) = F7B
9
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
62
Input: 111101111011
6

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
2
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
3

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
70

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
63
(1111)(0111)(1011) = F7B
18

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input: 111101111011
40
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
111101111011 = (1111)(0111)(1011)
70

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
98
(1111)(0111)(1011) = F7B
29

Input: 111101111011 = (111101111011)2
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
91
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
6
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
94
(1111)(0111)(1011) = F7B
8

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input: 111101111011
06
(1111)(0111)(1011) = F7B
29

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
4
Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
65
(1111)(0111)(1011) = F7B
27
Input: 111101111011
10
(1111)(0111)(1011) = F7B
29

Output:

Input:  1111
Output: F

Input: 110101
Output: 35

Input: 100001111
Output: 10F
1

Làm thế nào để bạn chuyển đổi nhị phân thành hex trong python?

Nhị phân đến thập lục phân bằng phương thức int () và hex () và sử dụng int () với 2 làm đối số thứ hai của nó, đã chuyển đổi giá trị đã cho thành giá trị loại số nguyên của cơ sở 2, đó là số nhị phân. Và sử dụng phương thức hex (), số nhị phân được chuyển đổi thành giá trị thập lục phân tương đương của nó.using int() and hex() And using int() method with 2 as its second argument, converted the given value into an integer type value of base 2, that is binary number. And using hex() method, the binary number gets converted into its equivalent hexadecimal value.

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 sử dụng Bin và Hex trong Python?

Phương pháp 1: Mã do người dùng xác định để chuyển đổi nhị phân thành hexadecimal Bước 1: Số nhị phân đầu vào.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.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.Step 1: Input binary number. Step 2: Divide your binary number into groups of four, starting from right. Step 3: Convert one 4-digit group of a binary number to one hexadecimal digit.

Làm cách nào để đọc một chuỗi nhị phân trong Python?

Phương pháp số 1: Dữ liệu nhị phân được chia thành các bộ 7 bit vì bộ nhị phân này làm đầu vào, trả về giá trị thập phân tương ứng là mã ASCII của ký tự của chuỗi.Mã ASCII này sau đó được chuyển đổi thành chuỗi bằng hàm chr ().using chr() function.