type conversion | SoloLearn: Learn to code for FREE!

+1

type conversion

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

4/15/2020 6:56:59 AM

PRIYANKA K

4 Answers

New Answer

+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/Python/2427/

+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

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)

0

Thank you sir, my doubt has cleared