Fraction Module in PythonPython Fraction module is used to work with the arithmetic of rational numbers. This module allows us to create a Fractional instance of integers, floats, numbers, decimal, and strings. What is a Fractional Instance?Fractional instances can be created using the pair of integers, or from a string, or another rational number. These are hashable and should be treated as mutable. How to create a fractional instance?Fraction module provides the following built-in functions that are used to create fraction. Let's understand the following ways of creating fraction instance.
Example - Output: 10/37 11/18 0
Example - Output: 6004799503160661/72057594037927936
Example - Output: 113/50
Example - Output: 7/25 123/100 3/5 1414213/1000000
Example - Output: 157079632679489661923/50000000000000000000 355/113 311/99 22/7 5 2 Example - 2: Perform Mathematical Operation on Fractional Output: 404/75 25/12 32/45 3/2 2.4326050606703427 ConclusionIn this tutorial, we have discussed Fraction module and its few important methods. These methods can be used in the complex mathematical computation and machine learning project.
Next TopicPopular Python Framework to Build API
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week