Python Math.isqrt() Metoda
Przykład
Zaokrąglij pierwiastek kwadratowy w dół do najbliższej liczby całkowitej:
# 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))
Definicja i użycie
Metoda math.isqrt()
zaokrągla pierwiastek kwadratowy w dół do najbliższej liczby całkowitej.
Uwaga: liczba musi być większa lub równa 0.
Składnia
math.isqrt(x)
Wartości parametrów
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 |
Szczegóły techniczne
Wartość zwrotu: | Wartość int reprezentująca pierwiastek kwadratowy liczby, bez miejsc po przecinku |
---|---|
Wersja Pythona: | 3,8 |