In what situations should you use strings, integers, and float in python. plus when I should change my type when in between the parenthesis. Last what does it do when I add a certain name like string, integers, and float to the line of code.
For your first question, you might want to use strings
of things that contain mixed characters or alphabets, like names, addresses, let's say some character constants, (though you should use enums for that, but it is not what you aksed).
Then for int
type, they should be used in places where a integral value is required, such as counters, indexes, and maybe phone numbers if you want (for that some languages use long int
though), but if you don't want arithmetic on your phone numbers, better stick with strings
for them. Anything you want to operate on using +
, -
, *
, /
use int
, and not string
Lastly, when you want more precision than integers, like when keeping things like salaries, or account balances, thing like Rupees and Paise, or Dollar and cents become equally important. Or let's say you want to store measurements like 5.2m, integers are not useful, and here floats
are used, to keeps the parts after decimal.
For you other two questions, you should probably state the language you are talking about
Hope this helps