PROGRAMMING
GAME DEVELOPMENT
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.
CODE SNIPPETS
;
to join two Executable Statements/
to break code into multiline codelen()
, find()
, replace()
& split()
zip
function to iterate over two Listsdel
, remove()
or pop()
insert()
, reverse()
& sort()
What is Studytonight?
Tutorials
Learn to Code
Interview Questions
/code/python/python-string-to-int-float-coversion.php