The solution given is wrong


#1

I think the solution given is wrong.
How can the statement : product=float_1*float_2 result in product being a string?


FAQ: Learn Python - Python Syntax - ValueError
#2

ValueError

Create a string called product that contains the result of multiplying the float value of float_1 and float_2.

Granted, this instruction is ambiguous, and the complaints go back well over a year. We just have to put on our thinking caps to interpret it how it must have been meant…

product = float_1 * float_2

We created a variable to reference the value of multiplying two floats. The above is a statement that does just that.

Next we are asked to represent it in a sentence, which in Python can only be done by converting the float value to a string value.

str(product)

What is also not obvious here is that a float times and int will result in a float as the product.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.