Sitemap
Manchirala Arun Kumar

Manchirala Arun Kumar

Data Types

4 min readJun 9, 2024
Press enter or click to view image in full size

Data Type :

Different types of data are available inside the python which we can store and create.

Types Of Data :

  • Numerical
  • String
  • Boolean
  • Collection

Numerical :

Numerical Data Type is categorized into three data types

  • Integer
  • Float
  • Complex

Integer :

Numerical data type by using which we ca create real numbers.

  • [ -∞,…..-4,-3,-2,-1,0,1,2,3,4,…., ∞ ]

Float :

It is also a numerical data type by using which we can create a decimal numbers. A floating point number, is a positive or negative whole number with a decimal point.

  • [ -∞,…..-4.1,-3.1,-2.1,-1.1,0.0,0.1,0.2,0.3,0.4,…., ∞ ]

Complex :

Complex numbers are the numbers that are expressed in the form of ( a + bi ) where a,b are real numbers and ‘ i ’ is a imaginary number.

  • Whenever you are creating a complex data type it should be having small ( j ) or Capital ( J ) .

Constructor :

It is a type of function. they are the things by using which we can create a particular thing.

  • Int ( )
  • Float ( )
  • Complex ( )

Function :

It’s a name given to a block of code.

Two types of functions :

  • In-built function's
  • User-defined function’s

In-built function:

Get Manchirala Arun Kumar’s stories in your inbox

Join Medium for free to get updates from this writer.

In-built functions are Pre-defined functions. they have their own functionality .

  • Ex : Int ( ), Float ( ), Complex ( ), Type ( )

User-defined function:

User defined functions are created by user or programmer to perform some specific task. user-defined function also has their own functionality.

  1. int( ) :

It is a integer constructor can construct integer data type. It can convert float data type to integer data type. It cannot convert complex data type to an integer.

Example is shown in a below image :

  • The first instruction i have given to convert from floating point to integer. It is converted to an integer.
  • The second instruction i have given to convert complex data to an integer. It is not converted and thrown an error. Because python will never convert complex data type to an integer data type.
Press enter or click to view image in full size
Int constructor

2. Float( ) :

It is a float constructor can construct float data type. It can convert integer data type to float data type. It cannot convert complex data type to float.

Example is shown in a below image :

  • The first instruction i have given to convert from integer to floating point. It is converted to a floating point.
  • The second instruction i have given to convert complex data to an floating point. It is not converted and thrown an error. Because python will never convert complex data type to floating point data type.
Press enter or click to view image in full size
Float constructor

3. Complex ( ):

It is a complex constructor can construct complex data type.It can convert integer data type to complex data type and also convert float data type to complex data type.

Example is shown in a below image :

  • The first instruction i have given to convert from integer to complex data type. It is converted to a complex data type.
  • The second instruction i have given to convert float data to complex data. It is converted . Because python will convert integer and floating point to complex data type.
  • Note : It can convert any kind of data (int,float) to complex data type.
Press enter or click to view image in full size

4. Type ( ):

It is a in-built function which is used for knowing the type of any data supported by python programming language.

  • I have checked the type of a variable { type (asdfg) }. It has thrown an error like “Name Error “ why because we haven’t created a variable (asdfg). you can see the example in below image.
Press enter or click to view image in full size
  • I have created variable then i checked the data type of a variable . Now, there is no error so it is successfully executed. Python engine returns a integer class.
Press enter or click to view image in full size
  • Important Note :

Hierarchy of constructors :-

  • When we are using combination of data types in single concept the python will give first priority to complex data type.

--

--