Metoda Python math.isqrt().
Příklad
Zaokrouhlete číslo druhé odmocniny dolů na nejbližší celé číslo:
# Import math Library
import math
# Print the square
root of different numbers
print (math.sqrt(10))
print (math.sqrt (12))
print (math.sqrt (68))
print (math.sqrt (100))
# Round square root
downward to the nearest integer
print (math.isqrt(10))
print
(math.isqrt (12))
print (math.isqrt (68))
print (math.isqrt (100))
Definice a použití
Metoda math.isqrt()
zaokrouhlí číslo druhé odmocniny dolů na nejbližší celé číslo.
Poznámka: Číslo musí být větší nebo rovno 0.
Syntax
math.isqrt(x)
Hodnoty parametrů
Parameter | Description |
---|---|
x | Required. The number to round the square root of. If x is negative, it returns a ValueError. If x is not a number, it returns a TypeError |
Technické údaje
Návratová hodnota: | Hodnota int představující druhou odmocninu čísla bez desetinných míst |
---|---|
Verze Pythonu: | 3.8 |