python - Does python3 typecast entered input() value? -


i writing raingauge precipitation calculator based in radius of raingauge. when run script, have error message:

type de raingauge radius [cm]: 5.0 traceback (most recent call last):   file "pluviometro.py", line 27, in <module>     area_bocal = (pi * (raio_bocal * raio_bocal)) # cm.cm typeerror: can't multiply sequence non-int of type 'str' 

i using raio_bocal = input("type de raingauge radius [cm]:") data input. when using python2 typecasting automatic.

how can have float entered value using python3?

as mentioned in docs

the function reads line input, converts string (stripping trailing newline), , returns that

so need type cast float explicitly

raio_bocal = float(input("type de raingauge radius [cm]:")) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -