Python Numerical Types

This data type supports only numerical values like 1 , 31.4 .

Python 3 support 3 different numerical types.

  1. int – for integer values like 45 .
  2. float – for floating point values like 2.3 .
  3. complex – for complex numbers like 3+2j .


Integer literals in python belong to int  class.


Floating points are values with decimal point like.

One point to note that when one of the operands for numeric operators is a float value then the result will be in float value.

Complex number

As you may now complex number consists of two parts real and imaginary, and is denoted by j .You can define complex number like this:

Determining types

Python has type()  inbuilt function which is use to determine the type of the variable.

Python operators

Python has the different operators which allows you to carry out required calculations in your program.


+  ,   and *  works as expected, remaining operators require some explanation.

/ – Float Division : /  operator divides and return result as floating point number means it will always return fractional part. For e.g


// – Integer Division : //  perform integer division i.e it will truncate the decimal part of the answer and return only integer.


** – Exponentiation Operator : This operator helps to compute a(a raise to the power of b). Let’s take an example:

% operator
 : % operator also known as remainder or modulus operator. This operator return remainder after division. For e.g:

Operator Precedence

In python every expression are evaluated using operator precedence. Let’s take an example to make it clear.

In the above expression which operation will be evaluated first addition or multiplication? To answer such question we need to refer to operator precedence list in python. Image below list python precedence order from high to low.


Operator precedence top (high) to bottom(low)

as you can see in table above *  is above +  , so *  will occur first then addition. Therefore the result of the above expression will be 13 .

Let’s,take one more example to illustrate one more concept.

In above expression which will occur first addition or subtraction. As we can see from the table +  and   have same precedence, then they will be evaluated from left to right, i.e addition will be applied first then subtraction.

The only exception to this rule is assignment operator ( = ) which occur from right to left.

You can change precedence by using parentheses () ,  For e.g

As you can see from the precedence table ()  has highest priority so in expression 3 * (4 +1) , (4 + 1)  is evaluated first then multiplication. Hence you can use ()  to alter order of precedence.

Augmented Assignment Operator

These operator allows you write shortcut assignment statements. For e.g:

by using Augmented Assignment Operator we can write it as:

similarly you can use   , %  , //  , /  , *  , **  with assignment operator to form augmented assignment operator.


Leave a Reply

Your email address will not be published. Required fields are marked *