as_integer_ratio() in Python for reduced fraction of a given rational Last Updated : 30 Nov, 2021 Comments Improve Suggest changes Like Article Like Report Given a rational number d, print the reduced fraction which gives d.Examples: Input : d = 2.5 Output : 5/2 Explanation: 5/2 gives 2.5 which is the reduced form of any fraction that gives 2.5 Input : d = 1.5 Output : 3/2 as_integer_ratio() function Python: Returns a pair of integers whose ratio is exactly equal to the original float and with a positive denominator. Syntax: float. as_integer_ratio() Return Value: Tuple (a pair of integers) Errors: Raises OverflowError on infinities and a ValueError on NaNs. In Python we have an inbuilt function as_integer_ratio() which prints the reduced fraction form of any given rational number d. We need to store that in any variable and then print the 0th index and 1st index of the stored fraction. Python3 # function to print the fraction of # a given rational number def reducedfraction(d): # function that converts a rational number # to the reduced fraction b = d.as_integer_ratio() # reduced the list that contains the fraction return b # driver code b = reducedfraction(2.5) print (b[0], "/", b[1]) Output: 5 / 2 Comment More infoAdvertise with us Next Article as_integer_ratio() in Python for reduced fraction of a given rational S Striver Follow Improve Article Tags : Misc Python Python-Library rational-numbers Fraction +1 More Practice Tags : Miscpython Similar Reads Python Tutorial | Learn Python Programming Language Python Tutorial â Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly.Python is:A high-level language, used in web development, data science, automatio 10 min read Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth 15+ min read SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e 7 min read Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p 11 min read TCP/IP Model The TCP/IP model (Transmission Control Protocol/Internet Protocol) is a four-layer networking framework that enables reliable communication between devices over interconnected networks. It provides a standardized set of protocols for transmitting data across interconnected networks, ensuring efficie 7 min read Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether youâre a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Hereâs a list 10 min read Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test 9 min read Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co 11 min read Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br 14 min read Unified Modeling Language (UML) Diagrams Unified Modeling Language (UML) is a general-purpose modeling language. The main aim of UML is to define a standard way to visualize the way a system has been designed. It is quite similar to blueprints used in other fields of engineering. UML is not a programming language, it is rather a visual lan 14 min read Like