Thursday , February 22 2018
most suggested
Home / Python / Python Number Systems Example

# Python Number Systems Example

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

## Python Number Systems :

Python number systems are representing how to use the below numbers in Language.

• Binary Number System
• Octal Number System
• Decimal Number System

Lets see one by one, how these are used in python language.

### Binary Number System :

In general a binary number represents the 0 and 1 in the system.

The base or radix of the binary number system is 2.

The possible digits that are used in binary number system are 0 and 1.

To represent a binary number in Python as a input, the number should be starts with 0b.

### Example : Python binary Number System

```
x = 0b1010

print('Value is : ',x)

```

(Value is : 10)

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

### Octal Number System :

The base or radix of the octal number system is 8.

The possible digits that are used in octal number system are 0 to 7.

To represent a binary number in Python as a input, the number should be starts with 0 (python2) or ox (python3).

### Example : Python octal Number System

```
x=0123

print('Value is : '+x)

```

(Value is : 83)

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

### Decimal Number System :

The base or radix of the decimal number system is 10.

The possible digits that are used in decimal number system are 0 to 9.

The default number system followed by python is decimal number system.

```
x=1234

print('Value is : '+x)

```

(Value is : 1234)

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

The possible digits that are used in hexadecimal number systems are 0 to  9 and a to f.

To represent a binary number in Python as a input, the number should be starts with 0x.

```
x=0x25

print('Value is :'+x)

```

(Value is : 37)

Resources :

Number System Wiki

Python Dev Peps

Happy Learning 🙂

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

## Python raw_input read input from keyboard

In this tutorials I am going to show you how to read input from keyboard …