working on a python programming book.
in the book there is a section on numbers. One numeric type according to the book was introduced with Python 2.4, it is the decimal object. In the book they are using the interactive Python prompt and they say to type the following:
and in the book they show there answer:
Decimal("0.142857...etc.")
earlier in the book they say to import, the code that is needed to work with Decimals
by including the following code at the interactive prompt:
when i go to run the code from the book i get the following error from my Python interactive prompt:
any help?
in the book there is a section on numbers. One numeric type according to the book was introduced with Python 2.4, it is the decimal object. In the book they are using the interactive Python prompt and they say to type the following:
Code:
decimal.Decimal(1) / decimal.Decimal(7)
Decimal("0.142857...etc.")
earlier in the book they say to import, the code that is needed to work with Decimals
by including the following code at the interactive prompt:
Code:
from decimal import Decimal
Code:
>>> decimal.Decimal(1) / decimal.Decimal(7)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'decimal' is not defined