0

Did not understand float("210"*int(.......))

13th Aug 2016, 9:45 AM
SenÖr Yassine
SenÖr Yassine - avatar
3 ответов
+ 5
int(): convert some string numbers to int string*into:the string repeate by number "210"*2: "210210" float(): convert string number to float float("210210")=210210.0
13th Aug 2016, 10:15 AM
nima sadeghpour
0
yeah. in the 1st one it's just duplicating the string value. in next we're using the type conversion from int to float
13th Aug 2016, 1:33 PM
Gilli Vimalraj
Gilli Vimalraj - avatar
0
Long explanation. Might help future doubts from anyone. With float, we're declaring that the result will have a decimal value. "210" is being declared as a string, just like the input enters as a string. We change the input from string to a real number by declaring int (integer) before it. So, when you put float("210" *int(input()) ), you are multiplying the string by the input given by the user, and turns it into a decimal value once the process is done. The final result, using the question exercise becomes: 210210.0
19th Sep 2016, 1:19 PM
Tyrone Marin
Tyrone Marin - avatar