Type conversion
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
- 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
- 2+3.0 we get the float value 4.2
important of rules :primarily
- complex
- float
- 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:
- complex:
- Explicit: In python explicit conversion means manually converting one data type into another using functions like int (), float () or str ().
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
3. complex (): the complex constructor is to construct complex values
python data type: there are different type of data which we can create python data.
- 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
- Integer: python data type by using which we use create any real values -~ to +~ Ex: …~ -3–2–1 0 1 2 3 4 5…~
- float: Python is a data type by using which we can create any decimal values …-~ to …+~
Ex: -1.2345 0.0 + 1.2
- 2234567893456254 →precise 16 decimal values
- 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
Complex:


