0
Basic Concepts - Type Conversion
In the question below What is the output of this code? >>> float("210" * int(input("Enter a number:" ))) Enter a number: 2 Answers Provided: a) "210210" b) 420 c) "420.0" d) 210210.0 (Correct Answer) If you enter >>> float("210" * int(input("Enter a number:" ))) in the IDLE and use the number "2" as instructed the answer you get is - 2. How do we end up with d) 210210.0 as the correct answer? What I'm I missing?
2 Réponses
+ 2
"210" is string. Multiplying it by integer 2 is 210210 (i.e. Repeating 210 two times)
Now, convert it to float resulting in 210210.0.
0
Thank you for your reply, I wasn't paying attention to the double quotation marks.