Sitemap
Vravinaik Boje

Vravinaik Boje

Type conversion

3 min read5 days ago

Type convection is a technique by using which we can convert a type of the data from one type to another type. The type conversion is two types

  1. implicit: implicit conversion in python is the automatic conversion of one data type into another by python, without the programmer explicitly converting it.

Ex: 1.2+3 this an example of here 1.2 is float and 3 is integer we convert int to float 3.0

  1. 2+3.0 we get the float value 4.2
Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

important of rules :primarily

  1. complex
  2. float
  3. integer

3.integer:

ex:1.2+3 or 1.2+3.0 or 10.1+9= 10.1 + 9.0 =19.1

1+(2+1j)=3+1j

1+2.0+(1+3j)

1+2.1+(1+3j)

2. float:

Press enter or click to view image in full size
  1. complex:
Press enter or click to view image in full size
  1. Explicit: In python explicit conversion means manually converting one data type into another using functions like int (), float () or str ().
Press enter or click to view image in full size

Explicit type conversion: programmer tools it can convert forcefully one data type to another data type

tools:

int (): integer convert will construct a integer values from a integer or float values.

int = 10 or int(1+2j)

Get Vravinaik Boje’s stories in your inbox

Join Medium for free to get updates from this writer.

2. float (): the float constructor it will convert a float value

Press enter or click to view image in full size

3. complex (): the complex constructor is to construct complex values

Press enter or click to view image in full size

python data type: there are different type of data which we can create python data.

  1. non-sequence) i. Booleans 2. sequential

i. Integer

ii. float

iii. complex

2.sequential

i. Text, ii. String, iii. Dictionary, iv. List vi. Tuple, Range

iii. set

i. set

ii. Fregin set

  1. Integer: python data type by using which we use create any real values -~ to +~ Ex: …~ -3–2–1 0 1 2 3 4 5…~
  2. float: Python is a data type by using which we can create any decimal values …-~ to …+~

Ex: -1.2345 0.0 + 1.2

  1. 2234567893456254 →precise 16 decimal values
  2. 33 →approximation

3. complex: python is a data type by using which we can create data called complex. real +_ imaginary ex: 3+4j.

Interning: interning is a technic it will automatically allocation a small memory is called cache memory.

→ integer support to interning

→float x1=0.12,x2= 0.12

x1=1.1 — 0.0j , x2 =1.1– 0.0j

Function:

id(): to get the actual memory

type(): to get the data type of the data

Press enter or click to view image in full size

Complex:

Press enter or click to view image in full size

--

--