Pre-defined Function in python

We have already Learnt on the previous post that there is 14 Built in data types in python.

Today's Agenda

  • type()
  • int()
  • float()
  • ord()
  • complex()
Now ,
                  If you have to make a variable x i.e.x=5 then On run -time,the interpreter decides its type after considering the content of that variable .
we can also verify it by using a function called type() in IDLE.


Note:  IDLE is a short form of Integrated Development and learning Environment.

Type Conversion:  

                                At first ,we understand that why do we type conversion in python by an example.
let us consider that a variable
x=6                                                                   # int type
y="123"                                                            #str type
if you want to perform the operation such as addition between x and y then the interpreter gives an error because both are of different type .So At first, we must have  to do the type conversion like this then perform the operation.


So we can use the type conversion function like 
    int() -This function is used to convert into integer type.
    float()-This function is used to convert into float type.
    str()-This function is used to convert into string type
    ord()-It return the unicode of a character.

Let's see by an example of each function.
Note:There are  more predefined function available which we will definitely explore on the next post



Best of Luck                                                                                            Keep learn ,enjoy & Share it


                                               Do not forget to comment below this post



Comments

Popular posts from this blog

Comments in Python