# Python Number With Examples

This article entitle Python Number is a continuation of the previous article entitled Python Loops.

Python Numbers are data types that store numeric values and these are immutable data types which means that there will be no changes in the number results in the newly allocated object.

## What is a Python number?

In Python, a number refers to a numeric data type and has three in-built numeric data types listed below.

• Integers
• Floating point numbers
• Complex numbers

## Python Integer

An integer is a whole number without any decimal places, it’s a positive and a negative number and has unlimited length.

Example

```num1 = 1
num2 = 9732827472724242
num3 = -77382232

print(type(num1))
print(type(num2))
print(type(num2))```

Output

```<class 'int'>
<class 'int'>
<class 'int'>
```

## Python Floating Point Number

A floating point number or a float in short is a number that contains single or multiple decimal places.

Example

```num1 = 1.20
num2 = 2.0
num3 = -45.65

print(type(num1))
print(type(num2))
print(type(num3))```

Output

```<class 'float'>
<class 'float'>
<class 'float'>
```

## Python Complex Numbers

Complex numbers in Python are written with a (j) as an imaginary part of a number.

Example

```num1 = 4+6j
num2 = 6j
num3 = -7j

print(type(num1))
print(type(num2))
print(type(num3))```

Output

```<class 'complex'>
<class 'complex'>
<class 'complex'>
```

## Number Type Conversion in Python

Python can also convert a number internally into an expression that contains a mixed type to a common type for evaluation. In some instances, you should need to coerce a number explicitly from a single type to another just to satisfy all the requirements of the operator or a parameter function.

• A type int(x) is used to convert an x to a plain integer.
• A type long(x) is used to convert an x to a long integer.
• A type float(x) is used to convert an x to a floating-point number.
• A type complex(x) is used to convert an x to a complex number with a real part x and a number imaginary part to zero.
• A type complex(x, y) is used to convert an x to a complex number with a real part x and an imaginary part y. And the x and y is a numeric expression.

## Python Mathematical Functions

Python also includes the following functions which can perform mathematical calculations.

## Python Random Numbers Functions

Random numbers are mostly used for games, testing, security, testing, and privacy applications.

The following table below shows functions that are commonly used in development.

## Python Trigonometric Functions

The following table below are functions that commonly use for trigonometric calculations.

## Python Mathematical Constants

The following modules can also define the two mathematical constants

## Summary

In summary, you have read about Python Number. We also discussed in this article what is a Python number, integer, floating point, complex numbers, number type conversion, mathematical functions, random numbers functions, trigonometric functions, and mathematical constants.