Home » Python

math.remainder() method with example in Python

Python math.remainder() method: Here, we are going to learn about the math.remainder() method with example in Python.
Submitted by IncludeHelp, on April 18, 2019

Python math.remainder() method

math.remainder() method is a library method of math module, it is used to find the remainder of given numbers, it accepts two numbers (integer or float) and returns the remainder of the first number with respect to the second number in the float.

Note: math.remainder() method is available in the new version of Python – Python 3.7

Syntax of math.remainder() method:

    math.remainder(a, b)

Parameter(s): a, b – the numbers whose remainder needs to be calculated.

Return value: float – it returns a float value that is the remainder of a with respect to b.

Example:

    Input:
    a = 10
    b = 7

    # function call
    print(math.remainder(a, b))

    Output:
    3.0

Python code to demonstrate example of math.remainder() method

# python code to demonstrate example of 
# math.remainder() method

# importing math module
import math

# numbers
a = 10
b = 7
# finding remainder
print(math.remainder(a,b))

a = 10.2
b = 7.1
# finding remainder
print(math.remainder(a,b))

Output

3.0
3.0999999999999996





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL







Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.