0
Did not understand float("210"*int(.......))
3 Answers
+ 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
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
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