New Tutorials:   NUMPY    TKINTER    KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL    Matplotlib    C++ Programs

Converting String to Int or Float datatype and vice versa

Although variables in Python are not declared or defined by specifying their datatype. In python a variable automatically sets its datatype based on the first value saved in it. But it's very important to know how to convert one datatype into another. Here, we will learn how to convert String datatype into Int or Float datatype and vice versa.

Try changing the line 16 to numAdd = numInt + numStr, you will get an error, because numStr is a string. Click the button, to Run the code again.