According to the mathematics we have four types of number systems which are representing the numbers in computer architecture. In this tutorial, we are going to learn how to deal with these number systems in Python Language.

## Python Number Systems :

The python number system is representing the way of using the below numbers in Language.

- Binary Number System
- Octal Number System
- Decimal Number System
- Hexadecimal Number System

Let’s see one by one, how these are used in the python language.

## Binary Number System :

- In general, a binary number represents a 0 or 1 in the system.
- The base or radix of the binary number system is 2.
- The possible digits that are used in a binary number system are 0 and 1.
- If we wanted to store a binary number in python variable, that number should sharts with
.**0b**

## Example: Python binary Number System

```
x = 0b1010
print('Value is : ',x)
```

**Output :**

`(Value is : 10)`

**Note:** we can not give the since binary numbers contain only 0 and 1. If so we will get an error message like SyntaxError: invalid syntax.**x=ob1020**

## Octal Number System :

- The base or radix of the octal number system is 8.
- The possible digits that are used in the octal number system are 0 to 7.
- To represent an octal number in Python, the number should start with
.**0 (python2) or ox (python3)**

## Example: Python octal Number System

```
x=0123
print('Value is : '+x)
```

**Output :**

`(Value is : 83)`

**Note:** we can not give the since octal numbers contain from 0 to 7. If so we will get an error message like SyntaxError: invalid token.**x=o180**

## Decimal Number System :

- The base or radix of the decimal number system is 10.
- The possible digits that are used in the decimal number system are 0 to 9.
- The default number system followed by python is the decimal number system.

```
x=1234
print('Value is : '+x)
```

**Output :**

`(Value is : 1234)`

**Note:** we can not give the since the decimal numbers contain from 0 to 9. If so we will get an error message like SyntaxError: invalid syntax.**x=1234p**

## Hexadecimal Number System :

- The base or radix of the hexadecimal number system is 16.
- The possible digits that are used in hexadecimal number systems are 0 to 9 and a to f.
- To represent a hexadecimal number in Python, the number should start with
.**0x**

```
x=0x25
print('Value is :'+x)
```

**Output :**

`(Value is : 37)`

## Resources :

Happy Learning 🙂

## Leave A Comment