w3resource

Understanding Numeral Systems binary, octal, decimal, and hexadecimal for PCEP-30-02 Python Exam

PCEP Certification Practice Test - Questions, Answers and Explanations

This comprehensive set of questions and explanations covers the fundamental topic of introducing literals and variables into code and using different numeral systems, focusing on binary, octal, decimal, and hexadecimal numeral systems. This diverse set of interactions enhances understanding and prepares for the PCEP-30-02 examination.

Question 1: Which of the following is the correct binary representation of the decimal number 10?

  1. 1001
  2. 1010
  3. 1111
  4. 1100

Answer: b) 1010

Explanation: The binary representation of decimal 10 is 1010.

Question 2: What is the octal representation of the decimal number 8?

  1. 10
  2. 8
  3. 12
  4. 11

Answer: a) 10

Explanation: The octal representation of decimal 8 is 10 because octal is base-8.

Question 3: What is the hexadecimal representation of the binary number 1110?

  1. A
  2. B
  3. C
  4. E

Answer: d) E

Explanation: The binary number 1110 corresponds to the hexadecimal value E.

Question 4: Which of the following are valid hexadecimal digits? (Select all that apply).

  1. G
  2. 9
  3. F
  4. B

Answer:b) 9, c) F, d) B

Explanation: Hexadecimal digits range from 0-9 and A-F.

Question 5: Select all the valid binary numbers.

  1. 1010
  2. 1021
  3. 0110
  4. 2101

Answer: a) 1010, c) 0110.

Explanation: Binary numbers only contain the digits 0 and 1.

Question 6: Place the following binary numbers in the correct decimal order: 1101, 1001, 1010, 1110.

Answer:

  1. 1001
  2. 1010
  3. 1101
  4. 1110

Explanation: Converting to decimal: 1001 (9), 1010 (10), 1101 (13), 1110 (14).

Question 7: Place the following hexadecimal numbers in the correct decimal order: A, 9, C, B.

Answer:

  • 9
  • A
  • B
  • C

Explanation: Converting to decimal: 9 (9), A (10), B (11), C (12).

Question 8: The binary number 1011 in decimal is ______.

Answer: 11

Explanation: 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0 = 8 + 0 + 2 + 1 = 11.

Question 9: The hexadecimal number F in decimal is ______.

Answer: 15

Explanation: F in hexadecimal is 15 in decimal.

Question 10: Sort the following numbers in ascending order: 1A (hex), 1100 (binary), 14 (decimal), 16 (octal).

Answer:

  • 1100 (binary)
  • 16 (octal)
  • 14 (decimal)
  • 1A (hex)

Explanation: Converting all to decimal: 1100 (12), 16 (14), 14 (14), 1A (26).

Question 11: Sort the following numbers in ascending order: 101 (binary), 21 (octal), 11 (decimal), B (hex).

Answer:

  • 101 (binary)
  • 11 (decimal)
  • B (hex)
  • 21 (octal)

Explanation: Converting all to decimal: 101 (5), 11 (11), B (11), 21 (17).

Question 12: Fill in the missing code to convert the binary number 1011 to decimal.

binary = "1011"
decimal = int(binary, ______)
print(decimal)

Answer:2

Explanation: The int function with base 2 converts a binary string to a decimal integer.

Question 13: Fill in the missing code to convert the decimal number 255 to hexadecimal.

decimal = 255
hexadecimal = hex(______)
print(hexadecimal)

Answer: decimal

Explanation: The hex function converts a decimal integer to a hexadecimal string.

Question 14: Insert the correct code to convert the octal number 17 to decimal.

octal = "17"
decimal = int(octal, ____)
print(decimal)

Answer: 8

Explanation: The int function with base 8 converts an octal string to a decimal integer.

Question 15: Insert the correct code to convert the hexadecimal number '1C' to decimal.

hex_num = "1C"
decimal = int(hex_num, ____)
print(decimal)

Answer: 16

Explanation: The int function with base 16 converts a hexadecimal string to a decimal integer.

Question 16: What is the binary representation of the hexadecimal number B?.

  1. 1011
  2. 1100
  3. 1110
  4. 1001

Answer: a) 1011

Explanation: The hexadecimal number B corresponds to the binary number 1011.

Question 17: What is the octal representation of the binary number 1111?

  1. 17
  2. 18
  3. 16
  4. 15

Answer: a) 17

Explanation: The binary number 1111 corresponds to the octal number 17.

Question 18: Which of the following are valid octal numbers? (Select all that apply)

  1. 78
  2. 67
  3. 54
  4. 45

Answer:b) 67,c) 54, d) 45

Explanation: Octal numbers contain digits from 0 to 7 only.

Question 19: Which of the following are valid decimal numbers? (Select all that apply)

  1. 10
  2. 20
  3. 1F
  4. 101

Answer: a) 10, b) 20, d) 101

Explanation: Decimal numbers contain digits from 0 to 9 only.

Question 20: The octal number 21 in decimal is ______.

Answer: 17

Explanation: 2*8^1 + 1*8^0 = 16 + 1 = 17.

Question 21: The hexadecimal number A in decimal is ______.

Answer: 10.

Explanation: A in hexadecimal is 10 in decimal.

Question 22: Sort the following numbers in ascending order: 110 (binary), 11 (decimal), 2 (hex), 10 (octal).

Answer:

  • 110 (binary)
  • 2 (hex)
  • 10 (octal)
  • 11 (decimal)

Explanation: Converting all to decimal: 110 (6), 2 (2), 10 (8), 11 (11).

Question 23: Sort the following numbers in ascending order: 1F (hex), 22 (octal), 1110 (binary), 25 (decimal).

Answer:

  • 1110 (binary)
  • 22 (octal)
  • 25 (decimal)
  • 1F (hex)

Explanation: Converting all to decimal: 1110 (14), 22 (18), 25 (25), 1F (31).

Question 24: Fill in the missing code to convert the decimal number 128 to binary.

decimal = 128
binary = bin(______)
print(binary)

Answer: decimal

Explanation: The bin function converts a decimal integer to a binary string.

Question 25: Fill in the missing code to convert the octal number 75 to hexadecimal.

octal = "75"
decimal = int(octal, 8)
hexadecimal = hex(______)
print(hexadecimal)

Answer: decimal

Explanation: First, convert the octal string to a decimal integer, then convert that to a hexadecimal string.

Question 26: Insert the correct code to convert the binary number 101010 to octal.

binary = "101010"
decimal = int(binary, 2)
octal = oct(______)
print(octal)

Answer: decimal

Explanation: First, convert the binary string to a decimal integer, then convert that to an octal string.

Question 27: Insert the correct code to convert the hexadecimal number 2A to binary.

hex_num = "2A"
decimal = int(hex_num, 16)
binary = bin(______)
print(binary)

Answer: decimal

Explanation: First, convert the hexadecimal string to a decimal integer, then convert that to a binary string.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/python/certificate/literals-and-variables-binary-octal-decimal-and-hexadecimal-numeral-systems.php