Python math.isqrt() Metodo
Esempio
Arrotonda per difetto una radice quadrata al numero intero più vicino:
# 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))
Definizione e utilizzo
Il math.isqrt()
metodo arrotonda un numero radice quadrata per difetto all'intero più vicino.
Nota: il numero deve essere maggiore o uguale a 0.
Sintassi
math.isqrt(x)
Valori dei parametri
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 |
Dettagli tecnici
Valore di ritorno: | Un int valore, che rappresenta la radice quadrata di un numero, senza decimali |
---|---|
Versione Python: | 3.8 |