Mathematical Functions in Python | Set 1 (Numeric Functions) Last Updated : 30 Aug, 2022 Comments Improve Suggest changes Like Article Like Report In python a number of mathematical operations can be performed with ease by importing a module named "math" which defines various functions which makes our tasks easier. 1. ceil() :- This function returns the smallest integral value greater than the number. If number is already integer, same number is returned. 2. floor() :- This function returns the greatest integral value smaller than the number. If number is already integer, same number is returned. Python # Python code to demonstrate the working of # ceil() and floor() # importing "math" for mathematical operations import math a = 2.3 # returning the ceil of 2.3 print ("The ceil of 2.3 is : ", end="") print (math.ceil(a)) # returning the floor of 2.3 print ("The floor of 2.3 is : ", end="") print (math.floor(a)) Output: The ceil of 2.3 is : 3 The floor of 2.3 is : 2 Time Complexity: O(1) Auxiliary Space: O(1) 3. fabs() :- This function returns the absolute value of the number. 4. factorial() :- This function returns the factorial of the number. An error message is displayed if number is not integral. Python # Python code to demonstrate the working of # fabs() and factorial() # importing "math" for mathematical operations import math a = -10 b= 5 # returning the absolute value. print ("The absolute value of -10 is : ", end="") print (math.fabs(a)) # returning the factorial of 5 print ("The factorial of 5 is : ", end="") print (math.factorial(b)) Output: The absolute value of -10 is : 10.0 The factorial of 5 is : 120 Time Complexity: O(b) Auxiliary Space: O(1) 5. copysign(a, b) :- This function returns the number with the value of 'a' but with the sign of 'b'. The returned value is float type. 6. gcd() :- This function is used to compute the greatest common divisor of 2 numbers mentioned in its arguments. This function works in python 3.5 and above. Python # Python code to demonstrate the working of # copysign() and gcd() # importing "math" for mathematical operations import math a = -10 b = 5.5 c = 15 d = 5 # returning the copysigned value. print ("The copysigned value of -10 and 5.5 is : ", end="") print (math.copysign(5.5, -10)) # returning the gcd of 15 and 5 print ("The gcd of 5 and 15 is : ", end="") print (math.gcd(5,15)) Output: The copysigned value of -10 and 5.5 is : -5.5 The gcd of 5 and 15 is : 5 Time Complexity: O(min(c,d)) Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Mathematical Functions in Python | Set 1 (Numeric Functions) M Manjeet Singh Improve Article Tags : Python School Programming Practice Tags : python 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 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 Types of Network Topology Network topology refers to the arrangement of different elements like nodes, links, or devices in a computer network. Common types of network topology include bus, star, ring, mesh, and tree topologies, each with its advantages and disadvantages. In this article, we will discuss different types of n 12 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 Java Exception Handling Exception handling in Java allows developers to manage runtime errors effectively by using mechanisms like try-catch block, finally block, throwing Exceptions, Custom Exception handling, etc. An Exception is an unwanted or unexpected event that occurs during the execution of a program, i.e., at runt 10 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 Enumerate() in Python enumerate() function adds a counter to each item in a list or other iterable. It turns the iterable into something we can loop through, where each item comes with its number (starting from 0 by default). We can also turn it into a list of (number, item) pairs using list().Let's look at a simple exam 3 min read Python Data Types Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of thes 9 min read Like