Where hexadecimal is used in computer science

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

This Where hexadecimal is used in computer science worksheet is part of the IGCSE Computer Science 0478 — 1.1 Number Systems journey. Print it as a booklet?

Where hexadecimal is used in computer science

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A web designer needs an orange colour code. Which one is a valid hexadecimal colour?
A #FF8800
B #GG8800
2. In the colour code #FF8800, what does the first pair FF set?
A Red at its maximum value (255)
B Blue at its minimum value (0)
3. Why do HTML and CSS colour codes use hexadecimal?
A Browsers cannot understand binary or denary numbers
B It is a short way to write the 24 bits of a colour
4. Which of these is a MAC address written in hexadecimal?
A 00:1A:2B:3C:4D:5E
B 00:1A:2B:3C:4D:5Z
5. A memory dump lists the contents of memory. Why are the addresses shown in hexadecimal?
A Memory chips can only store hex digits
B Hex is shorter and easier for people to read than long binary

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1color: #FF8800; AComputers store data in binary. Hex is only a shorter way for people to read and write binary values.
200:1A:2B:3C:4D:5E BError 0x80070005: Access denied
3Hexadecimal lets programmers read a memory address or memory dump value compactly instead of a long binary string CA CSS colour written as hexadecimal: FF red, 88 green, 00 blue (one byte per colour)
4Error codes are shown in hexadecimal so a technician or programmer can quickly look them up and debug the fault D0x7FFE 4A10
5color: #GG8800; EA MAC address: 6 bytes shown as 12 hex digits to identify a network device
6Hex is used because computers store data in hexadecimal instead of binary FG is not a hexadecimal digit. Hex uses only 0-9 and A-F, so #GG8800 is not a valid colour code.

Definitions

hexadecimal

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
color: _FF8800;
2.
background: #__0000;
3.
macbits = 12 * _
4.
address = __1A3F
5.
print(___(255))

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A h1 {
B color: #FF8800;
C background: #0000GG;
D }
Question 2
A address ← 0x1G3F
B OUTPUT address
C OUTPUT address + 1
Question 3
A hex ← FF
B nibble1 ← 1111
C nibble2 ← 1111
D binary ← 11110000
Question 4
A colour ← #FF8800
B red ← FF
C green ← FF
D blue ← 00
Question 5
A code ← 0x0B
B digit1 ← 0
C digit2 ← 11
D denary ← 16 * digit2 + digit1

Answer Key

Where hexadecimal is used in computer science
Section A: Quick Questions
Q1
A — #FF8800
Q2
A — Red at its maximum value (255)
Q3
B — It is a short way to write the 24 bits of a colour
Q4
A — 00:1A:2B:3C:4D:5E
Q5
B — Hex is shorter and easier for people to read than long binary
Section B: Match the Pairs
Q1
color: #FF8800; → A CSS colour written as hexadecimal: FF red, 88 green, 00 blue (one byte per colour)
Q2
00:1A:2B:3C:4D:5E → A MAC address: 6 bytes shown as 12 hex digits to identify a network device
Q3
Hexadecimal lets programmers read a memory address or memory dump value compactly instead of a long binary string → 0x7FFE 4A10
Q4
Error codes are shown in hexadecimal so a technician or programmer can quickly look them up and debug the fault → Error 0x80070005: Access denied
Q5
color: #GG8800; → G is not a hexadecimal digit. Hex uses only 0-9 and A-F, so #GG8800 is not a valid colour code.
Q6
Hex is used because computers store data in hexadecimal instead of binary → Computers store data in binary. Hex is only a shorter way for people to read and write binary values.
Section C: Definitions
Q1
hexadecimal — Base-16 notation that shortens binary so people can read and write it. Used in colour codes, MAC addresses, memory addresses and error codes.
Section D: Fill in the Blanks
Q1
color: #FF8800;
Q2
background: #FF0000;
Q3
macbits = 12 * 4
Q4
address = 0x1A3F
Q5
print(hex(255))
Section E: Spot the Error
Q1
C — Hexadecimal colour codes can only use the digits 0-9 and the letters A-F. G is not a hex digit, so the blue value should be #0000FF.
Q2
A — Memory addresses are written in hexadecimal, which only uses 0-9 and A-F. G is not valid, so the line should be address ← 0x1A3F.
Q3
D — Each hex digit is one 4-bit nibble. F is 1111, so FF is 11111111, not 11110000.
Q4
C — In #FF8800 the colour is split into pairs: red FF, green 88, blue 00. The green value should be 88.
Q5
D — The first hex digit is worth 16 and the second is worth 1. The calculation should be 16 * digit1 + digit2, which gives 11 for the error code 0x0B.