type conversion | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

type conversion

>>> float("210" * int(input("Enter a number:" ))) Enter a number: 2 How does this works?

15th Apr 2020, 6:56 AM
PRIYANKA K
PRIYANKA K - avatar
4 Answers
+ 2
the input will be converted to integer, string and integer multiplication just repeat the string: "210"*2 ==> "210210" the result of the multiplication will finally be converted to float. so the final output is 210210.0 https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2427/
15th Apr 2020, 7:10 AM
John Robotane
John Robotane - avatar
+ 1
The class str support the multiplication and division "210"*2 = "210" + "210" = "210210" And the content for this value is the number and the float result is 210210.0
15th Apr 2020, 8:43 PM
HADÈS
HADÈS - avatar
0
1.input returns string 2.int casts value to integer 3."210" * integer value gives value times repeated "210" because strings have different multiplication operator 4.float casts string value to real number (noninteger)
15th Apr 2020, 7:12 AM
Stephan
Stephan - avatar
0
Thank you sir, my doubt has cleared
15th Apr 2020, 9:48 AM
PRIYANKA K
PRIYANKA K - avatar