Python For Kids (Part 19: Hexadecimal Number System)

Python For Kids (Part 19: Hexadecimal Number System)

For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/Python-For-Kids

Today is another amazing day of our incredible journey! Today we are going to learn about the hexadecimal number system.

Last week we learned about the binary number system and learned that our little friend the microcontroller talks to us using binary.

Our computer has a brain very much like we do as people except our computer's brain has what we refer to as flash which is similar to the part of our brain that stores all of our memories and then it has registers which are very similar to the part of our brain which has more recent memories.

The flash and registers use the hexadecimal number system which ultimately our little friend turns into binary. The reason why our little microcontroller uses hexadecimal is because binary uses a lot of 0 and 1 to represent a number which ultimately represents a letter or number or the combination of them images or sound, etc.

I know this is a bit confusing but I wanted to explain a little bit about why hexadecimal is so important. If you think about saying the word hello like we discussed in our prior lessons it takes a lot of 0 and 1 to represent that. The word hello in binary is 01101000 01100101 01101100 01101100 01101111.

In prior lessons we talked about the ascii table that our little microcontroller uses to translate letters into something it can understand and that is how we got the binary number above. If this is still a little confusing as I know it can be, take a moment and re-read lesson 16 as it will help a great deal.

Now it is time to introduce the hexadecimal number system. We know that decimal has 10 numbers and we know that binary has 2 numbers. Hexadecimal has 16 numbers so lets show exactly what they are and what they translate to in decimal and binary.

Hexadecimal     Decimal     Binary
-----------     -------     ------
0                0          0000
1                1          0001
2                2          0010
3                3          0011
4                4          0100
5                5          0101
6                6          0110
7                7          0111
8                8          1000
9                9          1001
A               10          1010
B               11          1011
C               12          1100
D               13          1101
E               14          1110
F               15          1111

So the good news is we see that the from 0 to 9 the numbers are the same. We see that what we know of as decimal 10 we see A in hexadecimal. We see B is 11 in decimal, C is 12 in decimal, D is 13 in decimal, E is 14 in decimal and F is 15 in decimal.

You are doing great so far! Let's go back to our hello example again. We know that in binary it translates to 01101000 01100101 01101100 01101100 01101111 which is a a lot of numbers. Each letter is 8 binary numbers or what we call a byte. Each number in binary is a bit and 8 bits make a byte in binary.

In hexadecimal each digit from 0 to F represents 4 bits or what we call a nibble as we see in the table above.

When we look back again in our hello example, hello translates to 68 65 6c 6c 6f in hexadecimal which is a lot shorter and easier to read then 01101000 01100101 01101100 01101100 01101111 in binary.

Each hexadecimal digit being a nibble or 4 bits or a half a byte means that that 68 in hex is 01101000 in binary which is our letter h. Therefore 6 is 4 bits and together with 8 which is 4 bits make up 8 bits or a byte. Same as the examples below.

Each hexadecimal digit being a nibble or 4 bits means that that 65 in hex is 01100101 in binary which is our letter e.

Each hexadecimal digit being a nibble or 4 bits means that that 6c in hex is 01101100 in binary which is our letter l.

Each hexadecimal digit being a nibble or 4 bits means that that 6c in hex is 01101100 in binary which is our letter l.

Each hexadecimal digit being a nibble or 4 bits means that that 6f in hex is 01101111 in binary which is our letter o.

You are doing great! I am so proud of you for working through this and getting an introduction to these number systems. I am so proud of you!

In our next lesson we will talk about primitive data types.


要查看或添加评论,请登录

Kevin Thomas的更多文章

社区洞察

其他会员也浏览了