0
Type conversion
sorry guys but I can't wrap my head around this one! can't someone give me an example for its positive uses?
2 ответов
0
for example: Users input always returns a string. imagine you'r making a calculator, you need numbers for that so you need to make the strings, numbers.
hope it helps
0
Hey. In Python you don't need to explicitly declare your variable, just assign some information to that variable name and Python understands the type. For example, a = "blabla". Python understands variable a have a string data. If b = "7" so it's also a string just like "blabla". You can't do any math with strings (don't consider concatenation or copying as math operations). If you want to add variable b to the integer 8, you can't. They're two different types. It's the same thing you're trying to add "blabla" to 8 or one orange to one hammer. So if you can, you convert variable b to integer and now you can add to 8.
Python always expects from input function a string, so if you wanna do some math with value, convert it float or integer.
Hope it helps.