The Python FMOD function is one of the Python Math function which is used to calculate the Module of the specified given arguments. In this article we will show you, How to use FMOD() function in Python Programming language with example.

## Syntax of a Python FMOD Function

The basic syntax of the FMOD Function in Python Programming Language is as shown below:

Math.fmod(x, y);

**X:**Please specify the X value here.**Y:**Please specify the Y value here. The FMOD() Function will use these X and Y arguments to find the Module.

**NOTE: **

- 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**

### Python FMOD Function Example

The Python FMOD function is used to calculate the Module of the specified given arguments. In this example, We are going to find the same for different data types and display the output

**PYTHON CODE**

# Python FMOD Function import math Tup = (10, 20, 12, -40 , 50) # Tuple Declaration Lis = [-98, 32, -39, -42 , 15] # List Declaration print('Calculating MOD of Positive Number = %.2f' %math.fmod(2, 3)) print('Calculating MOD of Negative Number = %.2f' %math.fmod(-14, 3)) print('Calculating MOD of Positive Decimal = %.2f' %math.fmod(22.45, 4.5)) print('Calculating MOD of Negative Decimal = %.2f' %math.fmod(-110, 14.78)) print('Calculating MOD of Tuple Item = %.2f' %math.fmod(Tup[2], 5)) print('Calculating MOD of Tuple Item = %.2f' %math.fmod(Tup[2], -5)) print('Calculating MOD of List Item = %.2f' %math.fmod(Lis[4], 4)) print('Calculating MOD of List Item = %.2f' %math.fmod(Lis[0], -15)) print('Calculating MOD of Multiple Number = %.2f' %math.fmod(10 + 20 - 12, 40)) print('Calculating MOD of String Value = ', math.fmod('2', 3))

**OUTPUT**

**ANALYSIS**

- At the beginning, We declared Python List and Tuple with some random values.
- Within the first two statements, We passed both the Positive integer and negative integer as the FMOD() Function arguments. From the above screenshot you can observe that, FMOD() Function is returning output.
- Within the next two statements, We passed both the Positive and negative decimals as the FMOD() Function arguments. As we said before, FMOD() Function is returning the output.
- Next four statements, We used the Python Tuple and List items as first arguments and Positive and negative integer values as second argument for FMOD() Function. If you observe the above screenshot, FMOD() function is working perfectly on them.
- Next statement, We assigned multiple values as the first arguments and the FMOD() Function worked without any issue.
- Next, We tried FMOD() Function on String value. As we said before, this will return
as output**TypeError**

Thank You for Visiting Our Blog