Is three decimal places part of the question?

The solution is:

three_decimal_points = Decimal(‘0.2’) + Decimal(‘0.69’)
print(three_decimal_points)
four_decimal_points = Decimal(‘0.53’) * Decimal(‘0.65’)
print(four_decimal_points)

I didn’t get the point here, and the solution gives two decimals on three_decimal_points!

Where in the solution it says to the program the number of decimals?

3 Likes

Yeah I got the same result as brugerf:

three_decimal_points = Decimal('0.2') + Decimal('0.69')
print(three_decimal_points)

The above code only gives a result with 2 decimal points despite the exercise saying it should give 3 decimal points.

The bug has been reported but will invite a team member to examine this topic.

2 Likes

Which part of the code determines how many decimal points there will be?

1 Like

There is nothing in the instructions or description about there being any way to control it. Reporting as a bug.

This whole section is a mess.

3 Likes

No, this isn’t buggy at all. Hope this helps.

The instruction is to “Fix the floating point math below” so that it reflects 3 decimal places in three_decimal_points variable.
If you notice, it’s an addition problem which will result naturally into 2 decimal result, so you have to correct the “+” to " * " then you’ll get the three decimal places. :slight_smile:

# Import Decimal below:
from decimal import Decimal

# Fix the floating point math below:
three_decimal_points = Decimal('0.2') * Decimal('0.69')
print(three_decimal_points)
four_decimal_points = Decimal('0.53') * Decimal('0.65')
print(four_decimal_points)

Output:
0.138 <— three_decimal_points
0.3445 <— four_decimal_points

Also, the Decimal() knows how many decimals places to use based on what operations you use on your variables. Which is why it gave us 2 decimal places on the addition problem.

1 Like