Free cookie consent management tool by TermsFeed The fmod() function - Python math module | Pythontic.com

The fmod() function - Python math module

Overview:

  • The function fmod() returns the floating point remainder of the division operation x/y of two numbers.
  • When the value of the denominator is zero the fmod() function raises an Exception stating ValueError: math domain error.

Example:

# Example Python program that returns the floating point
# remainder of x/y
import math

num1 = 10.5
num2 = 2.5

# Calculate the remainder
rem = math.fmod(num1, num2)
print("Remainder:")
print(rem)

Output:

Remainder:

0.5

 


Copyright 2025 © pythontic.com