+ 1
In this code, we are declaring type of parameters in function definition, also declaring type of output.
8 Respostas
+ 8
i just wanted to add some more information about type annotations.
> just using type annotations in an editor like *sololearn playground* or other *basic editors* does not make sence, since python does not do anything actively with this information, it just *provides* the information.
>> this is totally different with an editor like *visual studio code* (or other professional editors) by using the ide plugins like *pylance* or other linters. these tools /plugins are using the type annotations from the code file actively.
> they show e.g. warnings when there is a type mismatch from a function call and the corresponding paramarer type. so when we type the function name with a pair of parenthesis, the required data types are shown in a popup window.
> code areas that are affected by type problems will be underlined with a red *wavy* line.
> so using type annotations in the discribed way makes a lof of sence for me, because it reduces errors in coding.
+ 6
An annotation is only an annotation. It is rather part of the documentation. It does NOT do any type validation.
+ 4
The answer is: Python is not the appropriate language for it.
If you want this feature, use a language like Java which uses static typing.
Anyways
https://code.sololearn.com/c81BOyOW7CIu/?ref=app
+ 2
But we can assign any type of variable (str, int, float etc.) . Unable to understand whole code. Can anyone explain this?
+ 2
Lamron Thanks for sharing this valuable information
+ 1
Thanks Lothar for providing info
0
Thanks very much for quick reply.