Python | fmod() function Last Updated : 20 Feb, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report fmod() function is one of the Standard math library function in Python, which is used to calculate the Module of the specified given arguments. Syntax: math.fmod( x, y ) Parameters: x any valid number (positive or negative). y any valid number(positive or negative). Returns: Return a floating point number value after calculating module of given parameters x and y. Time Complexity: O(1) Auxiliary Space: O(1) Example #1: Python3 # Python3 program to demonstrate fmod() function import math # Tuple Declaration Tup = (15, 22, -2, -40 ) # List Declaration Lis = [-89, 38, -39, 16] # modulus of +ve integer number print(math.fmod(4, 5)) print(math.fmod(43.50, 4.5)) # modulus of -ve integer number print(math.fmod(-17, 5)) print('%.2f' %math.fmod(-10, 4.78)) # modulus of tuple item print("\nModulus of tuple items:") print(math.fmod(Tup[2], 5)) print(math.fmod(Tup[2], -6)) # modulus of list item print("\nModulus of list items:") print(math.fmod(Lis[3], 4)) print(math.fmod(Lis[0], -15)) Output: 4.0 3.0 -2.0 -0.44 Modulus of tuple items: -2.0 -2.0 Modulus of list items: 0.0 -14.0 Example #2: ValueError and TypeError If both the x and y arguments are Zero, fmod() function will return the output as ValueError.If y argument (second argument) is Zero, fmod() function will return the output as ValueError.If the x value or y value is not a number, fmod() function will return TypeError. Python3 # Python3 program to demonstrate # errors in fmod() function import math # will give ValueError print(math.fmod(0, 0)) print(math.fmod(2, 0)) # it will give TypeError print(math.fmod('2', 3)) Output: ValueError: math domain error ValueError: math domain error TypeError: a float is required Comment More infoAdvertise with us Next Article Python | fmod() function J jana_sayantan Follow Improve Article Tags : Python Python-Library Python-Built-in-functions Python math-library Python math-library-functions +1 More Practice Tags : python Similar Reads Python | fsum() function fsum() is inbuilt function in Python, used to find sum between some range or an iterable. To use this function we need to import the math library. Syntax : maths.fsum( iterable ) Parameter : iterable : Here we pass some value which is iterable like arrays, list. Use : fsum() is used to find the sum 1 min read cmp() function - Python cmp() method in Python 2.x compares two integers and returns -1, 0, 1 according to comparison. cmp() does not work in python 3.x. You might want to see list comparison in Python.ExamplePython# Example 1 print(cmp(3, 4)) # Example 2 print(cmp(5, 5)) # Example 3 print(cmp(7, 6)) Output-101ExplanationI 3 min read Python Functions Python Functions is a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over an 9 min read Python | frexp() Function frexp() function is one of the Standard math Library function in Python. It returns mantissa and exponent as a pair (m, e) of a given value x, where mantissa m is a floating point number and e exponent is an integer value. m is a float and e is an integer such that x == m * 2**e exactly. If x is zer 2 min read dir() function in Python The dir() function is a built-in Python tool used to list the attributes (like methods, variables, etc.) of an object. It helps inspect modules, classes, functions, and even user-defined objects during development and debugging.Syntaxdir([object])Parameters: object (optional): Any Python object (lik 3 min read Like