44 of 151 menu

The sqrt method of the math module

The sqrt method of the math module returns the square root of the number specified in the parameter. A real value is always returned.

Syntax

import math math.sqrt(number)

Example

Let's find the square root of the number 25:

import math print(math.sqrt(25))

Result of code execution:

5.0

Example

Now let's get the square root of 10:

import math print(math.sqrt(10))

Result of code execution:

3.1622776601683795

Example

Let's try to get the square root of a negative number:

import math print(math.sqrt(-100))

As a result of executing the code, we will see an error:

ValueError: math domain error

See also

  • method pow of module math,
    which raises a number to a power
  • 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