Mooduli math meetod modf

Mooduli math meetod modf tagastab antud arvu murd- ja täisosast koosneva korteeži.

Süntaks

pythonimport math

math.modf(arv)

Näide

Uurime arvu 20 murd- ja täisosa:

pythonimport math

print(math.modf(20))

Koodi täitmise tulemus:

python(0.0, 20.0)

Näide

Rakendame nüüd meetodit modf arvule 20.56:

pythonimport math

print(math.modf(20.56))

Koodi täitmise tulemus:

python(0.5599999999999987, 20.0)

Vaata ka

  • funktsioon round,
    mis ümardab arvu
  • mooduli math meetod floor,
    mis ümardab arvu allapoole
  • mooduli math meetod ceil,
    mis ümardab arvu ülespoole