You are implementing a function to calculate the factorial of a number. Which Python built-in data type would be most suitable to store the result for very large numbers?
- Decimal
- float
- int
- long
For very large numbers, the Decimal data type from the decimal module is the most suitable choice. It provides arbitrary-precision arithmetic and can handle extremely large integers without loss of precision. The int type has a limited size, and the float type is not suitable for precise integer calculations. The long type is not a standard Python type; Decimal is the recommended choice for arbitrary precision.
Loading...
Related Quiz
- What is the primary reason to use method overriding in object-oriented programming?
- What is the purpose of using setUp and tearDown methods in a unittest TestCase class?
- Which Python feature allows functions to accept any number of keyword arguments?
- What is the primary use of a generator expression in Python?
- In Matplotlib, the ____ function is used to add text annotations in arbitrary locations of the plot.