0% found this document useful (0 votes)
4 views

Tutorial 2

python questions 2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Tutorial 2

python questions 2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Tutorial on Number system

Course- BTech Type- Core


Course Code- CSET101 Course Name- Computational Thinking
Year- 2024 and Programming
Batch- ALL Semester- odd

Tutorial Assignment: 2

Tutorial title: Introduction to python and Number system conversion

CO Mapping
Name CO1 CO2 CO3
Number System Conversion ✓ - -

In computer applications the Binary numbers are represented by only two symbols or digits, i.e. 0 and 1. The
binary numbers here are expressed in the base-2 numeral system. For example, (101)2 is a binary number. Each
digit in this system is said to be a bit. The Octal number system has base value equal to 8 and comprise
numbers 0 to 7. The Decimal number system is the number system that we use on a daily basis based on the
10 digits (0-9). The Hexadecimal number system number system has a base value equal to 16. Containing
numbers from 0 to 9 and the capital letters A to F to represent its Binary or Decimal number equivalent.

Conversion of Binary to Other Number Systems


To convert a binary number to octal number then Group all the 1's and 0's in the binary number in sets
of three, starting from the far right. Add zeros to the left of the last digit if you don't have enough digits to
make a set of three. Add up the new numbers in each set of three. For example: 10101 2 is the binary number.
We can write the given binary number as: 010 101. Now as we know, in the octal number system, 010 → 2 and
101 → 5. Therefore, the required octal number is (25)8.
To convert the binary number to decimal is equal to the sum of binary digits (dn) times their power of 2
(2n). For example: (10101)2 = 1 × 24 + 0 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 16 + 4 + 1 == (21)10.
To convert binary number to hexadecimal: Divide the binary digits into groups of four (starting from
right) for integer part and start from left for fraction part. Convert each group of four binary digits to one
hexadecimal digit. For example: 0001 0101 = (15)16.

Conversion of Octal to Other Number Systems


To convert the octal to binary: In order to convert the octal number into binary, we need to express
every octal value using 3 binary bits. For example (41)8 = 100 001 = (100001)2. To convert the octal to decimal:
is equal to the sum of octal digits (dn) times their power of 8 (8n). For example: 418 = (4 * 81) + (1 * 80) = 4 * 8
+ 1 * 1 = 32+1 = (33)10.

To convert the octal to hexadecimal: In order to convert the octal number into binary, we need to express
every octal value using 3 binary bits. And after that, we need to group every 4 binary bits and calculate the
value [From left to right]. For example: (41)8 = 100 001. Combine the groups = (100001)2. Divide the binary
digits from previous groups of 4 digits, starting from the right. = 0010 0001. Convert each group of 4 binary
digits into 1 hexadecimal digit. 0010 = 2, 0001 = 1, = (21)16.
Tutorial on Number system
Conversion of Decimal to Other Number Systems
To convert a decimal number to binary we need to divide the given number by 2 until the quotient is
equal to 0. We keep the remainders aside during the division process. Once the quotient is equal to zero, we
write the remainder along with the last numbers starting from the bottom to the top to obtain the binary number.
For example, (20)10 = (10000000)2

To convert decimal to octal, the decimal number is divided by 8 and record the remainders. Once the
quotient is less than 8, we obtain the octal number by writing the remainder in reverse order. For example, (45)10
= (55)8
The decimal to hexadecimal conversion is done similarly to the other two number systems. The base number
of hexadecimal is 16 so the number needs to be divided by 16 until the quotient is zero.

Conversion of Hexadecimal to Other Number Systems


To convert hexadecimal to a binary number we need to first convert the hexadecimal number to a
decimal number to finally convert it to a binary number. For example, (100) 16 is converted to decimal by
multiplying each digit with 16n-1.
(100)16 = 1 × 16(3-1) + 0 × 16(2-1) + 0 × 16(1-1)
(100)16 = 1 × 162 + 0 × 161 + 0 × 160
(100)16 = (256)10
Now, convert the decimal number (256)10 to a binary number by dividing the number by 2 until the quotient is
zero.
(100)16= (100000000)2

Questions:

1. How is the binary number (10101)2 converted to its octal equivalent?


a) Group into sets of two bits from the right
b) Group into sets of three bits from the left
c) Group into sets of three bits from the right
d) Group into sets of four bits from the right
Answer: c) Group into sets of three bits from the right
2. What is the octal equivalent of the binary number (10101)2?
a) (25)8
b) (24)8
c) (22)8
d) (20)8
Answer: a) (25)8
Tutorial on Number system

3. What is the first step to convert a binary number to a hexadecimal number?


a) Group all bits into sets of three from the right
b) Group all bits into sets of four from the right
c) Group all bits into sets of four from the left
d) Group all bits into sets of three from the left
Answer: b) Group all bits into sets of four from the right
4. Convert the binary number (0001 0101)2 to its hexadecimal equivalent.
a) (14)16
b) (15)16
c) (13)16
d) (12)16
Answer: b) (15)16
5. What is the decimal equivalent of the octal number (41)8?
a) (31)10
b) (32)10
c) (33)10
d) (34)10
Answer: c) (33)10
6. How is the octal number (41)8 converted to its binary equivalent?
a) 101 000
b) 100 001
c) 110 001
d) 101 001
Answer: b) 100 001
7. Which number system has a base value of 8 and includes numbers from 0 to 7?
a) Binary
b) Octal
c) Decimal
d) Hexadecimal
Answer: b) Octal
Tutorial on Number system

8. What is the first step to convert a decimal number to binary?


a) Divide by 8 and record the remainders
b) Divide by 2 and record the remainders
c) Divide by 4 and record the remainders
d) Divide by 16 and record the remainders
Answer: b) Divide by 2 and record the remainders
9. Convert the decimal number (20)10 to its binary equivalent.
a) (10100)2
b) (11000)2
c) (11100)2
d) (10000)2
Answer: a) (10100)2
10. What is the hexadecimal equivalent of the binary number (10000000)2?
a) (80)16
b) (90)16
c) (70)16
d) (60)16
Answer: a) (80)16

11. What is the base value of the Binary number system?


a) 2
b) 8
c) 10
d) 16
Answer: a) 2

12. What is the binary equivalent of the decimal number (21)10?


a) 10101
b) 10100
c) 10001
d) 11001
Answer: a) 10101
Tutorial on Number system

13. Which number system has a base value of 16 and includes numbers from 0 to 9 and the letters A
to F?
a) Binary
b) Octal
c) Decimal
d) Hexadecimal
Answer: d) Hexadecimal
14. How do you convert the binary number (10101)2 to its decimal equivalent?

a) 1 × 2^4 + 0 × 2^3 + 1 × 2^2 + 0 × 2^1 + 1 × 2^0

b) 1 × 2^5 + 0 × 2^4 + 1 × 2^3 + 0 × 2^2 + 1 × 2^1

c) 1 × 2^3 + 0 × 2^2 + 1 × 2^1 + 0 × 2^0 + 1 × 2^1

d) 1 × 2^4 + 0 × 2^3 + 1 × 2^2 + 1 × 2^1 + 1 × 2^0

Answer: a) 1 × 2^4 + 0 × 2^3 + 1 × 2^2 + 0 × 2^1 + 1 × 2^0

15. To convert a decimal number to binary, what is the method used?

a) Divide by 8 and record the remainders.

b) Divide by 2 until the quotient is zero, then write the remainders in reverse order.

c) Divide by 16 and record the remainders.

d) Divide by 4 until the quotient is zero, then write the remainders in reverse order.

Answer: b) Divide by 2 until the quotient is zero, then write the remainders in reverse
order.

16. Convert the octal number (41)8 to its binary equivalent.


a) 100 001
b) 101 001
c) 100 011
d) 110 001
Answer: a) 100 001
Tutorial on Number system

17. What is the hexadecimal equivalent of the binary number 0001 0101?
a) 13
b) 14
c) 15
d) 16

Answer: c) 15

18. Which of the following is not a correct extension for a Python file?
a) .py
b) .p
c) .python
d) .pl
Answer: b) .p and d) .pl
19. How do you convert the decimal number (45)10 to its octal equivalent?
a) Divide by 2 until the quotient is zero.
b) Divide by 16 until the quotient is zero.
c) Divide by 8 and record the remainders, then write the remainders in reverse order.
d) Divide by 4 until the quotient is zero.
Answer: c) Divide by 8 and record the remainders, then write the remainders in reverse
order.
20. Convert the hexadecimal number (100)16 to its binary equivalent.
a) 1100000
b) 100000000
c) 1010101
d) 1110000
Answer: b) 100000000
21. What is the first step to convert a hexadecimal number to a binary number?
a) Convert it to decimal first
b) Convert it to octal first
c) Group into sets of four bits from the right
d) Divide by 2 and record the remainders
Tutorial on Number system
Answer: c) Group into sets of four bits from the right
22. Convert the hexadecimal number (100)16 to its decimal equivalent.
a) (250)10
b) (255)10
c) (256)10
d) (257)10
Answer: c) (256)10
23. What is the base value of the Decimal number system?
a) 2
b) 8
c) 10
d) 16
Answer: c) 10
24. Convert the decimal number (45)10 to its octal equivalent.
a) (54)8
b) (55)8
c) (56)8
d) (57)8
Answer: b) (55)8
25. What is the first step to convert a decimal number to hexadecimal?
a) Divide by 2 and record the remainders
b) Divide by 4 and record the remainders
c) Divide by 8 and record the remainders
d) Divide by 16 and record the remainders
Answer: d) Divide by 16 and record the remainders
26. What is the decimal equivalent of the octal number (254)8?
a) (172)10
b) (170)10
c) (168)10
d) (166)10
Answer: a) (172)10
27. How is the decimal number (1032)10 converted to its octal equivalent?
a) Divide by 2 until the quotient is zero
b) Divide by 8 until the quotient is zero
Tutorial on Number system
c) Divide by 16 until the quotient is zero
d) Divide by 4 until the quotient is zero
Answer: b) Divide by 8 until the quotient is zero
28. Convert the decimal number (1032)10 to its octal equivalent.
a) (2010)8
b) (1770)8
c) (2050)8
d) (3000)8
Answer: a) (2010)8
29. Convert the octal number (11672)8 to its hexadecimal equivalent.
a) (13BA)16
b) (4EA)16
c) (4DA)16
d) (4CA)16
Answer: a) (13BA)16

You might also like