How can we control the rounding of our equation?

  + 0.69
  x 0.65

The number of decimal places is derived from the arithmetic.

1 Like

Hi mtf. Thanks for your response. What happens if, say, I want the first equation to print(one_decimal_point) instead of two? …

two_decimal_points = Decimal(β€˜0.2’) + Decimal(β€˜0.69’)
… somehow get to an output of …
β†’ only 0.9 …?

I see your example and it makes sense … but if what you say is true, then why in the lesson for this concept does the example produce a long string of numbers instead of just two decimals like what I wrote in green?

Is it that by adding (in front of the number) the word Decimal, we’re telling the computer to β€œHey, this number has two decimals so stick with a two decimal result?” Also, the lesson says that Decimal is a data type … which came from inside the decimal library/module right? Data type. Exactly like how strings and boolean are data types too right? So Decimal is NOT a function?

It will be helpful to have the documentation on hand when working with this module, at least until it is committed to memory.

1 Like

Thank you for this reference. I will study it!

1 Like

This was very helpful.

I needed to better understand the principle behind how decimal places are determined by the Decimal data type in the module.

I struggle remembering things when I do not understand how they work on a more fundamental level. It’s just how my mind works, and being someone who has taken a leap of faith for a career change from the medical field to IT at a later stage in life, the learning curve is steep and more challenging for me.

I believe many others like me will benefit from your post and the way you have analyzed and presented the information. Thank you so much. I will look out for more of your posts as I feel I may gain valuable insights from them.