Decimal Number System

A number system with a base value of 10 is termed a Decimal number system. and it is represented using digits between (0 to 9). Here, the place value is termed from right to left as first place value called units, second to the left as Tens, so on Hundreds, Thousands, etc.

1) Decimal to Binary.

For decimal to binary conversion, the number is divided by 2 until we get 1 or 0 as the final remainder. In python bin( ) function is used to convert decimal to binary numbers.

Here, a = 10
(10)10 = (1010)2
Python3
# Decimal to Binary
a = 10
print("Decimal to Binary ", a, ":", bin(a))

Output:

Decimal to Binary  10 : 0b1010

2) Decimal to Octal

For Decimal to Octal conversion, the number is divided by 8 until we get a number between 0 to 7 as the final remainder. In python oct( ) function is used to convert decimal to octal numbers.

so,  (10)10 = (12)8
Python3
# Decimal to Octal
a = 10
print("Decimal to Octal",a,":",oct(a))

Output:

Decimal to Octal 10 : 0o12

3) Decimal to Hexadecimal

For decimal to hexadecimal conversion, the number is divided by 16 until we get a number between 0 to 9 and (A to F)as the remainder. In python hex( ) function is used to convert decimal to hexadecimal numbers.

so, (1254)10  =  (4E6)16
Python3
a = 1254
print("Decimal to Hexadecimal",a,":",hex(1254))

Output:

Decimal to Hexadecimal 1254 : 0x4e6

Number System in Python

The arithmetic value that is used for representing the quantity and used in making calculations is defined as NUMBERS. The writing system for denoting numbers logically using digits or symbols is defined as a Number system. Number System is a system that defines numbers in different ways to represent numbers in different forms.

Types of Number System

The number system in Python is represented using the following four systems:

  •  Binary Number System (base or radix =2)
  •  Octal Number System (base or radix  = 8)
  •  Decimal Number System (base or radix  = 10)
  •  Hexadecimal Number System (base or radix  = 16)

Similar Reads

Binary Number System

A number system with base or radix 2 is known as a binary number system. Only 0 and 1 are used to represent numbers in this system....

Octal Number System

Octal Number System is one in which the base value is 8. It uses 8 digits i.e. 0-7 for the creation of Octal Numbers. It is also a positional system i.e weight is assigned to each position....

Decimal Number System

A number system with a base value of 10 is termed a Decimal number system. and it is represented using digits between (0 to 9). Here, the place value is termed from right to left as first place value called units, second to the left as Tens, so on Hundreds, Thousands, etc....

Hexadecimal Number System

A number system with a base of 16 is called a hexadecimal number system. It is represented using numbers between 0 to 9 and the alphabets between A to F. As both numeric digits and alphabets are used in this system, it is also called an alphanumeric system....