51 of 151 menu

The modf method of the math module

The modf method of the math module returns a tuple consisting of the fractional and integer parts of the given number.

Syntax

import math math.modf(number)

Example

Let's find out the fractional and integer parts of the number 20:

import math print(math.modf(20))

Result of code execution:

(0.0, 20.0)

Example

Now let's apply the modf method to the number 20.56:

import math print(math.modf(20.56))

Result of code execution:

(0.5599999999999987, 20.0)

See also

  • function round,
    which rounds off the number
  • method floor of module math,
    which rounds a number down
  • method ceil of module math,
    which rounds a number up
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline