Chapter 3: Control Statements and Program Development 11
b. Financial institutions like banks that deal with millions or even billions of trans-
actions per day have to tie out their transactions “to the penny.” Floating-point
numbers can represent some but not all monetary amounts with to-the-penny
precision.
c. For monetary calculations and other applications that require precise repre-
sentation and manipulation of numbers with decimal points, the Python Standard
Library provides type Decimal, which uses a special coding scheme to solve the
problem of “to-the-penny precision.” Banks also have to deal with other issues
such as using a fair rounding algorithm when they’re calculating daily interest on
accounts. Type Decimal offers such capabilities.
d. Floating-point values are stored and represented precisely in binary format.
3.14 Q2: Which of the following statements a), b) or c) is false?
a. The Python Standard Library is divided into modules—groups of related capa-
bilities.
b. The decimal module defines type Decimal and its capabilities.
c. To use Decimal, you must first import its module, as in
import decimal
and refer to the Decimal type as decimal.Decimal, or you must indicate a spe-
cific capability to import using from…import, as in:
from decimal import Decimal
which imports only the type Decimal from the decimal module so that you can
use it in your code.
d. All of the above statements are true.
3.14 Q3: Which of the following statements is false?
a. You typically create a Decimal from a string.
b. Decimals support the standard arithmetic operators +, –, *, /, //, ** and %, as
well as the corresponding augmented assignments.
c. You may perform arithmetic between Decimals and integers.
d. You may perform arithmetic between Decimals and floating-point numbers.
3.14 Q4: Which of the following statements is false?